Skip to content

Commit

Permalink
Add battery low threshold to battery increased and battery threshold …
Browse files Browse the repository at this point in the history
…events (#3165)
  • Loading branch information
andrew-codechimp authored Feb 27, 2025
1 parent 11dcbc7 commit b6fb324
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions custom_components/battery_notes/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ATTR_BATTERY_LAST_REPLACED,
ATTR_BATTERY_LEVEL,
ATTR_BATTERY_LOW,
ATTR_BATTERY_LOW_THRESHOLD,
ATTR_BATTERY_QUANTITY,
ATTR_BATTERY_THRESHOLD_REMINDER,
ATTR_BATTERY_TYPE,
Expand Down Expand Up @@ -143,6 +144,7 @@ def battery_low_template_state(self, value):
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
ATTR_DEVICE_NAME: self.device_name,
ATTR_BATTERY_LOW: self.battery_low,
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
ATTR_BATTERY_TYPE: self.battery_type,
ATTR_BATTERY_QUANTITY: self.battery_quantity,
Expand All @@ -168,6 +170,7 @@ def battery_low_template_state(self, value):
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
ATTR_DEVICE_NAME: self.device_name,
ATTR_BATTERY_LOW: self.battery_low,
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
ATTR_BATTERY_TYPE: self.battery_type,
ATTR_BATTERY_QUANTITY: self.battery_quantity,
Expand Down Expand Up @@ -198,6 +201,7 @@ def battery_low_binary_state(self, value):
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
ATTR_DEVICE_NAME: self.device_name,
ATTR_BATTERY_LOW: self.battery_low,
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
ATTR_BATTERY_TYPE: self.battery_type,
ATTR_BATTERY_QUANTITY: self.battery_quantity,
Expand All @@ -224,6 +228,7 @@ def battery_low_binary_state(self, value):
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
ATTR_DEVICE_NAME: self.device_name,
ATTR_BATTERY_LOW: self.battery_low,
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
ATTR_BATTERY_TYPE: self.battery_type,
ATTR_BATTERY_QUANTITY: self.battery_quantity,
Expand Down Expand Up @@ -273,6 +278,7 @@ def current_battery_level(self, value):
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
ATTR_DEVICE_NAME: self.device_name,
ATTR_BATTERY_LOW: self.battery_low,
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
ATTR_BATTERY_TYPE: self.battery_type,
ATTR_BATTERY_QUANTITY: self.battery_quantity,
Expand Down Expand Up @@ -307,6 +313,7 @@ def current_battery_level(self, value):
ATTR_SOURCE_ENTITY_ID: self.source_entity_id or "",
ATTR_DEVICE_NAME: self.device_name,
ATTR_BATTERY_LOW: self.battery_low,
ATTR_BATTERY_LOW_THRESHOLD: self.battery_low_threshold,
ATTR_BATTERY_TYPE_AND_QUANTITY: self.battery_type_and_quantity,
ATTR_BATTERY_TYPE: self.battery_type,
ATTR_BATTERY_QUANTITY: self.battery_quantity,
Expand Down
2 changes: 2 additions & 0 deletions custom_components/battery_notes/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ATTR_BATTERY_LAST_REPORTED_LEVEL,
ATTR_BATTERY_LEVEL,
ATTR_BATTERY_LOW,
ATTR_BATTERY_LOW_THRESHOLD,
ATTR_BATTERY_QUANTITY,
ATTR_BATTERY_THRESHOLD_REMINDER,
ATTR_BATTERY_TYPE,
Expand Down Expand Up @@ -220,6 +221,7 @@ async def handle_battery_low(call: ServiceCall) -> ServiceResponse:
ATTR_SOURCE_ENTITY_ID: device.coordinator.source_entity_id
or "",
ATTR_BATTERY_LOW: device.coordinator.battery_low,
ATTR_BATTERY_LOW_THRESHOLD: device.coordinator.battery_low_threshold,
ATTR_BATTERY_TYPE_AND_QUANTITY: device.coordinator.battery_type_and_quantity,
ATTR_BATTERY_TYPE: device.coordinator.battery_type,
ATTR_BATTERY_QUANTITY: device.coordinator.battery_quantity,
Expand Down

0 comments on commit b6fb324

Please sign in to comment.