basnijholt / adaptive-lighting

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

Protect for None attributes after HA core change #846

Closed kylebjordahl closed 7 months ago

kylebjordahl commented 7 months ago

Addresses change to HA core flagged in #832 which results in the following error:

Traceback (most recent call last):
  File "/config/custom_components/adaptive_lighting/switch.py", line 1129, in _async_update_at_interval_action
    await self._update_attrs_and_maybe_adapt_lights(
  File "/config/custom_components/adaptive_lighting/switch.py", line 1442, in _update_attrs_and_maybe_adapt_lights
    and await self.manager.significant_change(
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 2461, in significant_change
    changed = _attributes_have_changed(
              ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 726, in _attributes_have_changed
    if abs(current_brightness - last_brightness) > BRIGHTNESS_CHANGE:
           ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
basnijholt commented 7 months ago

@all-contributors please add @kylebjordahl for code

allcontributors[bot] commented 7 months ago

@basnijholt

I've put up a pull request to add @kylebjordahl! :tada:

nathang21 commented 7 months ago

Is it possible to get a new release with this included?

basnijholt commented 7 months ago

I just released 1.20.0. Thanks for reminding me.

basnijholt commented 7 months ago

@all-contributors add @kylebjordahl for bug and code

allcontributors[bot] commented 7 months ago

@basnijholt

I've put up a pull request to add @kylebjordahl! :tada: