Skip to content

Commit 111ae57

Browse files
Check for unknown/unavailable (#3176)
1 parent ef1b615 commit 111ae57

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

custom_components/battery_notes/coordinator.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ def battery_low_template_state(self, value):
136136
if (
137137
self._previous_battery_low_template_state is not None
138138
and self.battery_low_template
139+
and value not in [
140+
STATE_UNAVAILABLE,
141+
STATE_UNKNOWN,
142+
]
139143
):
140144
self.hass.bus.async_fire(
141145
EVENT_BATTERY_THRESHOLD,
@@ -162,6 +166,10 @@ def battery_low_template_state(self, value):
162166
if (
163167
self._previous_battery_low_template_state
164168
and not self._battery_low_template_state
169+
and value not in [
170+
STATE_UNAVAILABLE,
171+
STATE_UNKNOWN,
172+
]
165173
):
166174
self.hass.bus.async_fire(
167175
EVENT_BATTERY_INCREASED,
@@ -182,7 +190,13 @@ def battery_low_template_state(self, value):
182190

183191
_LOGGER.debug("battery_increased event fired via template")
184192

185-
self._previous_battery_low_template_state = value
193+
if value not in [
194+
STATE_UNAVAILABLE,
195+
STATE_UNKNOWN,
196+
]:
197+
self._previous_battery_low_template_state = value
198+
else:
199+
self._previous_battery_low_template_state = None
186200

187201
@property
188202
def battery_low_binary_state(self):

0 commit comments

Comments
 (0)