From f7ab4ff850af28a443d4424a2f6a8a3cfd219f28 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Thu, 25 Jan 2024 16:02:11 +0000 Subject: [PATCH] Example blueprints (#670) * First example * WIP * WIP * Docs * Docs * Docs * Docs --- .../battery_notes_battery_replaced.yaml | 26 +++++ .../battery_notes_battery_threshold.yaml | 94 +++++++++++++++++++ docs/community.md | 20 +++- 3 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 docs/blueprints/battery_notes_battery_replaced.yaml create mode 100644 docs/blueprints/battery_notes_battery_threshold.yaml diff --git a/docs/blueprints/battery_notes_battery_replaced.yaml b/docs/blueprints/battery_notes_battery_replaced.yaml new file mode 100644 index 000000000..e4a6ab1b5 --- /dev/null +++ b/docs/blueprints/battery_notes_battery_replaced.yaml @@ -0,0 +1,26 @@ +blueprint: + name: Battery Notes - Battery Replaced + description: Set the battery replaced automatically when the battery increased + author: andrew-codechimp + source_url: https://raw.githubusercontent.com/andrew-codechimp/HA-Battery-Notes/main/docs/blueprints/battery_notes_battery_replaced.yaml + domain: automation + + input: + on_replaced_actions: + name: On Replaced Actions + description: User actions to run on battery replacement, the battery is marked as replaced automatically. Use any event data via trigger.event.data.xxx + default: [] + selector: + action: +mode: queued +trigger: + - platform: event + event_type: battery_notes_battery_increased +condition: [] +action: + - service: battery_notes.set_battery_replaced + data: + device_id: "{{ trigger.event.data.device_id }}" + - alias: "Run user on replaced actions" + choose: [] + default: !input 'on_replaced_actions' diff --git a/docs/blueprints/battery_notes_battery_threshold.yaml b/docs/blueprints/battery_notes_battery_threshold.yaml new file mode 100644 index 000000000..65d1cbe5a --- /dev/null +++ b/docs/blueprints/battery_notes_battery_threshold.yaml @@ -0,0 +1,94 @@ +blueprint: + name: Battery Notes - Battery Threshold + description: Actions to perform when the battery threshold is met + author: andrew-codechimp + source_url: https://raw.githubusercontent.com/andrew-codechimp/HA-Battery-Notes/main/docs/blueprints/battery_notes_battery_threshold.yaml + domain: automation + + input: + low_notification: + name: Battery Low Notification + description: Create a persistent notification when the battery is low. + default: True + selector: + boolean: + high_notification: + name: Remove Low Notification + description: Remove the persistent notification when the battery is no longer low. Use any event data via trigger.event.data.xxx + default: True + selector: + boolean: + on_low_actions: + name: On Low Actions + description: User actions to run on battery low. + default: [] + selector: + action: + on_high_actions: + name: On High Actions + description: User actions to run on battery returning from low. Use any event data via trigger.event.data.xxx + default: [] + selector: + action: + +variables: + low_notification: !input low_notification + high_notification: !input high_notification + +trigger: + - platform: event + event_type: battery_notes_battery_threshold + event_data: + battery_low: true + id: low + alias: Battery went low + - platform: event + event_type: battery_notes_battery_threshold + event_data: + battery_low: false + id: high + alias: Battery went high + +condition: [] + +action: + - choose: + - conditions: + - condition: trigger + id: + - low + sequence: + - if: + - condition: template + value_template: "{{ low_notification }}" + then: + - service: persistent_notification.create + data: + title: | + {{ trigger.event.data.device_name }} Battery Low + notification_id: "{{ trigger.event.data.device_id }}" + message: > + The device has a battery level of {{ + trigger.event.data.battery_level }}% {{ '\n' -}} You need {{ + trigger.event.data.battery_quantity }}x {{ + trigger.event.data.battery_type }} + - alias: "Run user on low actions" + choose: [] + default: !input 'on_low_actions' + - conditions: + - condition: trigger + id: + - high + sequence: + - if: + - condition: template + value_template: "{{ low_notification }}" + then: + - service: persistent_notification.dismiss + data: + notification_id: "{{ trigger.event.data.device_id }}" + - alias: "Run user on high actions" + choose: [] + default: !input 'on_high_actions' + +mode: queued \ No newline at end of file diff --git a/docs/community.md b/docs/community.md index 02f7db1d5..5cc61f37d 100644 --- a/docs/community.md +++ b/docs/community.md @@ -103,6 +103,24 @@ action: device_id: "{{ device_id(trigger.entity_id) }}" ``` -## Contributing +## Blueprints +[Blueprints](https://www.home-assistant.io/docs/automation/using_blueprints/) are an excellent way to get you up and running with the integration quickly. They can also be used as a guide for setting up new automations which you can tailor to your needs. + +### Battery Threshold (Beta Only) + +[Install blueprint](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fraw.githubusercontent.com%2Fandrew-codechimp%2FHA-Battery-Notes%2Fmain%2Fdocs%2Fblueprints%2Fbattery_notes_battery_threshold.yaml) | [Source](./blueprints/battery_notes_battery_threshold.yaml) + +This blueprint will allow notifications to be raised and/or custom actions to be performed when the battery threshold is met. +It is extended from the example Battery Low Notification automation yaml above for those who'd prefer an easy way to get started. + + +### Battery Replaced (Beta Only) + +[Install blueprint](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fraw.githubusercontent.com%2Fandrew-codechimp%2FHA-Battery-Notes%2Fmain%2Fdocs%2Fblueprints%2Fbattery_notes_battery_replaced.yaml) | [Source](./blueprints/battery_notes_battery_replaced.yaml) + +This blueprint will automatically update the battery replaced sensor and custom actions to be performed when the battery increases. +It is extended from the example Battery Replaced automation yaml above for those who'd prefer an easy way to get started. + +## Contributing 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.