I´ve ordered several zigbee buttons (Sonoff SNZB-01)
and would like to fix my current automation that handles 1 button to be dynamic
and call scripts based on device_ieee but I want my scripts to have better naming convention than **device_ieee + “_click/dblclick/hold”
So I thought a template service calling different scripts depending on device_ieee would be the solution but I can’t get it working.
Am I doing it wrong or is this not possible?
I think I understand what you’re trying to do and it cannot be done with this thing you’ve invented called a “template service” (it doesn’t exist; there’s no service call to set a variable).
The variable you named device should be defined within action. Its template should compute the value by using trigger.event.data.device_ieee as a key for a map containing each device_ieee and its associated device.
If you define a variable the way you originally did, outside of action, the variable is global to the entire automation (visible in condition and action). However, as far as I can recall, it doesn’t have access to the Trigger State Object (in your case trigger.event.data.etc) because that’s generated after the trigger occurs.
If you define a variable insideaction it is local to action (i.e. doesn’t exist elsewhere like the condition). In addition, it has access to the Trigger State Object.
Having some issues here, action dies att the service template… The script to call does exist.
I added an input_text just to capture the generated text
If I add my input_text service before the templated service
I can see what the command looks like, IF I add my input text service after the templated service
it does not get updated so I guess its because the action “dies”