I’m new with Home Assistant and just set up everything new in my house (coming from Homey). I think HA is amazing so far. But now im struggeling with some basic timer. I’m not a coder but wanna learn that slowly now. It’s fun!
I created a timer with the helpers with entity name timer.flur_tags.
I’m starting that timer sucessfully with an automation
But now I’m struggeling turning the lights off when timer is done. I can’t save the automation and HA is telling me Message malformed: expected dict for dictionary value @ data[‘event_data’]:
alias: Flurlicht aus nach Timer
description: ''
mode: single
trigger:
- platform: event
event_type: timer.finished
event_data: timer.flur_tags
condition: []
action:
- service: light.turn_off
data:
transition: 10
target:
entity_id: light.flur_schiene_komplett
Still after lots of research I didn’t really find a solution.
When in doubt, refer to the examples in the documentation (which demonstrates how to use an Event Trigger for a timer and, like finity suggested, the issue is indentation of event_data's entity_id option).
Is that timer something you want to control via the UI or is it more like a “set” time that’s always the same? Like “turn off the light after five minutes”?
If the latter, I wouldn’t use a timer, just set the time in the automation or use a “state” time for it. From your naming of the light, I assume you want your hallway light on for five minutes after it was turned on. This would be a very simple automation, no timers or other fancy things needed.
alias: Flurlicht aus nach fünf Minuten
description: ''
mode: single
trigger:
- platform: state
entity_id: light.flur_schiene_komplett
to: 'on'
for: '00:05:00'
condition: []
action:
- service: light.turn_off
data:
transition: 10
target:
entity_id: light.flur_schiene_komplett
In fact I studied the documentation. And I already tried what finity suggested. But I guess that time I still had another error so I didn’t work. But thanks for your help, 123Taras!
That’s an very intersting way of doing that as well, Patrick. Just triggering if the light was turned on. I will defnitely consider that solution as well. Only thing is, I had the idea of turning it on by a motion sensor and only then using the timer. In your case it always turns off after 5 min, also when I turn it on manually, right?
Thanks a lot!!!
You need to differentiate what you want with the timer. The part where it goes this or that way, is how do you want your timer to be set?
If the timer is kind of constant (read: the time doesn’t get changed often/manually), you use an offset, like I did in the example. If you need the timer to be adjustable in the frontend, you use a “timer” component (like you did).
It doesn’t matter for the other stuff, it’s just depending on the timer.
Whatever it is that triggers your automation, a sensor for ie. the temperature, a binary_sensor like a motion sensor or a door contact, a template sensor, as long as it has a state, it can be the trigger (and following a state timing like “for”).
You can even set conditions for the offset. To stay with your example, you could differentiate between manually switched on or by motion sensor. Eg. turned on manually => turn off after three minutes, turned on by motion => switch off after 30 seconds.