I want some of my lights to switch off after a certain period of time. So I created an automation for it.
However in some cases I may want that light to stay on longer than the time out. e.g. I am in the pantry doing something that will take longer than 5 minutes, but the light goes off every 5 minutes.
As I have Tasmota based touch switches to control the lights, I want to assign a double, triple or quad press of the switch to ‘lock’ it on so it does not turn off after the normal timeout period.
nb: This is setup so the second trigger is specifically for a Tasmotised, multi tap switch with MQTT, but could be changed to use any other trigger:
blueprint:
name: Timed Light with lock
description: Define a timed light with a delayed turn off, with the ability to lock the light on using an Tasmotta , TRIPLE or QUAD click
domain: automation
input:
target_light:
name: Light
description: The Light
selector:
entity:
domain: light
delay:
name: Delay
description: The delay in minutes before switching off the light
selector:
number:
min: 5
max: 120
mode: slider
unit_of_measurement: minutes
step: 5
mqtt_message:
name: MQTT Message
description: The Tasmota multi-tap MQTT Message that will lock the light on (e.g. stat/tasmota_999999/BUTTON1T)
selector:
text:
trigger_type:
name: the type of Tasmota multi-tap
description: The type of multi-tap
selector:
select:
options:
- DOUBLE
- TRIPLE
- QUAD
trigger:
- platform: state
entity_id: !input target_light
to: "on"
id: "trig_on_single"
- platform: mqtt
topic: !input mqtt_message
value_template: "{{ value_json.TRIG }}"
payload: !input trigger_type
action:
- service: automation.turn_off
target:
entity_id: "{{ this.entity_id }}"
data:
stop_actions: false
- service: light.turn_on
target:
entity_id: !input target_light
- delay:
milliseconds: 100
- service: automation.turn_on
target:
entity_id: "{{ this.entity_id }}"
- condition: trigger
id: "trig_on_single"
- delay:
minutes: !input delay
- service: light.turn_off
target:
entity_id: !input target_light
data: {}
mode: restart
gist is here: timed_light_with_mqtt_lock.yaml · GitHub