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

added light brightness support #100

Merged
merged 4 commits into from
Aug 11, 2020
Merged

added light brightness support #100

merged 4 commits into from
Aug 11, 2020

Conversation

Sjack-Sch
Copy link
Contributor

Addition to #57.
Home Assistant brightness (0-255) will be converted to Home Connect brightness (10-100) and vice versa.

Home Assistant brightness (0-255) is converted to Home Connect brightness (10-100)
@GrumpyMeow
Copy link

Hi David,
could you maybe merge this Pull Request?

from homeconnect.api import HomeConnectError

from homeassistant.components.light import LightEntity
from homeassistant.components.light import (ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, LightEntity)
Copy link
Owner

Choose a reason for hiding this comment

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

Can you please apply isort and then format with black? (This is required for HA Core)

Copy link
Contributor Author

@Sjack-Sch Sjack-Sch Aug 10, 2020

Choose a reason for hiding this comment

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

Done

"""Switch the light on / change brightness."""
if ATTR_BRIGHTNESS in kwargs:
_LOGGER.debug("Tried to change brightness for: %s", self.name)
""" 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.

Can you please modify this doc string to make pydocstyle happy? (This is required for HA core)

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.

brightness = self.device.appliance.status.get(COOKING_LIGHTINGBRIGHTNESS, {})
if not brightness:
Copy link
Owner

Choose a reason for hiding this comment

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

I think this should be if brightness is None because 0 is a valid value and shouldn't lead to the state being shown as "unavailable".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Home connect returns a value from 10 up to and including 100 with steps of 1.
0 is never returned. Better to change to if brightness is None for consistency reasons?

Copy link
Owner

Choose a reason for hiding this comment

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

Fair enough, but yes, I would suggest to do it for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated and committed.

@DavidMStraub
Copy link
Owner

Looks great! Just a couple of minor comments above.

@DavidMStraub
Copy link
Owner

could you maybe merge this Pull Request?

Yeah sorry I somehow missed it.

@GrumpyMeow
Copy link

GrumpyMeow commented Aug 9, 2020

I implemented AmbientLight control:
https://github.com/Sjack-Sch/homeassistant-homeconnect/pull/1

applied isort and formated wit black
Modified doc string
@Sjack-Sch
Copy link
Contributor Author

I implemented AmbientLight control:
Sjack-Sch#1

Thanks, shall we wait merging ambient until brightness is merged?
In the mean time I can test your version on a hood without ambient support.

Change 'if not brightness' into 'if brightness is None'
@DavidMStraub
Copy link
Owner

Done?

@Sjack-Sch
Copy link
Contributor Author

Done?

Yep

@DavidMStraub DavidMStraub merged commit 09644ec into DavidMStraub:master Aug 11, 2020
@Sjack-Sch Sjack-Sch deleted the homeassistant branch August 11, 2020 19:05
@anthonyangel
Copy link

I implemented AmbientLight control:
Sjack-Sch#1

GrumpyMeow, could you please create a pull request from DavidMStraub/homeassistant-homeconnect to add your AmbientLight control?

I loaded up the code in that PR to test, the ambient light (including on/off, colour & brightness) works as expected for a hood, but not for a dishwasher, I was getting the error: Error while trying to turn on light: {'key': 'SDK.Error.UnsupportedSetting', 'description': 'Setting is not supported'} (I can't think of when I'd use the dishwasher light, but as it was there I figured that I'd give it a try anyway.

There was another issue that the startup time of the home_connect_beta component was about 6 minutes, which is long

@DavidMStraub
Copy link
Owner

Do you have an idea what it was doing in the 6 minutes?

@anthonyangel
Copy link

I have 'Waiting on integrations to complete setup: home_connect_beta' entries in the logs, but not much else. I'm increasing the logging of 'homeassistant.bootstrap' to debug and will try again

@Sjack-Sch Sjack-Sch restored the homeassistant branch August 12, 2020 16:43
@Sjack-Sch
Copy link
Contributor Author

Sjack-Sch commented Aug 12, 2020

I implemented AmbientLight control:
https://github.com/Sjack-Sch/homeassistant-homeconnect/pull/1

@GrumpyMeow,
I added the ambient with #105.
Can you please help testing.

@Sjack-Sch
Copy link
Contributor Author

Sjack-Sch commented Aug 12, 2020

I implemented AmbientLight control:
Sjack-Sch#1

GrumpyMeow, could you please create a pull request from DavidMStraub/homeassistant-homeconnect to add your AmbientLight control?

I loaded up the code in that PR to test, the ambient light (including on/off, colour & brightness) works as expected for a hood, but not for a dishwasher, I was getting the error: Error while trying to turn on light: {'key': 'SDK.Error.UnsupportedSetting', 'description': 'Setting is not supported'} (I can't think of when I'd use the dishwasher light, but as it was there I figured that I'd give it a try anyway.

There was another issue that the startup time of the home_connect_beta component was about 6 minutes, which is long

Hi @anthonyangel, Could you test #105,
I added an additonal check: if the device has the Ambient feature before creating the Ambient light entity.

@GrumpyMeow
Copy link

I’m on holiday for 2 weeks and this can’t help at this time with these changes. Sorry.

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.

None yet

4 participants