basnijholt / adaptive-lighting

Adaptive Lighting custom component for Home Assistant
https://basnijholt.github.io/adaptive-lighting/
Apache License 2.0
1.82k stars 134 forks source link

Error while processing state changed for switch.adaptive_lighting_alle #64

Closed Chreece closed 3 years ago

Chreece commented 3 years ago

Hello there! What a wonderful way to help others! Adaptive lightning saved literally my sleep... I'm happy using it. Sadly it's still not perfect but we are getting there...

I have an issue coming very often. I'm getting an error: Error while processing state changed for switch.adaptive_lighting_alle And that's blocking turn on or off my lights when it occurs.

Error code:

Logger: homeassistant.helpers.event
Source: helpers/condition.py:232
First occurred: 2:43:19 μ.μ. (2 occurrences)
Last logged: 2:43:19 μ.μ.

Error while processing state changed for switch.adaptive_lighting_alle
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/event.py", line 257, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/homeassistant/triggers/numeric_state.py", line 130, in state_automation_listener
    matching = check_numeric_state(entity_id, from_s, to_s)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/homeassistant/triggers/numeric_state.py", line 99, in check_numeric_state
    return condition.async_numeric_state(
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/condition.py", line 232, in async_numeric_state
    fvalue = float(value)
TypeError: float() argument must be a string or a number, not 'NoneType'

I tried turn on or off some options and also remove some lights (even all...) but I still get this error.

Happy to give more info if wanted...

Keep up guys, thank you spending your free time on it!

Chreece commented 3 years ago

And that's the DEBUG Log:

2020-12-27 14:43:17 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] alle: '_update_attrs_and_maybe_adapt_lights' called with context.id='adapt_lgt_ac78_interval_5'
2020-12-27 14:43:17 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting: alle: '_adapt_lights(['light.bett_beleuchtung', 'light.wohnzimmer_led'], None, force=False, context.id=adapt_lgt_ac78_interval_5)' called
2020-12-27 14:43:19 ERROR (MainThread) [homeassistant.helpers.event] Error while processing state changed for switch.adaptive_lighting_alle
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/event.py", line 257, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/homeassistant/triggers/numeric_state.py", line 130, in state_automation_listener
    matching = check_numeric_state(entity_id, from_s, to_s)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/homeassistant/triggers/numeric_state.py", line 99, in check_numeric_state
    return condition.async_numeric_state(
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/condition.py", line 232, in async_numeric_state
    fvalue = float(value)
TypeError: float() argument must be a string or a number, not 'NoneType'
2020-12-27 14:43:19 ERROR (MainThread) [homeassistant.helpers.event] Error while processing state changed for switch.adaptive_lighting_alle
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/event.py", line 257, in _async_state_change_dispatcher
    hass.async_run_hass_job(job, event)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/core.py", line 433, in async_run_hass_job
    hassjob.target(*args)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/homeassistant/triggers/numeric_state.py", line 130, in state_automation_listener
    matching = check_numeric_state(entity_id, from_s, to_s)
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/components/homeassistant/triggers/numeric_state.py", line 99, in check_numeric_state
    return condition.async_numeric_state(
  File "/srv/homeassistant/lib/python3.8/site-packages/homeassistant/helpers/condition.py", line 232, in async_numeric_state
    fvalue = float(value)
TypeError: float() argument must be a string or a number, not 'NoneType'
2020-12-27 14:43:21 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.bett_beleuchtung' 'state_changed' event: '{'min_mireds': 155, 'max_mireds': 495, 'effect_list': ['colorloop'], 'brightness': 149, 'color_temp': 495, 'is_deconz_group': False, 'friendly_name': 'Bett Beleuchtung', 'supported_features': 63}' with context.id='b371e9af6d4b5810a3feeee5fc3e385b'
2020-12-27 14:43:22 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected a 'light.wohnzimmer_led' 'state_changed' event: '{'min_mireds': 155, 'max_mireds': 495, 'effect_list': ['colorloop'], 'brightness': 4, 'color_temp': 495, 'is_deconz_group': False, 'friendly_name': 'Wohnzimmer LED', 'supported_features': 63}' with context.id='274099c44e8ba0297621102a0f7cc39a'
2020-12-27 14:43:22 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_off('['light.bett_beleuchtung']', transition=None)' event with context.id='8dbe0c6b52214ec3f06a1c95471028b8'
2020-12-27 14:43:22 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Detected an 'light.turn_off('['light.wohnzimmer_led']', transition=None)' event with context.id='8dbe0c6b52214ec3f06a1c95471028b8'
basnijholt commented 3 years ago

Do you have an automation that causes these errors? Or do you just have a switch set up?

Chreece commented 3 years ago

Hey basnijhot,

In the meanwhile I seperated my lights that are the same type, in different Adaptive Lighting entities. This error comes with the two LED Strips (Gledopto GL-C-008 controller) that showed also in the errors. The two other entities don't give any error. The values from this switch I use to automate another light (aquarium) so to simulate the sun light from the sunlight position attribute (sunlight position*255 = brightness from the aquarium light). It can be that momentary this switch doesn't give any values (NoneType) and then I got this error.

Don't worry about my issue, take a rest for the New Years Eve :)

RubenKelevra commented 3 years ago

Hey @Chreece,

the last update on this was done a while ago. I wanted to check if you still having trouble using adaptive lighting - since there were some major changes in how HA handles color temperatures and RGB values quite recently.

What does not work with the most recent version of HA and do you still use your workaround?

Chreece commented 3 years ago

Yes, indeed. I haven't recently any problems. I close this issue for the time :) Thank you very much for your message