hi all,
I’m struggling with sending ir codes to an zigbee IR-remote control. Using the visual editor I can send ir codes using an pre-defined action. However, I’m not able to send the same code via a variable.
I found some code to send the ir code via MQTT but it doesn’t work either
Please could anyone see quickly what is wrong in the next script. I’m getting desperate.
alias: Denon Remote Control
description: Denon IR Remote Control
triggers:
- trigger: state
entity_id:
- input_boolean.denon_button_switchonoff
conditions: []
actions:
- variables:
test_ir_code_to_send: >-
"CwYBJwMGATcH2gAnA0ADAQYBgAOACwI3BzVgAwInAwYgA8ATQAuAAwnrsAYBJwPaADcHQCNAA0APATUBQA8BNwdAC4ADATcHQA+AA0ATwAsD67A1AYAPAAZgB0ALBScD2gAnA0AHBAYBNwc1YAMBJwPgAQMLNwfaACcD2gAnAwYB"
- data:
topic: zigbee2mqtt/IrRemoteControl_Livingroom/set
payload: >-
{"ir_code_to_send":
"CwYBJwMGATcH2gAnA0ADAQYBgAOACwI3BzVgAwInAwYgA8ATQAuAAwnrsAYBJwPaADcHQCNAA0APATUBQA8BNwdAC4ADATcHQA+AA0ATwAsD67A1AYAPAAZgB0ALBScD2gAnA0AHBAYBNwc1YAMBJwPgAQMLNwfaACcD2gAnAwYB"}
action: mqtt.publish
- data:
topic: zigbee2mqtt/IrRemoteControl_Livingroom/set
payload: >-
{"ir_code_to_send": test_ir_code_to_send}
action: mqtt.publish
mode: single
Yes it is the right code (I copied it from the listening-mode), but it doesn’t show up in the UI as well. Normally, if it works, you will see in the UI of HA or Zigbee2MQTT the last code sent, even if it is wrong.
You’re using a YAML line continuation character >- to indicate the string begins on the next line but you’re still delimiting the string with double-quotes. Those double-quotes become part of the transmitted IR code. They should be removed.
The following line is sending the literal stringtest_ir_code_to_send (not the value of the variable with that name).
Why? Because you need to use a template to indicate that the string test_ir_code_to_send shouldn’t be taken literally but ought to be interpreted as the name of a variable.