Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created October 18, 2020 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bessarabov/423cf1a65814666d8b1a4cdaebd571ed to your computer and use it in GitHub Desktop.
Save bessarabov/423cf1a65814666d8b1a4cdaebd571ed 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