Hello All,
Posting this as a last straw before I go to bed and dream about the hair I wish I still had after I’ve just pulled out of my head trying to figure this issue out. I have mqtt publish commands set up pretty well for simple strings but I am trying to send a more complex one as a POC for an IR Blaster I have.
I captured the IR code to turn off the TV easy enough. I run the following command just perfectly from the console of the Tasmota-IR flashed device:
IRSend {"Protocol":"SAMSUNG","Bits":32,"Data":"0xE0E040BF","DataLSB":"0x070702FD","Repeat":0}
My console output is this:
15:29:38 CMD: IRSend {"Protocol":"SAMSUNG","Bits":32,"Data":"0xE0E040BF","DataLSB":"0x070702FD","Repeat":0}
15:29:38 MQT: stat/mirgen_ir_livingroom/RESULT = {"IRSend":"Done"}
TV turns off - perfect.
However, I cannot for the life of me find how to turn that into a script that I can call in HA. My latest effort (which does not work) is this:
data:
payload: >-
{"Protocol":"SAMSUNG", "Bits":32, "Data":"0xE0E040BF",
"DataLSB":"0x070702FD", "Repeat":0}
topic: tele/mirgen_ir_livingroom/IRSend
service: mqtt.publish
Would someone please mind casting an eye over this to see what I might be doing wrong?
I appreciate the time in advance.
francisp
(Francis)
May 17, 2020, 2:56pm
2
action:
- data:
payload: '{"Protocol":"SAMSUNG", "Bits":32, "Data":"0xE0E040BF", "DataLSB":"0x070702FD", "Repeat":0}'
topic: cmnd/mirgen_ir_livingroom/IRsend
service: mqtt.publish
brad3838
(Brad)
August 27, 2020, 8:09am
3
Hello,
I know this was from a few months ago. I’m having the exact same issue. Did the code provided by francisp solve this issue?
Just confirming I should place this code was placed under scripts.yaml?
Thanks,
Brad
From the docs ,
payload
must be a string. If you want to send JSON then you need to format/escape it properly. Like:
topic: home-assistant/light/1/state
payload: "{\"Status\":\"off\", \"Data\":\"something\"}"
francisp
(Francis)
August 27, 2020, 10:47am
5
I don’t think Tasmota needs a json, for me it works fine the way I posted some messages above.
brad3838
(Brad)
August 19, 2021, 2:05am
6
Hello,
Just follwoing up on what I ended up putting into the scripts.yaml file.
Here are some samples below.
lounge_tv_off:
alias: Lounge TV Off
mode: single
sequence:
- data_template:
payload: '{"Protocol":"PANASONIC","Bits":48,"Data":"0x40040100FCFD","DataLSB":"0x022080003FBF","Repeat":3}'
topic: cmnd/IR-Lounge/IRsend
service: mqtt.publish
lounge_tv_on:
alias: Lounge TV On
mode: single
sequence:
- data_template:
payload: '{"Protocol":"PANASONIC","Bits":48,"Data":"0x400401007C7D","DataLSB":"0x022080003EBE","Repeat":3}'
topic: cmnd/IR-Lounge/IRsend
service: mqtt.publish
lounge_tv_mute:
alias: Lounge TV Mute
mode: single
sequence:
- data_template:
payload: '{"Protocol":"PANASONIC","Bits":48,"Data":"0x400401004C4D","DataLSB":"0x0220800032B2","Repeat":0}'
topic: cmnd/IR-Lounge/IRsend
service: mqtt.publish
1 Like
danioj
August 21, 2021, 6:29am
7
Nice write up. Thanks for following up. Mine ended up similar.