Skip to content

Commit

Permalink
Add condition to exclude devices
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-codechimp committed Feb 23, 2024
1 parent 7363117 commit e7c69a4
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions docs/blueprints/battery_notes_battery_not_reported.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,55 @@ blueprint:
author: andrew-codechimp
source_url: https://raw.githubusercontent.com/andrew-codechimp/HA-Battery-Notes/main/docs/blueprints/battery_notes_battery_not_reported.yaml
domain: automation

input:
not_reported_notification:
name: Battery Not Reported Notification
description: Create a persistent notification when the battery is not reported.
default: True
default: true
selector:
boolean: {}
excluded_devices:
name: Devices to exclude (Optional)
description: Devices that you do not want to trigger this automation.
default:
selector:
boolean:
device:
multiple: true
user_actions:
name: User Actions
description: User actions to run on battery not reported.
default: []
selector:
action:

action: {}
variables:
not_reported_notification: !input not_reported_notification

excluded_devices: !input excluded_devices
trigger:
- platform: event
event_type: battery_notes_battery_not_reported
alias: Battery not reported

condition: []

- platform: event
event_type: battery_notes_battery_not_reported
alias: Battery not reported
condition:
- condition: template
value_template: |-
{{ trigger.event.data.device_id not in excluded_devices}}
action:
- if:
- condition: template
value_template: "{{ not_reported_notification }}"
then:
- service: persistent_notification.create
data:
title: |
{{ trigger.event.data.device_name }} Battery Not Reported
message: >
The device has not reported its battery level for {{
trigger.event.data.battery_last_reported_days }} days {{ '\n'
-}} Its last reported level was {{
trigger.event.data.battery_last_reported_level }}% {{ '\n' -}} You need
{{ trigger.event.data.battery_quantity }}× {{
trigger.event.data.battery_type }}
- alias: "Run user actions"
choose: []
default: !input 'user_actions'
- if:
- condition: template
value_template: '{{ not_reported_notification }}'
then:
- service: persistent_notification.create
data:
title: '{{ trigger.event.data.device_name }} Battery Not Reported
'
message: 'The device has not reported its battery level for {{ trigger.event.data.battery_last_reported_days
}} days {{ ''\n'' -}} Its last reported level was {{ trigger.event.data.battery_last_reported_level
}}% {{ ''\n'' -}} You need {{ trigger.event.data.battery_quantity }}× {{ trigger.event.data.battery_type
}}
'
- alias: Run user actions
choose: []
default: !input user_actions
mode: queued
max: 30

0 comments on commit e7c69a4

Please sign in to comment.