Skip to content

Commit

Permalink
Example blueprints (#670)
Browse files Browse the repository at this point in the history
* First example

* WIP

* WIP

* Docs

* Docs

* Docs

* Docs
  • Loading branch information
andrew-codechimp authored Jan 25, 2024
1 parent cb59ae3 commit f7ab4ff
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 1 deletion.
26 changes: 26 additions & 0 deletions docs/blueprints/battery_notes_battery_replaced.yaml
Original file line number Diff line number Diff line change
@@ -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'
94 changes: 94 additions & 0 deletions docs/blueprints/battery_notes_battery_threshold.yaml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 19 additions & 1 deletion docs/community.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit f7ab4ff

Please sign in to comment.