Skip to content

Commit b6fb324

Browse files
Add battery low threshold to battery increased and battery threshold events (#3165)
1 parent 11dcbc7 commit b6fb324

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

custom_components/battery_notes/coordinator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
ATTR_BATTERY_LAST_REPLACED,
2323
ATTR_BATTERY_LEVEL,
2424
ATTR_BATTERY_LOW,
25+
ATTR_BATTERY_LOW_THRESHOLD,
2526
ATTR_BATTERY_QUANTITY,
2627
ATTR_BATTERY_THRESHOLD_REMINDER,
2728
ATTR_BATTERY_TYPE,
@@ -143,6 +144,7 @@ def battery_low_template_state(self, value):
143144
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
144145
ATTR_DEVICE_NAME: self.device_name,
145146
ATTR_BATTERY_LOW: self.battery_low,
147+
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
146148
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
147149
ATTR_BATTERY_TYPE: self.battery_type,
148150
ATTR_BATTERY_QUANTITY: self.battery_quantity,
@@ -168,6 +170,7 @@ def battery_low_template_state(self, value):
168170
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
169171
ATTR_DEVICE_NAME: self.device_name,
170172
ATTR_BATTERY_LOW: self.battery_low,
173+
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
171174
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
172175
ATTR_BATTERY_TYPE: self.battery_type,
173176
ATTR_BATTERY_QUANTITY: self.battery_quantity,
@@ -198,6 +201,7 @@ def battery_low_binary_state(self, value):
198201
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
199202
ATTR_DEVICE_NAME: self.device_name,
200203
ATTR_BATTERY_LOW: self.battery_low,
204+
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
201205
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
202206
ATTR_BATTERY_TYPE: self.battery_type,
203207
ATTR_BATTERY_QUANTITY: self.battery_quantity,
@@ -224,6 +228,7 @@ def battery_low_binary_state(self, value):
224228
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
225229
ATTR_DEVICE_NAME: self.device_name,
226230
ATTR_BATTERY_LOW: self.battery_low,
231+
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
227232
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
228233
ATTR_BATTERY_TYPE: self.battery_type,
229234
ATTR_BATTERY_QUANTITY: self.battery_quantity,
@@ -273,6 +278,7 @@ def current_battery_level(self, value):
273278
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
274279
ATTR_DEVICE_NAME: self.device_name,
275280
ATTR_BATTERY_LOW: self.battery_low,
281+
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
276282
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
277283
ATTR_BATTERY_TYPE: self.battery_type,
278284
ATTR_BATTERY_QUANTITY: self.battery_quantity,
@@ -307,6 +313,7 @@ def current_battery_level(self, value):
307313
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
308314
ATTR_DEVICE_NAME: self.device_name,
309315
ATTR_BATTERY_LOW: self.battery_low,
316+
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
310317
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
311318
ATTR_BATTERY_TYPE: self.battery_type,
312319
ATTR_BATTERY_QUANTITY: self.battery_quantity,

custom_components/battery_notes/services.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
ATTR_BATTERY_LAST_REPORTED_LEVEL,
2121
ATTR_BATTERY_LEVEL,
2222
ATTR_BATTERY_LOW,
23+
ATTR_BATTERY_LOW_THRESHOLD,
2324
ATTR_BATTERY_QUANTITY,
2425
ATTR_BATTERY_THRESHOLD_REMINDER,
2526
ATTR_BATTERY_TYPE,
@@ -220,6 +221,7 @@ async def handle_battery_low(call: ServiceCall) -> ServiceResponse:
220221
ATTR_SOURCE_ENTITY_ID: device.coordinator.source_entity_id
221222
or "",
222223
ATTR_BATTERY_LOW: device.coordinator.battery_low,
224+
ATTR_BATTERY_LOW_THRESHOLD: device.coordinator.battery_low_threshold,
223225
ATTR_BATTERY_TYPE_AND_QUANTITY: device.coordinator.battery_type_and_quantity,
224226
ATTR_BATTERY_TYPE: device.coordinator.battery_type,
225227
ATTR_BATTERY_QUANTITY: device.coordinator.battery_quantity,

0 commit comments

Comments
 (0)