-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tahoma dimmable light #36258
Tahoma dimmable light #36258
Conversation
I don't understand the logic, got asked to use f-strings in another PR, so I made the change here as well, but pylint wants the % formatting in logging functions. If someone can explain, I'd be happy to know why this is required. Cheers |
@vlebourl It's about performance. For simple applications with few log, you don't care. But you log a lot, it can have an impact. You can see a discussion here: pylint-dev/pylint#2395 |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
def brightness(self) -> int: | ||
"""Return the brightness of this light between 0..255.""" | ||
_LOGGER.debug("[THM] Called to get brightness %s", self._brightness) | ||
return int(self._brightness * (255 / 100)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return int(self._brightness * (255 / 100)) | |
return round(self._brightness * (255 / 100)) |
self._skip_update = True | ||
|
||
if ATTR_BRIGHTNESS in kwargs: | ||
self._brightness = int(float(kwargs[ATTR_BRIGHTNESS]) / 255 * 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._brightness = int(float(kwargs[ATTR_BRIGHTNESS]) / 255 * 100) | |
self._brightness = round(float(kwargs[ATTR_BRIGHTNESS]) / 255 * 100) |
super().__init__(tahoma_device, controller) | ||
self._skip_update = False | ||
self._effect = None | ||
self._state = STATE_UNKNOWN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._state = STATE_UNKNOWN | |
self._state = None |
entity.py will set this to STATE_UNKNOWN
if its none
state = STATE_UNKNOWN if state is None else str(state)
Hi, I actually forgot about that PR... I think we should close it as we're working on a full rewrite of the component with @iMicknl and @tetienne. Do you agree? |
self._brightness = 0 | ||
if self.tahoma_device.type == "io:DimmableLightIOComponent": | ||
self._type = "io" | ||
self._unique_id = self.tahoma_device.url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't appear to meet the unique id requirements here https://developers.home-assistant.io/docs/entity_registry_index/#unique-id-requirements
We should use something that is stable for the life of the device or remove it.
|
||
async def async_turn_on(self, **kwargs) -> None: | ||
"""Turn the light on.""" | ||
_LOGGER.debug("[THM] Called to turn on (%s, %s)", kwargs, self._brightness) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LOGGER.debug("[THM] Called to turn on (%s, %s)", kwargs, self._brightness) | |
_LOGGER.debug("Called to turn on (%s, %s)", kwargs, self._brightness) |
The name of the module is already logged
self._skip_update = False | ||
return | ||
|
||
_LOGGER.debug("[THM] Updating state...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LOGGER.debug("[THM] Updating state...") | |
_LOGGER.debug("Updating state...") |
@property | ||
def is_on(self) -> bool: | ||
"""Return true if light is on.""" | ||
_LOGGER.debug("[THM] Called to check is on %s", self._state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LOGGER.debug("[THM] Called to check is on %s", self._state) | |
_LOGGER.debug("Called to check is on %s", self._state) |
devices = [] | ||
|
||
for device in hass.data[TAHOMA_DOMAIN]["devices"]["light"]: | ||
devices.append(TahomaLight(device, controller)) | ||
|
||
async_add_entities(devices, True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devices = [] | |
for device in hass.data[TAHOMA_DOMAIN]["devices"]["light"]: | |
devices.append(TahomaLight(device, controller)) | |
async_add_entities(devices, True) | |
entities = [] | |
for device in hass.data[TAHOMA_DOMAIN]["devices"]["light"]: | |
entities.append(TahomaLight(device, controller)) | |
async_add_entities(entities, True) |
These are entities
@vlebourl I think it is best to close this one, I didn't know this one was open.. :( All the comments from @bdraco are probably already fixed in the refactor https://github.com/iMicknl/ha-tahoma. I will double check, to not waste his review. |
|
||
async def async_turn_off(self, **kwargs) -> None: | ||
"""Turn the light off.""" | ||
_LOGGER.debug("[THM] Called to turn off") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_LOGGER.debug("[THM] Called to turn off") | |
_LOGGER.debug("Called to turn off") |
__name__
will already be in the logger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this. Please see comments above
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Let's close this one as we are submitting a bigger update to this component: #41267 |
Breaking change
Proposed change
Add support for dimmable lights in Tahoma.
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale: