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(
290
290
)
291
291
292
292
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 )
295
298
):
296
299
self .hass .bus .fire (
297
300
EVENT_BATTERY_INCREASED ,
@@ -315,8 +318,8 @@ async def async_state_changed_listener(
315
318
316
319
self ._previous_battery_level = float (wrapped_battery_state .state )
317
320
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
320
323
321
324
async def async_added_to_hass (self ) -> None :
322
325
"""Handle added to Hass."""
You can’t perform that action at this time.
0 commit comments