Skip to content
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

Closed
wants to merge 8 commits into from
Closed

Conversation

vlebourl
Copy link
Contributor

@vlebourl vlebourl commented May 29, 2020

Breaking change

Proposed change

Add support for dimmable lights in Tahoma.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

@vlebourl
Copy link
Contributor Author

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

@tetienne
Copy link
Contributor

tetienne commented Jun 2, 2020

@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

@stale
Copy link

stale bot commented Jul 3, 2020

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.
Thank you for your contributions.

@stale stale bot added the stale label Jul 3, 2020
@MartinHjelmare MartinHjelmare changed the title Tahoma dimable light Tahoma dimmable light Jul 3, 2020
@stale stale bot removed the stale label Jul 3, 2020
@stale
Copy link

stale bot commented Aug 2, 2020

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.
Thank you for your contributions.

@stale stale bot added the stale label Aug 2, 2020
@stale stale bot closed this Aug 9, 2020
Dev automation moved this from Needs review to Cancelled Aug 9, 2020
@MartinHjelmare MartinHjelmare reopened this Aug 9, 2020
Dev automation moved this from Cancelled to Incoming Aug 9, 2020
@stale stale bot removed the stale label Aug 9, 2020
@MartinHjelmare MartinHjelmare moved this from Incoming to Needs review in Dev Aug 16, 2020
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))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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)

@vlebourl
Copy link
Contributor Author

vlebourl commented Sep 4, 2020

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

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

Choose a reason for hiding this comment

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

Suggested change
_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...")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_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)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_LOGGER.debug("[THM] Called to check is on %s", self._state)
_LOGGER.debug("Called to check is on %s", self._state)

Comment on lines +26 to +31
devices = []

for device in hass.data[TAHOMA_DOMAIN]["devices"]["light"]:
devices.append(TahomaLight(device, controller))

async_add_entities(devices, True)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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

@iMicknl
Copy link
Contributor

iMicknl commented Sep 4, 2020

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?

@vlebourl I think it is best to close this one, I didn't know this one was open.. :(
This will also make our new core PR a bit smaller since it doesn't need to include the light integration.

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")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
_LOGGER.debug("[THM] Called to turn off")
_LOGGER.debug("Called to turn off")

__name__ will already be in the logger

Copy link
Member

@bdraco bdraco left a 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

Dev automation moved this from Needs review to Review in progress Sep 4, 2020
@stale
Copy link

stale bot commented Oct 4, 2020

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.
Thank you for your contributions.

@stale stale bot added the stale label Oct 4, 2020
@vlebourl
Copy link
Contributor Author

vlebourl commented Oct 6, 2020

Let's close this one as we are submitting a bigger update to this component: #41267

@vlebourl vlebourl closed this Oct 6, 2020
Dev automation moved this from Review in progress to Cancelled Oct 6, 2020
@vlebourl vlebourl deleted the TahomaDimableLight branch May 11, 2021 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dev
  
Cancelled
Development

Successfully merging this pull request may close these issues.

None yet

6 participants