plex-configs/home_assistant/blueprints/automations/based_on_sensor.yaml

76 lines
1.9 KiB
YAML

# This script will trigger different actions based on whether a sensor is on or off.
blueprint:
name: Based on sensor
description: Trigger an action when a sensor is on or off
source_url: https://raw.githubusercontent.com/nwithan8/configs/main/home_assistant/blueprints/automations/based_on_sensor.yaml
domain: automation
input:
sensor:
name: Sensor
description: A sensor that toggles on and off
selector:
entity:
domain:
- sensor
- binary_sensor
- input_boolean
- light
- switch
- outlet
sensor_on_state:
name: Sensor "on"
description: State the sensor is considered "on"
selector:
text:
sensor_on_action:
name: When enabled
description: The action to perform when the sensor is enabled
selector:
action:
default: []
sensor_off_state:
name: Sensor "off"
description: State the sensor is considered "off"
selector:
text:
sensor_off_action:
name: When disabled
description: The action to perform when the sensor is disabled
selector:
action:
default: []
duration:
name: Wait duration
description: How long to wait after the sensor is disabled before triggering the action
default: "0:00:30"
trigger:
- id: "off"
entity_id: !input sensor
for: !input duration
platform: state
to: !input sensor_off_state
- id: "on"
entity_id: !input sensor
platform: state
to: !input sensor_on_state
condition: []
action:
- choose:
# Sensor enabled
- conditions:
- condition: trigger
id: "on"
sequence: !input sensor_on_action
# Sensor disabled
- conditions:
- condition: trigger
id: "off"
sequence: !input sensor_off_action
mode: single