2023-03-29 05:55:29 +00:00
|
|
|
# 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
|
2023-03-29 05:56:09 +00:00
|
|
|
source_url: https://raw.githubusercontent.com/nwithan8/configs/main/home_assistant/blueprints/automations/based_on_sensor.yaml
|
2023-03-29 05:55:29 +00:00
|
|
|
domain: automation
|
|
|
|
input:
|
|
|
|
sensor:
|
|
|
|
name: Sensor
|
|
|
|
description: A sensor that toggles on and off
|
|
|
|
selector:
|
|
|
|
entity:
|
2023-03-29 16:51:43 +00:00
|
|
|
domain:
|
|
|
|
- sensor
|
|
|
|
- binary_sensor
|
|
|
|
- input_boolean
|
|
|
|
- light
|
|
|
|
- switch
|
|
|
|
- outlet
|
|
|
|
sensor_on_state:
|
|
|
|
name: Sensor "on"
|
|
|
|
description: State the sensor is considered "on"
|
|
|
|
selector:
|
|
|
|
text:
|
2023-03-29 05:55:29 +00:00
|
|
|
sensor_on_action:
|
|
|
|
name: When enabled
|
|
|
|
description: The action to perform when the sensor is enabled
|
|
|
|
selector:
|
|
|
|
action:
|
|
|
|
default: []
|
2023-03-29 16:51:43 +00:00
|
|
|
sensor_off_state:
|
|
|
|
name: Sensor "off"
|
|
|
|
description: State the sensor is considered "off"
|
|
|
|
selector:
|
|
|
|
text:
|
2023-03-29 05:55:29 +00:00
|
|
|
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
|
2023-03-29 16:51:43 +00:00
|
|
|
to: !input sensor_off_state
|
2023-03-29 05:55:29 +00:00
|
|
|
|
|
|
|
- id: "on"
|
|
|
|
entity_id: !input sensor
|
|
|
|
platform: state
|
2023-03-29 16:51:43 +00:00
|
|
|
to: !input sensor_on_state
|
2023-03-29 05:55:29 +00:00
|
|
|
|
|
|
|
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
|