IR code verzenden met MQTT via een knop
Ik ga er van uit dat je een werkende IR receiver/zender hebt, bijvoorbeeld deze Tasmota
En je hebt Home Assistant. Nu gaan we IR code verzenden!
Tasmota
Ga als eerste naar de Tasmota url en ga naar de console. Gebruik wel de IR versie van Tasmota, dan kun je meer codes verzenden.
Pak een afstandsbediening, bijvoorbeeld die van je radio en duw op een knop. Ik duw bijvoorbeeld op het cijfer “1” van mijn oude Onkyo receiver TX-SR508.
In de console zal iets verschijnen zoals
08:07:27.316 MQT: tele/tasmota_XXXXXX/RESULT = ‘{“Protocol”:”NEC”,”Bits”:32,”Data”:”0x4B40AB54″,”DataLSB”:”0xD202D52A”,”Repeat”:0}’
Het dikgedrukte hebt je nodig.
Home Assistant
Ga naar Home Assistant en maak op je gewenste plaatst een knop aan.
Tikactie wordt: service aanroepen
Service wordt: MQTT.publish
Topic is: cmnd/tasmota_XXXXXX/IRsend *je eigen Tasmota apparaat
Payload: {“IrReceived”:{“Protocol”:”NEC”,”Bits”:32,”Data”:”0x4B40AB54″,”DataLSB”:”0xD202D52A”,”Repeat”:0}}
Sla op.
type: button
icon: mdi:numeric-1
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: ‘{"Protocol":"NEC","Bits":32,"Data":"0x4B40AB54","DataLSB":"0xD202D52A","Repeat":0}’
target: {}
show_name: false

Klik erop en de IR code wordt verzonden.
Als het goed is staat in het Tasmota Console nu: 08:14:27.664 MQT: stat/tasmota_XXXXXX/RESULT = {“IRSend”:”Done”}
Zo kun je je domme radio op afstand met IR bedienen, of je TV, of een ventilator met afstandsbediening en zo verder!
Mijn volledige LoveLace code met IR codes
type: horizontal-stack
cards:
- type: vertical-stack
cards:
- show_name: true
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B350BF4}'
target: {}
name: tv/movie
icon: mdi:television-ambient-light
- show_name: false
show_icon: true
type: button
icon: mdi:numeric-1
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: >-
{"Protocol":"NEC","Bits":32,"Data":"0x4B40AB54","DataLSB":"0xD202D52A","Repeat":0}
target: {}
- type: button
icon: mdi:numeric-4
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B401BE4}'
target: {}
show_name: false
- type: button
icon: mdi:numeric-7
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B40DB24}'
target: {}
show_name: false
- type: button
icon: mdi:numeric-10-box-multiple-outline
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4BB6A956}'
target: {}
show_name: false
- type: vertical-stack
cards:
- show_name: true
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: >-
{"Protocol":"NEC","Bits":32,"Data":0x4B358B74,"DataLSB":"0xD2ACD12E"}
target: {}
name: music
icon: mdi:music
- type: button
icon: mdi:numeric-2
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B406B94}'
target: {}
show_name: false
- type: button
icon: mdi:numeric-5
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B409B64}'
target: {}
show_name: false
- type: button
icon: mdi:numeric-8
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B403BC4}'
target: {}
show_name: false
- type: button
icon: mdi:numeric-0
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B407B84}'
target: {}
show_name: false
- type: vertical-stack
cards:
- show_name: true
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: >-
{"Protocol":"NEC","Bits":32,"Data":"0x4B354BB4","DataLSB":"0xD2ACD22D"}
target: {}
name: game
icon: mdi:gamepad-outline
- type: button
icon: mdi:numeric-3
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B40EB14}'
target: {}
show_name: false
- type: button
icon: mdi:numeric-6
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B405BA4}'
target: {}
show_name: false
- type: button
icon: mdi:numeric-9
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B40BB44}'
target: {}
show_name: false
- show_name: true
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4BB6A05F}'
target: {}
name: receiver
icon: mdi:led-variant-on
- type: vertical-stack
cards:
- show_name: true
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: >-
{"Protocol":"NEC","Bits":32,"Data":"0x4B3632CD","DataLSB":"0xD26C4CB3"}
target: {}
name: stereo
icon: mdi:surround-sound
- show_name: false
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: >-
{"Protocol":"NEC","Bits":32,"Data":"0x4BB640BF","DataLSB":"0xD26D02FD"}
target: {}
name: stereo
icon: mdi:volume-plus
- show_name: false
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: >-
{"Protocol":"NEC","Bits":32,"Data":"0x4BB6C03F","DataLSB":"0xD26D03FC"}
target: {}
icon: mdi:volume-minus
- show_name: false
show_icon: true
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: >-
{"Protocol":"NEC","Bits":32,"Data":"0x4BB6A05F","DataLSB":"0xD26D05FA"}
target: {}
icon: mdi:volume-mute
- show_name: true
show_icon: false
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B3551AE}'
target: {}
name: Port
- show_name: true
show_icon: false
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4BB6F00F}'
target: {}
name: VCR/DVR
- show_name: true
show_icon: false
type: button
icon_height: 50px
tap_action:
action: call-service
service: mqtt.publish
data:
topic: cmnd/tasmota_167EAE/IRsend
payload: '{"Protocol":"NEC","Bits":32,"Data":0x4B3631CE}'
target: {}
name: BD/DVD
Maak je domme radio nog slimmer met deze AudioCast en Radio Browser.
Een nog mooiere LoveLance
Laat weten of het je is gelukt! Domoticz klik hier
