Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Added Ambient light #105

Merged
merged 4 commits into from
Oct 17, 2020
Merged

Added Ambient light #105

merged 4 commits into from
Oct 17, 2020

Conversation

Sjack-Sch
Copy link
Contributor

@Sjack-Sch Sjack-Sch commented Aug 12, 2020

With major support of @GrumpyMeow

With major support of Meow
custom_components/home_connect_beta/api.py Outdated Show resolved Hide resolved
_LOGGER.debug("Tried to change brightness for: %s", self.name)
"""Convert Home Assistant brightness (0-255) to Home Connect brightness (10-100)"""
""" Convert Home Assistant brightness (0-255) to Home Connect brightness (10-100)"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This space should be removed; also there is no full stop. Please run pydocstyle and make sure it is happy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, forgot to make pydocstyle happy :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi David,

Sorry to react so late, I totally forgot this PR.
Can we finish this PR?
After it has been merged I will merge it in the official HA.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

hmm strange, I also forgot about it. So is it ready to merge and all issues have been resolved?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, al request have been resolved.
I am not sure if the 5 minute delays mentioned by @anthonyangel is still there. I will try this week to execute some tests to find out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Anthonie, thanks for sharing.
Would it be possible for you to check if the core version of home connect has a different delay?

Copy link
Contributor Author

@Sjack-Sch Sjack-Sch Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK great, let me know.

Also a heads-up: we should wait with the core PR until DavidMStraub/homeconnect#3 is finally closed (I just pushed a possible fix but have to wait for others testing it.).

I just checked the core version of home connect and I noticed the same delay before entities become available after a restart as seen in the beta version.

I think we can this PR.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge, you mean? 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep merge, auto correct is not always helping 🙃

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I just got a mini-PR merged into HA core fixing the SSE reconnection issue by simply bumping the homeconnect dependency. I wanted to separate this from the feature PR as it is an important fix. @Sjack-Sch if you want feel free to open a PR at core with the additional changes in this repo.

@anthonyangel
Copy link

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
Copy link
Owner

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
Copy link
Contributor Author

Sjack-Sch commented Aug 14, 2020

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?

Brightness set to none for Ambient gave an error when converting from home assistant brightness to home connect brightness
@anthonyangel
Copy link

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
Copy link
Contributor Author

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?

added the word "ambient" to the error notification for ambient light on
@anthonyangel
Copy link

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
Copy link
Contributor Author

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?

@Sjack-Sch Sjack-Sch requested a review from DavidMStraub August 21, 2020 18:46
@DavidMStraub DavidMStraub merged commit fbfde3d into DavidMStraub:master Oct 17, 2020
@GrumpyMeow
Copy link

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
Copy link

allmoney commented Dec 1, 2020

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

@DavidMStraub
Copy link
Owner

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
Copy link
Contributor Author

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

@allmoney
Copy link

allmoney commented Dec 2, 2020

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

Thank you so much !!! 👍

@Sjack-Sch
Copy link
Contributor Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants