Skip to content

Commit 3bd94eb

Browse files
2.3 release (#1627)
* Docs & blueprints * Update docs * Docs
1 parent 4852046 commit 3bd94eb

9 files changed

+25
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
[![License][license-shield]](LICENSE)
77
[![hacs][hacsbadge]][hacs]
88

9-
Integration to add battery notes to a device, with automatic discovery via a growing [battery library](library.md) for devices.
10-
Track the battery type, when the battery was replaced, when a battery is low based on device or global thresholds and also when a device hasn't reported a battery for a while.
9+
Integration to add battery notes to a device or entity, with automatic discovery via a growing [battery library](library.md) for devices.
10+
Track the battery type, when the battery was replaced, when a battery is low based on device or global thresholds and also when a battery hasn't been reported for a while.
1111

1212
A battery+ sensor provides useful attributes for easy use in dashboards, the standard battery can optionally be hidden.
1313

docs/blueprints/battery_notes_battery_not_reported.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ blueprint:
1919
device:
2020
multiple: true
2121
entity:
22-
- integration: battery_notes
22+
- integration: battery_notes
2323
user_actions:
2424
name: User Actions
2525
description: User actions to run on battery not reported.
@@ -49,7 +49,7 @@ action:
4949
}} days {{ ''\n'' -}} Its last reported level was {{ trigger.event.data.battery_last_reported_level
5050
}}% {{ ''\n'' -}} You need {{ trigger.event.data.battery_quantity }}× {{ trigger.event.data.battery_type
5151
}}'
52-
notification_id: 'battery_notes_not_reported {{ trigger.event.data.device_id }}'
52+
notification_id: 'battery_notes_not_reported {{ trigger.event.data.device_id }}-{{ trigger.event.data.source_entity_id }}'
5353
- alias: Run user actions
5454
choose: []
5555
default: !input user_actions

docs/blueprints/battery_notes_battery_replaced.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ action:
2323
- service: battery_notes.set_battery_replaced
2424
data:
2525
device_id: "{{ trigger.event.data.device_id }}"
26+
source_entity_id: "{{ trigger.event.data.source_entity_id }}"
2627
- alias: "Run user on replaced actions"
2728
choose: []
2829
default: !input 'on_replaced_actions'

docs/blueprints/battery_notes_battery_threshold.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ blueprint:
2626
device:
2727
multiple: true
2828
entity:
29-
- integration: battery_notes
29+
- integration: battery_notes
3030
on_low_actions:
3131
name: On Low Actions
3232
description: User actions to run on battery low. Use any event data via trigger.event.data.xxx
@@ -38,7 +38,7 @@ blueprint:
3838
description: User actions to run on battery returning from low. Use any event data via trigger.event.data.xxx
3939
default: []
4040
selector:
41-
action:
41+
action:
4242

4343
variables:
4444
low_notification: !input low_notification
@@ -79,7 +79,7 @@ action:
7979
data:
8080
title: |
8181
{{ trigger.event.data.device_name }} Battery Low
82-
notification_id: "battery_notes_threshold {{ trigger.event.data.device_id }}"
82+
notification_id: "battery_notes_threshold {{ trigger.event.data.device_id }}-{{ trigger.event.data.source_entity_id }}"
8383
message: >
8484
The device has a battery level of {{
8585
trigger.event.data.battery_level }}% {{ '\n' -}} You need {{
@@ -99,7 +99,7 @@ action:
9999
then:
100100
- service: persistent_notification.dismiss
101101
data:
102-
notification_id: "battery_notes_threshold {{ trigger.event.data.device_id }}"
102+
notification_id: "battery_notes_threshold {{ trigger.event.data.device_id }}-{{ trigger.event.data.source_entity_id }}"
103103
- alias: "Run user on high actions"
104104
choose: []
105105
default: !input 'on_high_actions'

docs/community.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ action:
5555
data:
5656
title: |
5757
{{ trigger.event.data.device_name }} Battery Low
58-
notification_id: "{{ trigger.event.data.device_id }}"
58+
notification_id: "{{ trigger.event.data.device_id }}-{{ trigger.event.data.source_entity_id }}"
5959
message: >
6060
The device has a battery level of {{
6161
trigger.event.data.battery_level }}% {{ '\n' -}} You need {{
@@ -68,7 +68,7 @@ action:
6868
sequence:
6969
- service: persistent_notification.dismiss
7070
data:
71-
notification_id: "{{ trigger.event.data.device_id }}"
71+
notification_id: "{{ trigger.event.data.device_id }}-{{ trigger.event.data.source_entity_id }}"
7272
mode: queued
7373
```
7474
@@ -122,6 +122,7 @@ action:
122122
- service: battery_notes.set_battery_replaced
123123
data:
124124
device_id: "{{ trigger.event.data.device_id }}"
125+
source_entity_id: "{{ trigger.event.data.source_entity_id }}"
125126
mode: queued
126127
```
127128
@@ -226,4 +227,4 @@ It is extended from the example Battery Not Reported automation yaml above for t
226227
You must trigger the check_battery_not_reported service via an automation to raise events, see [Check Battery Last Reported Daily](community.md/#check-battery-last-reported-daily) above.
227228
228229
## Contributing
229-
If you want to contribute then [fork the repository](https://github.com/andrew-codechimp/HA-Battery-Notes), edit this page which is in the docs folder and submit a pull request.
230+
If you want to contribute then [fork the repository](https://github.com/andrew-codechimp/HA-Battery-Notes), edit this page which is in the docs folder and submit a pull request.

docs/entities.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ See how to use this entity in the [community contributions](./community.md)
2323
| `battery_last_reported_level` | `float` | The level when the battery was last reported |
2424
| `device_id` | `string` | The device_id of the device |
2525
| `device_name` | `string` | The name of the device |
26+
| `source_entity_id` | `string` | The entity_id the battery note is associated with |
2627

2728
## Battery Type
2829
`sensor.{{device_name}}_battery_type`

docs/events.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ You can use this to send notifications in your preferred method. An example aut
1212
| Attribute | Type | Description |
1313
|-----------|------|-------------|
1414
| `device_id` | `string` | The device id of the device. |
15+
| `source_entity_id` | `string` | The entity id of the sensor associated with the battery note. |
1516
| `device_name` | `string` | The device name (or associated sensor name if no device). |
1617
| `battery_low` | `bool` | Returns true if the battery has gone below the threshold, false when the battery has returned above the threshold. **Your automations will almost certainly want to examine this value and set/clear notifications or other indicators.** |
1718
| `battery_type_and_quantity` | `string` | Battery type & quantity. |
@@ -53,7 +54,7 @@ action:
5354
data:
5455
title: |
5556
{{ trigger.event.data.device_name }} Battery Low
56-
notification_id: "{{ trigger.event.data.device_id }}"
57+
notification_id: "{{ trigger.event.data.device_id }}-{{ trigger.event.data.source_entity_id }}"
5758
message: >
5859
The device has a battery level of {{
5960
trigger.event.data.battery_level }}% {{ '\n' -}} You need {{
@@ -66,7 +67,7 @@ action:
6667
sequence:
6768
- service: persistent_notification.dismiss
6869
data:
69-
notification_id: "{{ trigger.event.data.device_id }}"
70+
notification_id: "{{ trigger.event.data.device_id }}-{{ trigger.event.data.source_entity_id }}"
7071
mode: queued
7172
```
7273
@@ -81,6 +82,7 @@ An example automation below shows how to update the battery_replaced.
8182
| Attribute | Type | Description |
8283
|-----------|------|-------------|
8384
| `device_id` | `string` | The device id of the device. |
85+
| `source_entity_id` | `string` | The entity id of the sensor associated with the battery note. |
8486
| `device_name` | `string` | The device name (or associated sensor name if no device). |
8587
| `battery_low` | `bool` | Returns true if the battery has gone below the threshold, false when the battery has returned above the threshold. |
8688
| `battery_type_and_quantity` | `string` | Battery type & quantity. |
@@ -104,6 +106,7 @@ action:
104106
- service: battery_notes.set_battery_replaced
105107
data:
106108
device_id: "{{ trigger.event.data.device_id }}"
109+
entity_id: "{{ trigger.event.data.source_entity_id }}"
107110
mode: queued
108111
```
109112

@@ -117,7 +120,7 @@ The service can raise multiple events quickly so when using with an automation i
117120
| Attribute | Type | Description |
118121
|-----------|------|-------------|
119122
| `device_id` | `string` | The device id of the device. |
120-
| `entity_id` | `string` | The entity id of the sensor associated with the battery note. (BETA ONLY)|
123+
| `source_entity_id` | `string` | The entity id of the sensor associated with the battery note. |
121124
| `device_name` | `string` | The device name (or associated sensor name if no device). |
122125
| `battery_type_and_quantity` | `string` | Battery type & quantity. |
123126
| `battery_type` | `string` | Battery type. |

docs/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Battery Notes for Home Assistant
22

3-
Integration to add battery notes to a device, with automatic discovery via a growing [battery library](https://github.com/andrew-codechimp/HA-Battery-Notes/blob/main/library.md) for devices.
4-
Track the battery type, when the battery was replaced, when a battery is low based on device or global thresholds and also when a device hasn't reported a battery for a while.
3+
Integration to add battery notes to a device or entity, with automatic discovery via a growing [battery library](library.md) for devices.
4+
Track the battery type, when the battery was replaced, when a battery is low based on device or global thresholds and also when a battery hasn't been reported for a while.
55
Battery low, replaced and not reported are all via events and services, you have the option of creating your own automations for these or using the predefined ones in [community](./community.md).
66

77
*Please :star: this repo on [GitHub](https://github.com/andrew-codechimp/HA-Battery-Notes) if you find it useful*
@@ -28,7 +28,8 @@ Once you have [installed the integration](https://github.com/andrew-codechimp/HA
2828
## To add a battery note manually
2929
* Go to Settings/Integrations and click Add Integration.
3030
* Select Battery Notes.
31-
* Choose your device from the drop down and click next.
31+
* Choose Device or Entity and click next. Device will automatically detect a battery and will work for most common devices, you should use entity if your device has multiple batteries or when an entity does not have a device.
32+
* Choose your device or entity from the drop down and click next.
3233
* Enter the battery type and quantity and optionally a battery low threshold and click submit.
3334

3435
!!! info

docs/services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ See how to use this service in the [community contributions](./community.md)
99
| Parameter | Optional | Description |
1010
| ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------- |
1111
| `data.device_id` | `yes` | The device id that you want to change the battery replaced date for. |
12+
| `data.source_entity_id` | `yes` | The entity id that you want to change the battery replaced date for. |
1213
| `data.datetime_replaced` | `yes` | The optional datetime that you want to set the battery replaced to, if omitted the current date/time will be used. |
1314

1415
You must specify either a device_id or entity_id, entity_id will be used in preference if both are specified. This allows the service to work with battery notes associated with both a device and also an individual entity, whether it is part of a device or not.
@@ -36,4 +37,3 @@ The service will raise a seperate [battery_threshold](./events.md/#battery_thres
3637
You can use this service call as a reminder that is convenient to you, e.g. when you wake up, once a week etc. The event has a boolean data item `reminder` to determine if the event was raised by this service or the device battery going to a low state.
3738

3839
See how to use this service in the [community contributions](./community.md)
39-

0 commit comments

Comments
 (0)