Skip to content

Instantly share code, notes, and snippets.

@tvwerkhoven
Last active December 7, 2021 21:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tvwerkhoven/e2b30274d2bb054d60bca2c7cd45ebdf to your computer and use it in GitHub Desktop.
Save tvwerkhoven/e2b30274d2bb054d60bca2c7cd45ebdf to your computer and use it in GitHub Desktop.
Home Assistant automation to notify at high sensor values
blueprint:
name: High sensor value notification
description: Notify users of high sensor values (e.g. CO2, temp, PM2.5), and again when value drops below acceptable level
domain: automation
input:
trigger_sensor:
name: Trigger sensor
description: E.g. CO2, PM2.5, temperature
selector:
entity:
domain: sensor
trigger_level_high:
name: Trigger level high
description: Notify above this level
selector:
number:
mode: box
min: -50
max: 1250
trigger_level_low:
name: Trigger level low
description: Notify again below this level
selector:
number:
mode: box
min: -50
max: 1250
alias: High sensor value notification+
description: Notify when high sensor values are detected somewhere
trigger:
- platform: numeric_state
entity_id: !input "trigger_sensor"
above: !input "trigger_level_high"
variables:
trigger_sensor_var: !input "trigger_sensor"
trigger_level_high_var: !input "trigger_level_high"
trigger_level_low_var: !input "trigger_level_low"
condition: []
action:
- repeat:
until:
- condition: numeric_state
entity_id: !input "trigger_sensor"
below: !input 'trigger_level_low'
sequence:
- service: notify.notify
data:
message: >-
High reading of {{state_attr(trigger_sensor_var, 'friendly_name')}}
at {{ states(trigger_sensor_var) }}{{state_attr(trigger_sensor_var, 'unit_of_measurement') }}
- wait_for_trigger:
- platform: numeric_state
entity_id: !input "trigger_sensor"
below: !input 'trigger_level_low'
timeout:
minutes: 60
continue_on_timeout: false
- service: notify.notify
data:
message: >-
Reading of {{state_attr(trigger_sensor_var, 'friendly_name')}} back to normal
at {{ states(trigger_sensor_var) }}{{state_attr(trigger_sensor_var, 'unit_of_measurement') }}
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment