Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created November 12, 2020 13:22
Show Gist options
  • Save bessarabov/225b557bd6c0620a77d5cec00300e9eb to your computer and use it in GitHub Desktop.
Save bessarabov/225b557bd6c0620a77d5cec00300e9eb to your computer and use it in GitHub Desktop.
timer:
toilet:
automation:
- alias: Turn on light in the toilet by aqara sensor motion
trigger:
platform: mqtt
topic: zigbee2mqtt/0x00158d0004518e15
condition:
condition: template
value_template: "{{ trigger.payload_json.occupancy }}"
action:
- service: light.turn_on
data_template:
entity_id: light.0xccccccfffe00418e_light
brightness: "{% if is_state('binary_sensor.night', 'on') %}1{% else %}255{% endif %}"
- service: timer.cancel
data:
entity_id: timer.toilet
- service: timer.start
data:
entity_id: timer.toilet
duration: "0:05:00"
- alias: Turn off light in the toilet by timer
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.toilet
action:
- service: light.turn_off
data:
entity_id: light.0xccccccfffe00418e_light
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment