Hi All
Recently with the changes made in Z2M I migrated my automation from node-red into HA automation. I am using sonff zigbee PIR sensors to trigger my lights for 10mins then turn off. I initially used the delay function but found that to be unreliable to am trying to move to timers.
I used the following code for a few WIFI PIR sensor that change state this worked fine however with MQTT trigger, it triggers the turn on automation but not the timer so never turns off. I understand that in my code there is no payload and I am guessing that is where the problem lies. I tried a number of variables with value_template but no joy. I have spent days on this with no luck so any help is greatly appreciated.
The MQTT payload is {"battery":100,"battery_low":false,"linkquality":43,"occupancy":true,"voltage":3000}
In MQTT explorer the message seems to trigger quickly then go back to false.
alias: Bedroom PIR Timer
description: ""
triggers:
- trigger: event
event_type: timer.finished
event_data:
entity_id: timer.bedroom_pir
id: Timer finished
- trigger: mqtt
topic: zigbee2mqtt/Zigbee Bedroom PIR
id: Motion Stopped
- trigger: mqtt
topic: zigbee2mqtt/Zigbee Bedroom PIR
id: Motion Detected
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- Motion Stopped
sequence:
- action: timer.start
target:
entity_id: timer.bedroom_pir
data:
duration: "600"
- conditions:
- condition: trigger
id:
- Motion Detected
sequence:
- action: timer.cancel
target:
entity_id: timer.bedroom_pir
data: {}
- action: light.turn_on
metadata: {}
data: {}
target:
device_id: 9b51e60cd2e377dedcb57680b814a39f
- conditions:
- condition: trigger
id:
- Timer finished
sequence:
- action: light.turn_off
metadata: {}
data: {}
target:
device_id: 9b51e60cd2e377dedcb57680b814a39f
mode: single
Thanks again