Hi all !
I’m new with HA but already have some things configured and automated. Both the sonoff basic and bridge have tasmota installed.
I have a sonoff basic connected to a lamp and already configured in HA.
The sonoff bridge is sending mqtt codes to HA when the PIR2 detects movement.
The automation is set when the bridge sends the PIR code, the lamp turns on.
What I’m trying to do is, after the lamp has been turned on, it turns off after x minutes.
I don’t have any binary sensor configured. Here’s the configurations.
configuration.yaml (sonoff basic switch)
switch:
- platform: mqtt
name: "sonoff_lamp"
state_topic: "stat/sonoff_lamp/POWER"
command_topic: "cmnd/sonoff_lamp/power"
availability_topic: "tele/sonoff_lamp/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
And automations.yaml
- alias: Light on
hide_entity: true
trigger:
platform: mqtt
topic: tele/sonoffBridge/RESULT
condition:
condition: template
value_template: '{{trigger.payload_json.RfReceived.Data == "EEA0FE" }}'
action:
service: homeassistant.turn_on
data:
entity_id: switch.sonoff_lamp
This is working.
I’m trying to turn it off after a few minutes.
This is the code I’m using - but is not correct
- alias: Light off
trigger:
platform: state
entity_id: switch.sonoff_lamp
from: 'ON'
to: 'OFF'
for:
minutes: 1
condition:
condition: state
entity_id: switch.sonoff_lamp
state: 'ON'
action:
service: homeassistant.turn_off
entity_id: switch.sonoff_lamp
I’ve seen configurations with binary sensors defined, but don’t know if its a similar approach or a better one.
Thank you for any help