Hi everyone! I’ve been crashing my way through Home Assistant and feel like I’ve made reasonably good progress but now I’ve come to a halt grinding halt with MQTT and getting commands to devices.
I have an IR bridge (Genio brand) that I have converted to Tasmota via OTA. I can see IR commands it receives in the Tasmota console interface and I can use the HA MQTT interface to publish commands to the device. Most importantly, I can see the published commands appear in the Tasmota Console - so I know HA and the IR Bridge are talking.
Where I am stuck is joining the dots to make a card in Lovelace to send the IR commands to MQTT to then pass to my devices.
Below shows the command being published, and then the second image is the successful processing of the command in the IR bridge.
Where the topic is cmnd/ir_bridge_mbr/IrSend and the payload is {“Protocol”:“NEC”,“Bits”:32,“Data”:“0x4EBB926D”,“DataLSB”:“0x72DD49B6”,“Repeat”:0}} can someone enlighten me on how to create a button in Lovelace to execute this command?
From what I can work out it seems to relate to creating a script and also something in my configuration.yaml file but I just can’t seem to get it working.
You’d be better using a script, no on or off state to worry about then.
It sounds a bit like you’ve dived straight into the deep end, if so I’d suggest you go back to basics and understand how automations and scripts etc work by trying some of the examples, will make your life much easier going forward.
Appreciate that, but hence the reason I’m looking for some help to join the last of the dots. I’ve got to a point where I can flash a device and get it to talk with HA and now I can get it to talk with a switch, but I need to understand how to get the switch to turn off once pressed. When I read into scripts I feel like I’m going in to circles. If there is a known primer that is good, outside of the official manual, then I’d love to be pointed in the right direction. And I know it’s a stretch but with what I’ve provided if anyone can help with the last parts of the code required I feel like it’s going to unlock quite the puzzle for me.
The off part would be the exact same data if the IR is a toggle switch. Toggles will not show on / off graphics correctly in HA, but it won’t matter since it’s sending the exact same command.
(as note, devices will often have separate power codes even if the button isn’t physically present on the remote. Some may even have features you didn’t know about. You can use a cell phone IR app to see if compatible remotes exist, try different models from the same manufacturer)
And I’m sorry if I wasn’t being clear, but a Button is specific type of element in HA speak. I meant the word to be used in more generic sense … it’s a graphic you click on
- platform: mqtt
name: "TV"
command_topic: "cmnd/ir_bridge_mbr/irsend"
optimistic: true
payload_on: '{"Protocol":"NEC","Bits":32,"Data":"0x4EBB926D","DataLSB":"0x72DD49B6","Repeat":0}'
#//Next Line is off, change as needed.
payload_off: '{"Protocol":"NEC","Bits":32,"Data":"0x4EBB926D","DataLSB":"0x72DD49B6","Repeat":0}'
The button card is the best way to go but again with a script not a switch to avoid the unecessary ‘off’ shenanigans. There’s an example of how to use it with a script at the bottom of the page @Holdestmade linked to.
As regards the script itself you just need to insert the data you’ve already written into one of the examples, that’s how we all learnt.
Another tip, when replying to a specific post, click the ‘reply’ button in that post or the person your responding to won’t know you have
Erm…you might want to learn to use search as well…
Thank you all for your help and advice - really appreciate it!
For anyone who is looking for this in the future, well hopefully this is suitable for what yo need! What is below is working, although probably the longhand way of doing it.
In my configuration.yaml I have my switches set up like below, one for each button on the remote:
@Bobby_Nobble I had searched, for hours on end but I couldn’t make the link between where I was to where I needed to be. That said I have tried to share my end result here to help others who may get stuck in the same spot. Thanks again for your help though!
@chris14 great call on looking up discreet codes, I recall hunting those down back in the day and hopefully for my TV they exist. It is a budget model so I’m not holding much hope that they exist, but it’s really only for the source inputs where they would be handy. For everything else it’s pretty straight forward as the button is a singular function button. Thanks again!
No problem but you’re still using that switch which is especially pointless given you’re using a script now anyway. If you follow that post I linked to it has a script exactly how you need it, just slot your data in.
Another little tip which should save you some headaches when searching next time, use Google and just stick home assistant at the front of the search, is far better at finding what you want than the forum search. I just stuck ‘home assistant script to send mqtt’ in and that was the first result