From 7466a49caac56216a575e9726750fcd5550a54f9 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Sun, 27 Oct 2024 10:00:26 +0000 Subject: [PATCH] 202409 docs (#2274) * Add battery replaced event documentation * Add battery replaced example * Add beta tag --- docs/events.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/events.md b/docs/events.md index 72c402fbd..d4f5f563d 100644 --- a/docs/events.md +++ b/docs/events.md @@ -156,4 +156,42 @@ action: trigger.event.data.battery_type }} mode: queued max: 30 +``` + +## Battery Replaced (BETA ONLY) +`battery_notes_battery_replaced` + +This is fired when the battery is replaced, either by a button press or the action. + +This can be useful for adding batteries to a shopping list or inventory system. + +| Attribute | Type | Description | +|-----------|------|-------------| +| `device_id` | `string` | The device id of the device. | +| `source_entity_id` | `string` | The entity id of the sensor associated with the battery note. | +| `device_name` | `string` | The device name (or associated sensor name if no device). | +| `battery_type_and_quantity` | `string` | Battery type & quantity. | +| `battery_type` | `string` | Battery type. | +| `battery_quantity` | `int` | Battery quantity. | + +### Automation Example + +Note this cannot be run manually as it examines event triggers. + +```yaml +alias: Battery Replaced +description: Battery replaced +trigger: + - platform: event + event_type: battery_notes_battery_replaced +condition: [] +action: + - service: persistent_notification.create + data: + title: | + {{ trigger.event.data.device_name }} Battery Replaced + message: > + You just used {{trigger.event.data.battery_type_and_quantity }} batteries +mode: queued +max: 30 ``` \ No newline at end of file