I need to run an automation when a light is turned on or off with the physical button. I see a possibility in the Activity log, I think. Because when I use Hass to turn on and off the light, it says “turned off by action light: turn off”. When the motion sensor light automation is used, it says “turned off triggered by automation motion sensor light”. But when I use the physical dimmer button it just says “turned off”. The same goes for turning on. it’s in Norwegian, but I think it should be understandable. “slått på” means turned on, “slått av” means turned off, and “utløst av” means triggered by:
So if it was possible to filter so only the one saying “turned off” and nothing else came through a condition, I believe it would work. But I’m not getting anywhere. I thought this could work, but it doesn’t:
conditions:
- condition: template
value_template: "{{ 'triggered by' not in trigger.event.data }}"
I also made a test automation to send the trigger.event.data as an MQTT (which I read in Node-RED, it’s my goto way of logging stuff). When I try to send the MQTT message without the condition, but with {{ trigger.event.data }} as the payload, it doesn’t work. Maybe the syntax is wrong? If I try to put a string as the payload it works. So what am I doing wrong here? Here’s the test automation:
alias: Test automation
description: ""
triggers:
- trigger: state
entity_id:
- light.dimmer_in_staircase
actions:
- action: mqtt.publish
metadata: {}
data:
topic: eventdatatest
payload: "{{ trigger.event.data }}"
