Skip to content

Commit a91d2c8

Browse files
Fix binary battery low event
1 parent 04bd824 commit a91d2c8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

custom_components/battery_notes/coordinator.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,11 @@ def battery_low_binary_state(self):
202202
def battery_low_binary_state(self, value):
203203
"""Set the current battery low status from a binary sensor and fire events if valid."""
204204
self._battery_low_binary_state = value
205-
if self._previous_battery_low_binary_state is not None:
205+
if (self._previous_battery_low_binary_state is not None
206+
and value not in [
207+
STATE_UNAVAILABLE,
208+
STATE_UNKNOWN,
209+
]):
206210
self.hass.bus.async_fire(
207211
EVENT_BATTERY_THRESHOLD,
208212
{
@@ -229,6 +233,10 @@ def battery_low_binary_state(self, value):
229233
if (
230234
self._previous_battery_low_binary_state
231235
and not self._battery_low_binary_state
236+
and value not in [
237+
STATE_UNAVAILABLE,
238+
STATE_UNKNOWN,
239+
]
232240
):
233241
self.hass.bus.async_fire(
234242
EVENT_BATTERY_INCREASED,

0 commit comments

Comments
 (0)