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

Already on GitHub? Sign in to your account

Protect for None attributes after HA core change #846

Merged

Conversation

kylebjordahl
Copy link
Contributor

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'

Copy link
Owner

@basnijholt basnijholt left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks!

@basnijholt basnijholt merged commit dce2a35 into basnijholt:main Nov 20, 2023
14 checks passed
@basnijholt
Copy link
Owner

@all-contributors please add @kylebjordahl for code

Copy link
Contributor

@basnijholt

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

@nathang21
Copy link

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

@basnijholt
Copy link
Owner

I just released 1.20.0. Thanks for reminding me.

@basnijholt
Copy link
Owner

@all-contributors add @kylebjordahl for bug and code

Copy link
Contributor

@basnijholt

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants