Skip to content

Instantly share code, notes, and snippets.

@ignisf
Created July 20, 2024 16:10
Show Gist options
  • Save ignisf/65ad0e04311991bd0876e21eda7031fb to your computer and use it in GitHub Desktop.
Save ignisf/65ad0e04311991bd0876e21eda7031fb to your computer and use it in GitHub Desktop.
blueprint:
name: HVAC Vane Direction on Presence
description: Turn HVAC away from/toward people
domain: automation
input:
presence_detection_device:
name: Presence Sensor
description: Specify a device that will trigger the automation to switch to direct/indirect vane position.
selector:
entity:
device_class: motion
domain: binary_sensor
absence_duration:
name: Absence Duration
description: How long must there be no presence in the area in order for it to be considered vacant.
selector:
duration:
default:
minutes: 15
target_entities:
name: Target Entities
description: Choose which vane entities should be controlled by the automation.
selector:
entity:
domain: select
multiple: true
vacant_area_value:
name: Vane Position When Area is Vacant
description: What value should be selected when there are no people in the area.
occupied_area_value:
name: Vane Position When Area is Occupied
description: What value should be selected when there are people in the area.
switching_condition:
name: Condition
description: Specify a condition that has to be met before the automation changes the state.
selector:
condition:
default:
alias: "Unconditionally"
condition: template
value_template: true
mode: single
trigger:
- platform: state
entity_id: !input presence_detection_device
to: "on"
id: area_occupied
- platform: state
entity_id: !input presence_detection_device
to: "off"
for: !input absence_duration
id: area_vacant
action:
- if:
- condition: and
conditions:
- condition: and
conditions: !input switching_condition
- condition: trigger
id:
- area_occupied
then:
- repeat:
for_each: !input target_entities
sequence:
- condition: template
value_template: "{{ not is_state_attr((device_entities(device_id(repeat.item)) | select('match', '^climate\\.') | first), 'hvac_action', 'off') }}"
- service: select.select_option
target:
entity_id: "{{ repeat.item }}"
data:
option: !input occupied_area_value
else:
- repeat:
for_each: !input target_entities
sequence:
- condition: template
value_template: "{{ not is_state_attr((device_entities(device_id(repeat.item)) | select('match', '^climate\\.') | first), 'hvac_action', 'off') }}"
- service: select.select_option
target:
entity_id: "{{ repeat.item }}"
data:
option: !input vacant_area_value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment