I’m sure this is possible and described somewhere but I couldn’t find it. I’m trying to use a field as the input to a script to select a key in a dict variable. What’s the correct way to do this? Below the script I am writing, I’ve commented out the ‘fields’ part, but basically I want to pass the name of command to send to the script. In the example I hardcoded the command into “codedata”, that works. I had an example of a blueprint from which I thought that using codedata: '{{codes[command]}} should have worked with the field enabled but it did not. I tried multiple combinations of brackets and dots and quotation marks but nothing worked. What’s the characters I need to use here?
Thanks!
# fields:
# command:
# description: the command to send
# example: hk_amp_on
variables:
codes:
hk_amp_on: >-
BVUjhBEzAuATAQOmBjMC4AcBQBPAA+ATAcAj4A8HwAEJ1a1VI7UIMwL//+ArBwB44A43CXgC//9VI7UIMwI=
hk_amp_off: >-
BUMjgBE0AuATAQOiBjQC4AcBQBPAA0ABwAvgAwfAAUAT4AsBQBdAA0ABCbOtQyPJCDQC///gAgcCCDQC
hk_amp_cd: >-
BVAjdxEwAuATAQOpBjAC4AcBQBPAA+ADAUAT4AMBQA/gAwNAAeAHD0ABCaytUCPYCDAC///gGgcCCDAC
hk_amp_aux: >-
BU0jaRE0AuATAQOZBjQC4AcBQBPAA0ABQAtAAcAHwAFAD0ADQAHgAwdAC0ADwAEJwK1NI8kINAL//+ACBwIINAI=
hk_amp_volume_up: >-
BUQjnhE0AuATAQOGBjQC4AcBQBPAA0ABwAtABwXDAo8BNAKAAUAPQAPAAQPDAjQCQA/AA8ABD9utRCPyCDQC//9EI/IINAI=
hk_amp_volume_down: >-
BVUjcxEyAuATAQOiBjIC4AcBQBPAA+AHAUAXwAFAC+AHA0ABwBPAAQ+lrVUj0wgyAv//VSPTCDIC
device_ieee: 18:0D:F9:FF:FE:D4:87:4D
codedata: "{{codes.hk_amp_off}}"
sequence:
- action: zha.issue_zigbee_cluster_command
metadata: {}
data:
cluster_type: in
ieee: "{{device_ieee}}"
endpoint_id: 1
cluster_id: 57348
command: 2
command_type: server
params:
data: "{{codedata}}"
code: "{{codedata}}"
alias: Amplifier IR control
description: "script to send commands from MOES UFO controller "