@lmb wrote:
Hey all,
I’m using quite a few remotes in my home - and the YaML for them can get quite exasperatingly verbose if I have to configure every possible button press/mode separately. Hence, I’m using templating to reduce the number of lines, for example:
- alias: Remote trigger: platform: event event_type: homematic.keypress event_data: name: "Remote-1" action: service: scene.turn_on data_template: entity_id: > {{ { '1_PRESS_SHORT':'scene.off', '2_PRESS_SHORT':'scene.off', '3_PRESS_SHORT':'scene.low', '4_PRESS_SHORT':'scene.bright', '5_PRESS_SHORT':'scene.mid', '6_PRESS_SHORT':'scene.work', '7_PRESS_SHORT':'scene.nightlight', '8_PRESS_SHORT':'scene.off', '1_PRESS_LONG':'scene.screen_open', '3_PRESS_LONG':'scene.screen_open50', '5_PRESS_LONG':'scene.screen_open25', '7_PRESS_LONG':'scene.screen_closed', '2_PRESS_LONG':'scene.bedroom_open', '4_PRESS_LONG':'scene.bedroom_open50', '6_PRESS_LONG':'scene.bedroom_open25', '8_PRESS_LONG':'scene.bedroom_closed', }.get(trigger.event.data.channel ~ '_' ~ trigger.event.data.param) }}
That works quite nicely (similarly for deCONZ, where I just have to match on
trigger.event.data.event
rather than needing to concatenate), but it gets rather verbose again if I have a similar look-up table for theservice_template
in case I want different services and not just scene activation or only scripts.Excerpt:
action: service_template: > {{ { 1001:'scene.turn_on', ... }[trigger.event.data.event] }} data_template: entity_id: > {{ { '1001':'scene.foo', ... }[trigger.event.data.event] }}
What I’d want is a dict that combines both the
service_template
and theentity_id
passed to it, something like:action: template: > {{ { 1001:[ 'scene.turn_on', 'scene.foo' ], ... }[trigger.event.data.event] }}
Does anyone have a suggestion on how to achieve this goal of a more compact syntax?
Thanks for any insights!
Posts: 1
Participants: 1