DavidMStraub / homeassistant-homeconnect

Custom component for Home Assistant to connect appliances supporting the Home Connect standard
MIT License
116 stars 29 forks source link

Added Ambient light #105

Closed Sjack-Sch closed 3 years ago

Sjack-Sch commented 3 years ago

With major support of @GrumpyMeow

anthonyangel commented 3 years ago

This takes 5+ minutes to startup, I tested this with appliance in standby / off state, and also turned everything on and checked and it was the same result. Potentially having the appliance which the programs can't be fetched for in the logs would help troubleshoot this further.

DEBUG (SyncWorker_1) [custom_components.home_connect_beta.api] Unable to fetch active programs. Probably offline.
WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: home_connect_beta

After a few minutes more I get:

2020-08-13 22:48:25 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for stage 2 - moving forward
2020-08-13 22:48:25 DEBUG (MainThread) [homeassistant.bootstrap] Waiting for startup to wrap up
2020-08-13 22:48:25 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: home_connect_beta

And then eventually:

2020-08-13 22:48:26 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 315.39s

The functionality for a hood works as intended (including colour & brightness), but when I try to set the ambient light on a dishwasher I get the following error. I'd assume that this ambient light only has on/off states and doesn't support brightness

2020-08-13 22:49:52 ERROR (MainThread) [custom_components.home_connect_beta.light] Error while trying selecting customcolor: {'key': 'SDK.Error.UnsupportedSetting', 'description': 'Setting is not supported'}
2020-08-13 22:49:52 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140337398648592] unsupported operand type(s) for /: 'NoneType' and 'int'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 125, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1308, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1343, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
    await self.hass.helpers.service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 454, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 583, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 485, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 249, in async_handle_light_on_service
    await light.async_turn_on(**params)
  File "/config/custom_components/home_connect_beta/light.py", line 103, in async_turn_on
    brightness = 10 + ceil(self._brightness / 255 * 90)
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
DavidMStraub commented 3 years ago

This looks like it's due to the change requested above. During the (async) setup process, a sync call to the API is started which fails.

Sjack-Sch commented 3 years ago

This looks like it's due to the change requested above. During the (async) setup process, a sync call to the API is started which fails.

Hi @anthonyangel, I removed the sync call. And added a check on Ambient brightness not set to None before converting from home assistant brightness to home connect brightness.

Could you please test the latest commits?

anthonyangel commented 3 years ago

I checked the latest version of the code, I still get the slow startup for this component.

I also checked the dishwasher ambient light and I now get a different error:

2020-08-21 10:58:40 ERROR (MainThread) [custom_components.home_connect_beta.light] Error while trying to turn on light: {'key': 'SDK.Error.UnsupportedSetting', 'description': 'Setting is not supported'}
Sjack-Sch commented 3 years ago

I checked the latest version of the code, I still get the slow startup for this component.

I also checked the dishwasher ambient light and I now get a different error:

2020-08-21 10:58:40 ERROR (MainThread) [custom_components.home_connect_beta.light] Error while trying to turn on light: {'key': 'SDK.Error.UnsupportedSetting', 'description': 'Setting is not supported'}

Hi @anthonyangel,

It seems that your dishwasher does support ambient lighting. Can you try /homeappliances/{haid}/settings in https://apiclient.home-connect.com for your dishwasher and share the response?

anthonyangel commented 3 years ago

When it's of off I get

{ "data": { "settings": [ { "key": "BSH.Common.Setting.PowerState", "value": "BSH.Common.EnumType.PowerState.Off", "name": "Power status", "displayvalue": "Off" } ] } }

When the power is on I get the same, but the API reports that the power status is on.

It must be one of those settings which is available in the app, but not the API. From my point of view it's not worth worrying about as it's a pretty useless feature (I only brought it up as it was discovered as an entity so I tested it)

Sjack-Sch commented 3 years ago

When it's of off I get

{ "data": { "settings": [ { "key": "BSH.Common.Setting.PowerState", "value": "BSH.Common.EnumType.PowerState.Off", "name": "Power status", "displayvalue": "Off" } ] } }

When the power is on I get the same, but the API reports that the power status is on.

It must be one of those settings which is available in the app, but not the API. From my point of view it's not worth worrying about as it's a pretty useless feature (I only brought it up as it was discovered as an entity so I tested it)

OK thanks, yep it seams that the ambient setting is not available/supported. Maybe Bosch will add this API in the future. Does your Hood still work as expected?

GrumpyMeow commented 3 years ago

I've just cloned your "DavidMStraub:master' branch and mapped it into my Home Assistant. The Ambient-light works perfectly on my Hood (LC97FVW60S). I did had to do a restart of Home Assistant to have the entities to show up.

allmoney commented 3 years ago

When Functional Light of Hood will be available in HA integration?

DavidMStraub commented 3 years ago

Good question, "somebody" has to do a pull request. It is very low on my prio list because I don't have a hood light. Happy if someone volunteers.

Sjack-Sch commented 3 years ago

I will start a PR that adds functional and ambient lighting to the core soon.

allmoney commented 3 years ago

I will start a PR that adds functional and ambient lighting to the core soon.

Thank you so much !!! 👍

Sjack-Sch commented 3 years ago

A PR to HA core has been started: Home connect functional and ambient light added #44091