paul.nine3
(Paul Anderson)
December 19, 2024, 1:11pm
1
Hi …
The following trigger works with the constant numbers (15 and 60):
- id: bathroom_humidity_goes_low
type: humidity
device_id: ea366e5190f68e32fc354a80cf7cc390
entity_id: 8115526df0131de8772f90f4afa4d1a8
domain: sensor
trigger: device
below: 60
for:
hours: 0
minutes: 15
seconds: 0
And the following template works in other situations:
{{ states('input_number.bathroom_fan_time') }}
But if I try to replace the 15 or the 60 with the template, I get the following error:
** Error loading /config/configuration.yaml: invalid key: "{"states('input_number.bathroom_fan_time') ": None}"
Can anyone tell me what I’m doing wrong ?
Many thanks
Paul
tom_l
December 19, 2024, 8:48pm
2
Device triggers do not support templates.
Background
When you start writing automations, a device trigger seems the obvious choice. Everybody knows what a device is and it comes at the top of the UI dropdown list.
[image]
It works… but it is certainly not a “great way to start” because it is storing up problems for the future. Far better to use an entity, with state or numeric_state.
Device_id problems
The yaml will be longer and harder to follow, which may make maintenance difficult, especially a few months down the line when y…
paul.nine3
(Paul Anderson)
December 20, 2024, 10:39am
3
This is super useful! Thank you! I did think that those cryptic device references were a bit suspect - I have changed almost all of them to entities & my templates are now working. I have just one case where I still have a device reference:
- id: bathroom_fan_button_longpush
type: long_push
subtype: button1
device_id: a9376566982c5f5c398121c5eef4707f
domain: shelly
trigger: device
If I try to use the entity in the trigger, I can’t see how to distinguish the “long push” from a simple press. Is there a way to do this without using the device ID?
Thanks again for your time
Paul
tom_l
December 20, 2024, 10:58am
4
That looks like you need to use an event trigger instead.
paul.nine3
(Paul Anderson)
December 20, 2024, 5:50pm
5
Ah. Ok. Thanks. I will look in to that …
Paul