Git Product home page Git Product logo

homeassistant-homeconnect's Introduction

⚠️ This repository is no longer up to date with the Home Assistant Core integration and is no longer actively maintained. Please raise feature requests and issues against Home Assistant Core. ⚠️

Home Assistant Home Connect development repository

Custom component for testing experimental features of the Home Assistant Home Connect intgegration.

Usage

  1. Register an account with the Home Connect Developer Program
  2. Register a new application with OAuth Flow type Authorization Code Grant Flow and Redirect URI https://YOUR_HOMEASSISTANT_BASE_URL:PORT/auth/external/callback (it will not work without https, but your Home Assistant instance does not have to be accessible from the internet and a self-signed certificate will do)
  3. Make sure the http component in your configuration.yaml has the base url set to YOUR_HOMEASSISTANT_BASE_URL:PORT (it will not work otherwise)
  4. Add the following to your configuration.yaml:
home_connect_beta:
  client_id: YOUR_CLIENT_ID
  client_secret: YOUR_CLIENT_SECRET
  1. Copy the contents of custom_components to the custom_components directory of your Home Assistant configuration directory
  2. Navigate to the Integrations page and select "Home Connect"

Step 5 can also be replaced by using HACS and adding this repository as a custom repistory.

Feedback

Since the Home Connect component originally developed in this repository has been merged into Home Assistant Core as of May 5, 2020, this custom component will only be used for testing new features. You are welcome to contribute pull requests, but of course any bug fixes and serious improvements can also be directly submitted to Home Assistant Core.

homeassistant-homeconnect's People

Contributors

andre68723 avatar badguy99 avatar davidmstraub avatar holnburger avatar kayjei avatar krocko avatar marcuskapun avatar robvanuden avatar sjack-sch avatar volshebniks avatar yusijs avatar zufivan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

homeassistant-homeconnect's Issues

Directory structure needs changed, warnings after 0.88.0 upgrade

WARNING (MainThread) [homeassistant.loader] Integrations need to be in their own folder. Change sensor/homeconnect.py to homeconnect/sensor.py. This will stop working soon.

I've manually moved binary_sensor/homeconnect.py, sensor/homeconnect.py and switch/homeconnect.py in my installation to homeconnect/binary_sensor.py, homeconnect/sensor.py and homeconnect/switch.py, this seems to be working fine at first glance.

OAuth 2 MUST utilize https

I'm trying to link my Home Connect account, but get this 500 Internal Server Error on the callback after I approved my application to access my account:

500 Internal Server Error
Server got itself in trouble

The callback URL censored) : https://smarthome.xxxxxxxxxxxxxxxxxxx.xxx/api/homeconnect?code=eyJ4XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx&state=rBzaXXXXXXXXXXXXXXXXXXXXXXXXx&grant_type=authorization_code

In my homeassistant.log I see this error:

2019-01-09 20:57:47 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/opt/homeassistant/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/opt/homeassistant/lib/python3.5/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "/opt/homeassistant/lib/python3.5/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/auth.py", line 99, in auth_middleware
    return await handler(request)
  File "/opt/homeassistant/lib/python3.5/site-packages/homeassistant/components/http/view.py", line 118, in handle
    result = await result
  File "/home/homeassistant/.homeassistant/custom_components/homeconnect/__init__.py", line 123, in get
    hass.async_add_job(
  File "/opt/homeassistant/lib/python3.5/site-packages/homeconnect/api.py", line 95, in get_token
    client_secret=self.client_secret)
  File "/opt/homeassistant/lib/python3.5/site-packages/requests_oauthlib/oauth2_session.py", line 187, in fetch_token
    state=self._state)
  File "/opt/homeassistant/lib/python3.5/site-packages/oauthlib/oauth2/rfc6749/clients/web_application.py", line 174, in parse_request_uri_response
    response = parse_authorization_code_response(uri, state=state)
  File "/opt/homeassistant/lib/python3.5/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 221, in parse_authorization_code_response
    raise InsecureTransportError()
oauthlib.oauth2.rfc6749.errors.InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https.

I use a nginx reverse proxy with let's encrypt for the https, I also have the base_url in my HA-config. I've checked the browser communication with the developer tools and saw that all of the communication was over https.

Any tips to get my Home Connect linked or any clue why this error occurs?

Thanks in advance!
Dennis

HACS support?

Thank you so much for creating this integration!

I see there is a hacs.json file in this repo, but I can't seem to find this integration in HACKS/Community in my Homeassistant page.

Am I missing something?

Washing machine door gets the state “unavailable” when program starts and the door gets locked.

Washing machine door gets the state “unavailable” when program starts and the door gets locked. When the program finish it gets status "closed".
Here is the json delivered to HA and the information comes under BSH.Common.Status.DoorState as 'value': 'BSH.Common.EnumType.DoorState.Locked'

{'BSH.Common.Status.RemoteControlActive': {'timestamp': 1544013996, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/status/BSH.Common.Status.RemoteControlActive', 'value': True, 'level': 'hint'}, 'BSH.Common.Status.LocalControlActive': {'timestamp': 1544013996, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/status/BSH.Common.Status.LocalControlActive', 'value': False, 'level': 'hint'}, 'BSH.Common.Status.OperationState': {'timestamp': 1544013993, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/status/BSH.Common.Status.OperationState', 'value': 'BSH.Common.EnumType.OperationState.Run', 'level': 'hint'}, 'BSH.Common.Status.DoorState': {'timestamp': 1544013993, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/status/BSH.Common.Status.DoorState', 'value': 'BSH.Common.EnumType.DoorState.Locked', 'level': 'hint'}, 'BSH.Common.Status.RemoteControlStartAllowed': {'value': False}, 'LaundryCare.Washer.Option.Temperature': {'timestamp': 1544003180, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/programs/selected/LaundryCare.Washer.Option.Temperature', 'value': 'LaundryCare.Washer.EnumType.Temperature.GC40', 'level': 'hint'}, 'BSH.Common.Root.ActiveProgram': {'timestamp': 1544013993, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/programs/active', 'value': 'LaundryCare.Washer.Program.Cotton', 'level': 'hint'}, 'BSH.Common.Option.RemainingProgramTime': {'timestamp': 1544015465, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/programs/active/BSH.Common.Option.RemainingProgramTime', 'unit': 'seconds', 'value': 7920, 'level': 'hint'}, 'BSH.Common.Option.ProgramProgress': {'timestamp': 1544015465, 'handling': 'none', 'uri': '/api/homeappliances/SIEMENS-WMH6W649DN-************/programs/active/BSH.Common.Option.ProgramProgress', 'unit': '%', 'value': 15, 'level': 'hint'}, 'BSH.Common.Event.ProgramFinished': {'timestamp': 1544013978, 'handling': 'acknowledge', 'value': 'BSH.Common.EnumType.EventPresentState.Off', 'level': 'hint'}}

"unauthorized_client"

Hi, I have to say, this is an excellent work. But I still got some problems.

When I followed the guide install this plug-in and reset the HA service, I got a error:
{
"error": "unauthorized_client",
"error_description": "client or redirection URI not authorized",
"state": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmbG93X2lkIjoiZmIwOTEzYzMwYjE3NGQyYjg2ZjZkMzQ3ZTIxNjdhYjUifQ.aidwZ7ZCaOVAODfL3FRygYna-xQfEuwh_iflteVhzoA"
}
Is this mean I need to verify my application in HomeConnectDev?

BTW, my application's OAuth Flow is Authorization Code Grant Flow.

Home Appliance Events

Hi,

Thank you for integrating HomeConnect with HA, awesom work!
I just upgraded and it works perfectly with HA 102.1.

This is a Wish and I would love to have an event sensor, if I knew more about Python and HA integrations, I would try to contribute with this myself.
So I make a wish here, guess that there are more people who would like to get status messages to HA from HomeConnect.
The part of the HomeConnect API I'm referring to is

Program Progress Events
Home Appliance Events.

500 Internal Server Error

I'm trying to run this on hassio, but have SSL enabled via a reverse proxy (Caddy), my site is accessible via the internet at https://hasstest.domain.com, but trying to access the /api/homeconnect endpoint gives me the following error

500 Internal Server Error
Server got itself in trouble

The error log in hass when I try and complete the auth flow shows

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 390, in start
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_app.py", line 366, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 106, in impl
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/static.py", line 66, in staticresource_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 107, in auth_middleware
    return await handler(request)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 115, in handle
    result = await result
  File "/config/custom_components/homeconnect/__init__.py", line 123, in get
    self.hc.get_token(str(request.url))
  File "/config/deps/lib/python3.6/site-packages/homeconnect/api.py", line 95, in get_token
    client_secret=self.client_secret)
  File "/usr/local/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 187, in fetch_token
    state=self._state)
  File "/usr/local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/web_application.py", line 174, in parse_request_uri_response
    response = parse_authorization_code_response(uri, state=state)
  File "/usr/local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 221, in parse_authorization_code_response
    raise InsecureTransportError()
oauthlib.oauth2.rfc6749.errors.InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https.

I'm assuming that this is to do with SSL being terminated at the proxy rather than on the hass box

HACS Integration

Hi!

This is not a issue, it's more an enhancement. Would it be possible to integrate your custom component into HACS?

As far i can see you only need to add a file called "hacs.json" to your repository with some content like this.

Regards
Richard

Page Not Found

hi.
trying to get this to work.
after a little struggling i have now com to

in Home assistant i get

**Invalid config
The following components and platforms could not be set up:

homeconnect**

and if i press "homeconnect it links to
https://www.home-assistant.io/components/homeconnect/

and i gets

**Page Not Found

Looks like you've followed a broken link or entered a URL that doesn't exist on this site.**

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 172, in _async_setup_component
component.setup, hass, processed_config # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/homeconnect/init.py", line 49, in setup
from homeconnect import HomeConnect
ImportError: cannot import name 'HomeConnect' from 'homeconnect' (/config/homeconnect/init.py)

some help ?
grettings
tommy

Oven programs don't start

Finally I was able to connect my oven with this integration. Great work, thank you very much!

I can see valid sensor values and the general turn on/off switch for the oven is working fine.
However if I try to select on of the program switches I don't see any response on my device.
I would also expect that I need to set a temperature which I could not see anywhere.

"error": "unauthorized_client",

Can you explain a bit further, what to do on developer.home-connect.com.
I have registered for an account, made an application, but get error. Should I do more?

{
"error": "unauthorized_client",
"error_description": "client or redirection URI not authorized",
"state": "bRl6aNDDAcf6sRuxYYUuJ5yilThuDv"
}

Operation state and fridge settings implementation request

No posts found

I'm getting "No posts found".
Followed the setup instructions.

  • Created and activated bosch dev account
  • Set up auth:
    • type: legacy_api_password
      api_password: !secret http_password
  • set up config:
    • homeconnect:
      client_id: scsdcsdc
      client_secret: csdcsdcsdcd
  • Connected via url that showed up as notification, "click this link", which I did, and acknowledged the access

What happened here is that I realized I had "shields up for this site", in the Brave browser, when I saw an empty popup-window in HA. (running HASSIO).

  1. How to re-run this linking step?
  2. Any plans for changing the auth before 0.96?
2019-05-01 05:33:25 WARNING (MainThread) [homeassistant.components.websocket_api.http.connection.1862184592] Disconnected: Did not receive auth message within 10 seconds
2019-05-01 05:33:31 WARNING (MainThread) [homeassistant.components.http.view] Access from trusted networks without auth token is going to be removed in Home Assistant 0.96. Configure the trusted networks auth provider or use long-lived access tokens to access /api/ios/identify from 1.2.3.4
2019-05-01 05:33:31 WARNING (MainThread) [homeassistant.components.http.view] Access from trusted networks without auth token is going to be removed in Home Assistant 0.96. Configure the trusted networks auth provider or use long-lived access tokens to access /api/services/device_tracker/see from 1.2.3.4
2019-05-01 05:33:43 ERROR (MainThread) [frontend.js.latest.201904240] https://xxxxxxxxredacted/frontend_latest/chunk.4e658893eb3987694e23.js:1:973 TypeError: undefined is not an object (evaluating 'window.webkit.messageHandlers.externalBus.postMessage')

Implement service calls to talk to the API

The currently implemented program switches are of limited use as they do not allow to change settings. For more fine-grained control, the easiest and most flexible solution IMO is to implement service calls that directly talk to the HomeConnect API.

Oven-control scope not granted

Hi David,

Thanks so much for your work on the component, it's great!
I currently have a Siemens Home Connect enabled oven and am trying to hook it up to Home Assistant. I have followed all the steps as outlined in the readme and it seems to work fine. When I open or close the oven door the 'Door' entity gets updated correctly. The 'on' switch does not work, as per #10 .

However, all of the other oven controls (Pre heating, Hot air, etc) do not work. The log shows homeconnect.api.HomeConnectError: {'description': 'Insufficient scope for this resource', 'key': 'insufficient_scope'}
If I check the Granted Scopes table in the Home Connect developer Program for the application that I have created the oven-control scope in the Control column is greyed-out. Please see the attached screenshot.

schermafbeelding 2019-02-17 om 14 57 28

Do you by any chance know how to enable this? I cannot seem to find a setting somewhere to enable it... Thanks in advance, your work is much appreciated!

Add more sensors

E.g. oven core temperature.

Is there a list of sensors supported by the API somewhere??

Does not work after .097>

Traceback (most recent call last):
File "/usr/src/app/homeassistant/setup.py", line 172, in _async_setup_component
component.setup, hass, processed_config # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/homeconnect/init.py", line 57, in setup
simulate=config.get(DOMAIN, {}).get('simulate', False))
File "/usr/local/lib/python3.7/site-packages/homeconnect/api.py", line 30, in init
self.connect()
File "/usr/local/lib/python3.7/site-packages/homeconnect/api.py", line 69, in connect
token = self.token_load()
File "/usr/local/lib/python3.7/site-packages/homeconnect/api.py", line 50, in token_load
token = json.load(f)
File "/usr/local/lib/python3.7/json/init.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/local/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 4258 (char 4257)

Home Connect API token expired

Over the weekend I started getting this error:

`2019-03-12 20:53:00 ERROR (MainThread) [homeassistant.setup] Error during setup of component homeconnect
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 395, in request
http_method=method, body=data, headers=headers)
File "/srv/homeassistant/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/setup.py", line 154, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/config/custom_components/homeconnect/init.py", line 72, in setup
hass.data[DOMAIN]['devices'] = get_devices(hc)
File "/srv/homeassistant/config/custom_components/homeconnect/init.py", line 129, in get_devices
appl = retry(hc.get_appliances, times=20, sleep=0.1)
File "/srv/homeassistant/config/custom_components/homeconnect/init.py", line 120, in retry
return f()
File "/srv/homeassistant/lib/python3.6/site-packages/homeconnect/api.py", line 146, in get_appliances
data = self.get(ENDPOINT_APPLIANCES)
File "/srv/homeassistant/lib/python3.6/site-packages/homeconnect/api.py", line 101, in get
res = self.oauth.get(uri)
File "/srv/homeassistant/lib/python3.6/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/srv/homeassistant/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 408, in request
self.auto_refresh_url, auth=auth, **kwargs
File "/srv/homeassistant/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 374, in refresh_token
self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
File "/srv/homeassistant/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 415, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/srv/homeassistant/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 425, in parse_token_response
validate_token_parameters(params)
File "/srv/homeassistant/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 432, in validate_token_parameters
raise_from_error(params.get('error'), params)
File "/srv/homeassistant/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 405, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) invalid refresh_token`

I've created a new app in Home Connect Developers portal and tried using new credentials, I still get the same error.

Versions in use:
(homeassistant) homeassistant@hass0:~$ pip freeze | egrep -i '^homeconnect=|^homeassistant=' homeassistant==0.89.1 homeconnect==0.2.1

I'm also using the master branch ofDavidMStraub/homeassistant-homeconnect and this is located in custom_components/homeconnect.

Any thoughts?

HACS integration

Dear David,
Thank you very much for your efforts to get this custom component to work in Hassio. Today I've reinstalled HACS and installed your HomeConnect custom component. After following steps 1 through 5 from the instructions, I go to Integrations to get the HomeConnect component started. The first time it took a long time before a screen came back with the message 'Aborted'. Now, no matter how often I try to delete and reinstall, the same message keeps coming back. There is no error in the log files and the Home Assistant components remains red (not configured) in HACS.

Any direction is very much appreciated.

Bekomm es einfach nicht ans Laufen

Hallo!

Hab die Komponente mittels HACS installiert

in configuration.yamhl steht unter base url https://famxxxxx.duckdns.org:8123

Ich kann auch per app drauf zugreifen, also der https über duckdns läuft

ruf ich die adresse inkl /auth/external/callback auf kommt folgende Meldung:

Missing code or state parameter in https://famxxxxxxxx.duckdns.org:8123/auth/external/callback

in der configuration.yaml hab ich homeconnect drin und sowohl client id und secret aus der siemens app übernommen.

Leider kommt bei mir aber keine entity daher

Kann mir wer helfen?

Logging in HASS

Can I edit the log level? Now I got very much log entries in HASS

Integration stops working after some time

I only have a Home Connected hob in the house. I monitor the hob status with this integration and connect some actions to it (e.g. turn on lights above the hob when it is turned on).

This works perfectly after a (re)start of the Home Assistant server. Only after a few hours the Hob state is not updated any more.

Running with debug logging now to see if I can spot the cause. No hints in any of the logs previously.

Obviously the connection with Home Connect is terminated for some reason. Would't it be a good idea to run some form of self-check and reopen the connection in case of problems?

Will update this ticket when I find out anything more from the logs.

Config flow not working

Hi, thanks for all the recent work which you've put into this.

I'm unable to authenticate via the the new config flow integration, I get the following error when I try to add the Home Connect integration.

Screenshot_20191120-092632

I'm running home assistant 102.0b2, have your component installed via HACS (the current code in the master branch) and have updated the callback URL in the home connect developer site as per the docs.

I'll enable more verbose logging, as I currently have no more useful information to look into this.

Save more properties of the devices

It would be nice if more properties are saved. Every property via the SSE connection could be saved in the attributes of a sensor. These can be used in template sensors for example.
For example the currently selected program or the "remote control allowed state" of a dishwasher aren't visible yet in HA.
I think we can start saving it as attributes and maybe later on adding more "real" sensors.

I'm new to python, but I think it's something I could work on.

Let me know what you think.

Implement config flow

Now that HA allows custom components to use the config flow, this should be done.

Expired token not refreshed

HA log:

homeconnect.api.HomeConnectError: {'description': 'The access token expired', 'key': 'invalid_token'}

This should not have happened; rather, the refresh token should have been used to fetch a new one.

Error loading custom_components.homeconnect.

I've followed the instruction. Copied the folder homeconnect into /custom-components
Added homeconnect: to configuration.yaml

Receives this error:

2020-01-26 14:56:52 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.homeconnect. Make sure all dependencies are installed
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/loader.py", line 379, in _load_file
module = importlib.import_module(path)
File "/usr/local/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/custom_components/homeconnect/init.py", line 21, in
from . import api, config_flow
File "/config/custom_components/homeconnect/api.py", line 6, in
import homeconnect
ModuleNotFoundError: No module named 'homeconnect'
2020-01-26 14:56:57 ERROR (MainThread) [homeassistant.components.hassio] Component error: homeconnect - Integration 'homeconnect' not found.

Problems with setup

Hi,

I installed HACS and it works for another component, then I add your Homeconnet.
I have a Siemens Dishwasher fully visible in the Home Connect App on my phone.
I create this developer and application on the Home Connect Developer page and took the relevant code and the URL as per my configuration.yaml file which looks like this:

`http:
base_url: hassio.local:8123 (3 spaces in the beginning of this line)

homeconnect:
client_id: 7B55..... (3 spaces in the beginning of this line)
client_secret: FA77... (3 spaces in the beginning of this line)`

The good thing is I have nothing in my Error Log after reboot. The bad thing is that I still don@t recognise my dischwasher in Homeassistant. Do I need to configure it on top somewhere somehow? Sorry but I do miss this in the descriptions.

kind regards

Add missing programs

Washer:
{'name': 'LaundryCare.Washer.Program.Sensitive',},
{'name': 'LaundryCare.Washer.Program.Auto30',},
{'name': 'LaundryCare.Washer.Program.Auto40',},
{'name': 'LaundryCare.Washer.Program.Auto60',},
{'name': 'LaundryCare.Washer.Program.Chiffon',},
{'name': 'LaundryCare.Washer.Program.Curtains',},
{'name': 'LaundryCare.Washer.Program.DarkWash',},
{'name': 'LaundryCare.Washer.Program.Dessous',},
{'name': 'LaundryCare.Washer.Program.Monsoon',},
{'name': 'LaundryCare.Washer.Program.Outdoor',},
{'name': 'LaundryCare.Washer.Program.PlushToy',},
{'name': 'LaundryCare.Washer.Program.ShirtsBlouses',},
{'name': 'LaundryCare.Washer.Program.SportFitness',},
{'name': 'LaundryCare.Washer.Program.Towels',},
{'name': 'LaundryCare.Washer.Program.WaterProof',},

Dryer:
{'name': 'LaundryCare.Dryer.Program.Blankets',},
{'name': 'LaundryCare.Dryer.Program.BusinessShirts',},
{'name': 'LaundryCare.Dryer.Program.DownFeathers',},
{'name': 'LaundryCare.Dryer.Program.Hygiene',},
{'name': 'LaundryCare.Dryer.Program.Jeans',},
{'name': 'LaundryCare.Dryer.Program.Outdoor',},
{'name': 'LaundryCare.Dryer.Program.SyntheticRefresh',},
{'name': 'LaundryCare.Dryer.Program.Towels',},
{'name': 'LaundryCare.Dryer.Program.Delicates',},
{'name': 'LaundryCare.Dryer.Program.Super40',},
{'name': 'LaundryCare.Dryer.Program.Shirts15',},
{'name': 'LaundryCare.Dryer.Program.Pillow',},
{'name': 'LaundryCare.Dryer.Program.AntiShrink',},

Hood not implemented

I temporarily threw in a load of additional logging to try and find out why I was authenticated, but got no devices, no logs and no errors.

I could see that I was receiving valid JSON back from the API, the first item received back was a hood, and there's nothing specified for a hood in the get_devices function, so it just goes to the else: break without returning anything.

I can imagine that there are 2 fixes to come for this:

  • Handle an unsupported device more elegantly, with logging of the error, and continuing to load the supported devices
  • Introduce support for a hood, this could be represented as a fan and a light in HA (I'm going to try and find time to put in a PR for this)

missing status for dishwasher

Hi,

many Thanks first of all for this integration.

Homeaconnect show further status messages but the integration not yet.
Things like
the salt comes to a end, or
the rinse aid, or
that I shall use the mashine cleaning program.

Would be great if this could be added.

No module named "homeconnect"

Not sure if I am doing something totally stupid or not, but I have followed the installation details, created my app on the home connect website, then copied the custom component to my hass config custom components folder, and added the config settings as described.

When restarting hass, my log contains...

2020-01-10 17:19:37 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.homeconnect. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/loader.py", line 346, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/media/USBHDD1/homeassistant/custom_components/homeconnect/__init__.py", line 21, in <module>
    from . import api, config_flow
  File "/media/USBHDD1/homeassistant/custom_components/homeconnect/api.py", line 6, in <module>
    import homeconnect
ModuleNotFoundError: No module named 'homeconnect'
2020-01-10 17:19:37 ERROR (MainThread) [homeassistant.components.homeassistant] Component error: homeconnect - Integration 'homeconnect' not found.

This a python version issue, or something else? I am running 0.102.1. I have one other custom component, heatmiserneo.

Thanks

'OAuth2Session' object has no attribute 'async_refresh_token'

The specific backtrace that I get is slightly different than the one posted above:

Error setting up entry Configuration.yaml for homeconnect

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeconnect/api.py", line 65, in request
    return getattr(self._oauth, method)(url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests_oauthlib/oauth2_session.py", line 478, in request
    url, http_method=method, body=data, headers=headers
  File "/usr/local/lib/python3.7/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired) 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 192, in async_setup
    hass, self
  File "/config/custom_components/homeconnect/__init__.py", line 82, in async_setup_entry
    await update_all_devices(hass, entry)
  File "/config/custom_components/homeconnect/__init__.py", line 114, in update_all_devices
    data[DEVICES] = await hass.async_add_executor_job(hc.get_devices)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/homeconnect/api.py", line 45, in get_devices
    appl = self.get_appliances()
  File "/usr/local/lib/python3.7/site-packages/homeconnect/api.py", line 123, in get_appliances
    data = self.get(ENDPOINT_APPLIANCES)
  File "/usr/local/lib/python3.7/site-packages/homeconnect/api.py", line 73, in get
    res = self.request("get", endpoint)
  File "/usr/local/lib/python3.7/site-packages/homeconnect/api.py", line 67, in request
    self._oauth.token = self.refresh_tokens()
  File "/config/custom_components/homeconnect/api.py", line 39, in refresh_tokens
    self.session.async_ensure_token_valid(), self.hass.loop
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 435, in result
    return self.__get_result()
  File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 403, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
AttributeError: 'OAuth2Session' object has no attribute 'async_refresh_token'

I installed home-connect via HACS and then added it via "Integrations", yes. I still have the

homeconnect:
  client_id: !secret homeconnect_id
  client_secret: !secret homeconnect_secret

entry in my configuration.yaml, though.

I previously had the custom component manually installed without HACS, but I completely removed the folder in /config/custom_components/ before reinstalling via HACS.

Originally posted by @sharkdp in #17 (comment)

Home Connect Coffee Machine not starting

I cant start my Coffee Machine, everything else (Coffee, Espresso, ... ) is working if i power on my Machine manually (physical)

error on start of HA:

2018-12-12 23:06:41 WARNING (MainThread) [homeassistant.loader] You are using a custom component for homeconnect which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.
2018-12-12 23:06:44 ERROR (SyncWorker_3) [custom_components.homeconnect] <bound method HomeConnectAppliance.get_programs_active of HomeConnectAppliance(hc, haId='SIEMENS-XXXXXXX', vib='XXXXXXX', brand='Siemens', type='CoffeeMaker', name='Kaffeevollautomat', enumber='XXXXXX/03', connected=True)> {'key': 'SDK.Error.NoProgramActive', 'description': 'There is no program active'}
2018-12-12 23:06:45 ERROR (SyncWorker_3) [custom_components.homeconnect] Error while executing <bound method HomeConnectAppliance.get_programs_active of HomeConnectAppliance(hc, haId='SIEMENS-TXXXXXXXXXXX', vib='TI909701HC', brand='Siemens', type='CoffeeMaker', name='Kaffeevollautomat', enumber='XXXXXX3', connected=True)>. Retry #1
2018-12-12 23:06:45 ERROR (SyncWorker_3) [custom_components.homeconnect] <bound method HomeConnectAppliance.get_programs_active of HomeConnectAppliance(hc, haId='SIEMENS-XXXXX', vib='TXXXXXXX', brand='Siemens', type='CoffeeMaker', name='Kaffeevollautomat', enumber='XXXXXC/03', connected=True)> {'key': 'SDK.Error.NoProgramActive', 'description': 'There is no program active'}

after powering on the machine manually:

2018-12-13 00:10:08 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2967527792] Received {'type': 'call_service', 'domain': 'switch', 'service': 'turn_on', 'service_data': {'entity_id': 'switch.kaffeevollautomat'}, 'id': 16}
2018-12-13 00:10:08 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=switch, service=turn_on, service_data=entity_id=switch.kaffeevollautomat>
2018-12-13 00:10:08 DEBUG (SyncWorker_4) [custom_components.switch.homeconnect] tried to switch on Kaffeevollautomat
2018-12-13 00:10:08 DEBUG (SyncWorker_4) [requests_oauthlib.oauth2_session] Invoking 0 protected resource request hooks.
2018-12-13 00:10:08 DEBUG (SyncWorker_4) [requests_oauthlib.oauth2_session] Adding token {'id_token': 'xxx', 'access_token': 'xxx', 'expires_in': 81336.79819726944, 'scope': ['Dryer-Settings', 'Washer-Control', 'Dryer-Monitor', 'Settings', 'IdentifyAppliance', 'Washer-Settings', 'CoffeeMaker', 'Washer', 'Hob-Settings', 'Oven-Monitor', 'Hood-Control', 'WasherDryer-Monitor', 'Oven-Settings', 'CoffeeMaker-Monitor', 'Monitor', 'Hob-Monitor', 'WasherDryer-Control', 'Dishwasher-Control', 'Dishwasher', 'Dryer-Control', 'CleaningRobot-Control', 'WasherDryer', 'Dishwasher-Settings', 'Hood', 'Dryer', 'FridgeFreezer-Monitor', 'CleaningRobot-Settings', 'Dishwasher-Monitor', 'CoffeeMaker-Settings', 'FridgeFreezer-Settings', 'CleaningRobot-Monitor', 'CoffeeMaker-Control', 'Washer-Monitor', 'Hood-Monitor', 'Hood-Settings', 'WasherDryer-Settings'], 'refresh_token': 'xxx', 'token_type': 'Bearer', 'expires_at': 1544737302.7981973} to request.
2018-12-13 00:10:08 DEBUG (SyncWorker_4) [requests_oauthlib.oauth2_session] Requesting url https://api.home-connect.com/api/homeappliances/SIEMENS-TI909701HC-68A40E07D5B7/settings/BSH.Common.Setting.PowerState using method PUT.
2018-12-13 00:10:08 DEBUG (SyncWorker_4) [requests_oauthlib.oauth2_session] Supplying headers {'Content-Type': 'application/vnd.bsh.sdk.v1+json', 'Authorization': 'Bearer xxx'} and data {"data": {"key": "BSH.Common.Setting.PowerState.On"}}
2018-12-13 00:10:08 DEBUG (SyncWorker_4) [requests_oauthlib.oauth2_session] Passing through key word arguments {}.
2018-12-13 00:10:08 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2967527792] Sending {'id': 16, 'type': 'result', 'success': True, 'result': None}

Is it possible to create a own Program?

Hey i wanted to know if it is possible to create a own or customize program.
For examle a double espresso or a stronger coffee.

If yes, how can i create one?

Thanks for the help

Regards
Miguel

Error during Setup - HA 0.90.3

Homeconnect isn't starting anymore since updating to 0.91.3:

Error during setup of component homeconnect
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 154, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/homeconnect/init.py", line 72, in setup
hass.data[DOMAIN]['devices'] = get_devices(hc)
File "/config/custom_components/homeconnect/init.py", line 129, in get_devices
appl = retry(hc.get_appliances, times=20, sleep=0.1)
File "/config/custom_components/homeconnect/init.py", line 120, in retry
return f()
File "/config/deps/lib/python3.7/site-packages/homeconnect/api.py", line 146, in get_appliances
data = self.get(ENDPOINT_APPLIANCES)
File "/config/deps/lib/python3.7/site-packages/homeconnect/api.py", line 109, in get
raise HomeConnectError(res['error'])
homeconnect.api.HomeConnectError: {'key': 'SDK.Error.504.GatewayTimeout', 'description': 'Timeout on Home Connect subsystem. Please try it again.'}

problems with initiating component

Hi, after a few months I got this error:

Error during setup of component homeconnect:

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/setup.py", line 156, in _async_setup_component
component.setup, hass, processed_config) # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/homeconnect/init.py", line 57, in setup
simulate=config.get(DOMAIN, {}).get('simulate', False))
File "/config/deps/lib/python3.7/site-packages/homeconnect/api.py", line 30, in init
self.connect()
File "/config/deps/lib/python3.7/site-packages/homeconnect/api.py", line 69, in connect
token = self.token_load()
File "/config/deps/lib/python3.7/site-packages/homeconnect/api.py", line 50, in token_load
token = json.load(f)
File "/usr/local/lib/python3.7/json/init.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/local/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 1 column 4258 (char 4257)

Nabu Casa

Does this work with my HA accessed thru Nabu Casa?

I tried and saw that the redirect uri is an issue

On/off status not available

Error while trying to turn on device: {'key': 'SDK.Error.InvalidSettingState', 'description': 'BSH.Common.Setting.PowerState currently not available or writable'}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.