Despite my best efforts, I’ve been unable to use the value of an input_number helper in my simple script. I found several other topics related to this, e.g., 442654, but none of the syntax suggestions that I found are working for me.
Message malformed: not a valid value for dictionary value @ data['type']
And a screenshot:
I have tried several variants for specifying the code_slot, including flipping the order of the double & single quotes, but to no avail. It only seems to accept hard-coded numbers for the value of code_slot and usercode.
Any pointers would be appreciated…I’m sure it’s something obvious that I’m just missing.
Thanks, @MaestroMetty. It didn’t seem to work though. For some reason, when I save those changes it kept resetting code_slot to ‘null’ and it reformatted usercode as:
"{{ states("input_number.lock_code") | string }}"
Continuing along that route, I’ve tried casting as int then string but am unable to get the representation that I need. For example, with Script A, it gets encoded as a number and there are no quotes added at all:
Script A:
data:
code_slot: "{{ states(\"input_number.lock_user_id\") | int | string }}"
usercode: "{{ states(\"input_number.lock_code\") | int | string }}"
Trace A:
service_data:
code_slot: 40
usercode: 1000
Yet in Script B, if I add an additional escaped double quote to the template, it gets encoded with a single quote AND a double quote. I just need one or the other :).
Script B:
data:
code_slot: "\"{{ states(\"input_number.lock_user_id\") | int | string }}\""
usercode: "\"{{ states(\"input_number.lock_code\") | int | string }}\""
Nevermind, although Script A above looks like it’s sending a number over to the service call, it seems to actually work. Thanks for the idea to cast the values!