File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
custom_components/battery_notes Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -290,8 +290,11 @@ async def async_state_changed_listener(
290290 )
291291
292292 if wrapped_battery_state .state not in [STATE_UNAVAILABLE , STATE_UNKNOWN ]:
293- if float (wrapped_battery_state .state ) >= (
294- self ._previous_battery_level + increase_threshold
293+ if (
294+ wrapped_battery_state .state
295+ and self ._previous_battery_level
296+ and float (wrapped_battery_state .state )
297+ >= (self ._previous_battery_level + increase_threshold )
295298 ):
296299 self .hass .bus .fire (
297300 EVENT_BATTERY_INCREASED ,
@@ -315,8 +318,8 @@ async def async_state_changed_listener(
315318
316319 self ._previous_battery_level = float (wrapped_battery_state .state )
317320
318- self ._previous_state_last_changed = wrapped_battery_state .last_changed
319- self ._previous_battery_low = battery_low
321+ self ._previous_state_last_changed = wrapped_battery_state .last_changed
322+ self ._previous_battery_low = battery_low
320323
321324 async def async_added_to_hass (self ) -> None :
322325 """Handle added to Hass."""
You can’t perform that action at this time.
0 commit comments