I’m trying to set a schedule for an air purifier. As well as being on/off at certain time I need to change the Mode attribute of the air purifier at different times of the day.
My schedule is as follows (defined in UI so no YAML available):
However I get the error: Error: Option {{ state_attr('schedule.lounge_purifier', 'mode') }} is not valid for entity select.air_purifier_1_mode, valid options are: Off, Auto, Eco, Max, Low, Med, High
Device actions do not support templates. Do not use device actions, ever, if it can be avoided. They may be easy to create in the visual editor but makes code difficult to read.
Instead use a select.select_option action. (And while you are at it, replace the preceding device action with a switch.turn_on action.)
It is a very arbitrary limitation, as many such limitation in HASS are. Feels like whomever wrote the device action parser simply forgot to add a line that passes any optional arguments through the template renderer and then never got around to fixing it. Most such bug reports filed through GitHub Issues sadly seem to never be read by anyone and much less fixed unless you do it yourself.
Device-oriented trigger/condition/action was designed for novices. Select a device (virtual model of a physical device) and the UI is able to present its capabilities.
Templating is an advanced subject, requiring familiarity with Jinja, so it wasn’t included in a feature intended for a novice audience.
The way I look at it, novice users wouldn’t be affected either way if templates were supported, thus there is no reason for not supporting them.
Intermediate users however are harmed by the exclusion of templates, as they begin to learn more about HASS but cannot understand why this newfangled thing they just learnt about does not work when attempting to make their existing novice automations do more advanced stuff. Hence why I believe that templates should just work everywhere, always.
Having been both novice and intermediate user, I never felt “harmed” by it because I consciously chose not to use them.
It’s a feature for novices and, having progressed from that stage, I prefer to use the vast array of non-device-oriented triggers/conditions/actions.
In your linked post, you indicated your PRs were rejected. Can you post links to them? I’d like to see the reasons given. Or if you recall them, and don’t mind, please share them here. Thank you.