8000 0.73.0 - light.tplink - division by zero · Issue #15339 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

0.73.0 - light.tplink - division by zero #15339

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ctalkington opened this issue Jul 7, 2018 · 10 comments
Closed

0.73.0 - light.tplink - division by zero #15339

ctalkington opened this issue Jul 7, 2018 · 10 comments
Assignees

Comments

@ctalkington
Copy link
Contributor

Home Assistant release with the issue:

0.73.0

Last working Home Assistant release (if known):
0.72.1

Operating environment (Hass.io/Docker/Windows/etc.):

Docker / RPI3B

Component/platform:

light.tplink

Description of problem:
LB100 causes division by zero error with kelvin temperature conversion. seems #15020 could be the culprit

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

light:
  - platform: tplink
    host: 192.168.1.111

Traceback (if applicable):

homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 214, in async_update_ha_state
    attr = self.state_attributes or {}
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/__init__.py", line 504, in state_attributes
    value = getattr(self, prop)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/light/tplink.py", line 110, in min_mireds
    return kelvin_to_mired(self.smartbulb.valid_temperature_range[1])
  File "/usr/lib/python3.6/site-packages/homeassistant/util/color.py", line 474, in color_temperature_kelvin_to_mired
    return math.floor(1000000 / kelvin_temperature)
ZeroDivisionError: division by zero

Additional information:

@rytilahti
Copy link
Member

Hmm, LB100 does not support temperature changing, so the backend library reports 0 as min & max kelvin. The fix would be to check for that and return whatever is the default return for those methods.

@amelchio
Copy link
Contributor
amelchio commented Jul 8, 2018

Probably return None for min_mireds with that bulb?

@clickityclickclickclick
Copy link
clickityclickclickclick commented Jul 14, 2018

This was the fix for me. Edit color.py

From:

def color_temperature_kelvin_to_mired(kelvin_temperature):
    """Convert degrees kelvin to mired shift."""
    return math.floor(1000000 / kelvin_temperature)

To:

def color_temperature_kelvin_to_mired(kelvin_temperature):
    """Convert degrees kelvin to mired shift."""
    if kelvin_temperature != None and kelvin_temperature != 0:
      return math.floor(1000000 / kelvin_temperature)

@ntompson
Copy link

Same problem here - LB110 doesn't have colour control, so now they are broken in the GUI. Still seem to work in automations, but it would be good to see this fixed. Is there an ETA?

I am using hassio, so hard to fix the source.

@rytilahti
Copy link
Member

I'm wondering if the get_features() should already be called in setup_platform()? That way min_mireds and max_mireds should never be accessed and this issue would be solved without other changes. Anyone mind testing if that'd do the trick?

@Segfault198
Copy link

Its interesting to see this issue reappear. It used to occur way back in the early days of the tplink platform. Strange to see it resurface now. Was working fine for me until 0.73.1. For now I'll go back to altering color.py as I did in the old (lol maybe a year ago) days.

@tchellomello
Copy link
Contributor

I had the same issue and the implemented something similar as comment 6 #15339 (comment)

@amelchio
Copy link
Contributor

If you are going for a local change, please test #15484 since that is what we expect will fix this issue.

@ctalkington
Copy link
Contributor Author

seems resolved in 0.74.0

@ghost ghost removed the in progress label Jul 21, 2018
@amelchio
Copy link
Contributor

It seems that @rytilahti managed to fix it with #15571 👍

@home-assistant home-assistant locked and limited conversation to collaborators Oct 26, 2018
Sign up for free to subscrib 5511 e to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants
0