433mhz, infrared IR to and from MQTT on ESP8266

You have to use a script to send a message like this


    sequence:
      - service: mqtt.publish
        data_template:
          topic: '/energenie/eTRV/Command/{{command}}/{{id}}'
          payload: 'ON'

Then you have to include the script in a group to be able to see it.

Hello,

I think you could use these examples:

Or this one:

Thanks gpbenton, but without the full configuration im struggling to see where it fits in, sorry

Cheers, Iā€™ll check them out

Whoop, its working now. Below is the configuration.yaml i used in the end:

switch:

  • platform: mqtt
    name: ā€œtvonoffā€
    state_topic: ā€œhome/commands/IR_SAMSUNGā€
    command_topic: ā€œhome/commands/IR_SAMSUNGā€
    payload_on: ā€œ3772793023ā€
    payload_off: ā€œ3772793023ā€
    optimistic: true
    retain: true

Note the spaces are not reflected accurately above as the viewer seems to remove spaces at the start of the line

The switch is added to my default view which is fine for the time being.

Thanks again 1technophile

1 Like

I think you could change that, with the # it will receive all the data coming from the gateway, you could put for example
home/sensors/ir
to restrict to IR data coming

Could I just use

state_topic: ā€œhome/commands/IR_SAMSUNGā€

to return just the IR_SAMSUNG commands, is this suitable?

There is no filtering following the type of protocol received, the state will update if the IR receiver see the value 3772793023.
This value is published by the gateway to the topic home/sensors/ir

This feedback coming from the gateway is used most of the time with RF remote control, by this way when pressing a button on the remote the switch in HA is updated. I donā€™t know if it is usefull for IR. In all the case it is better to donā€™t put home/commands/# as this is a general topic that can receive a lot of information

Iā€™ve remove the state_topic: ā€œhome/commands/#ā€ to limit the streaming and used ā€œhome/commands/IR_SAMSUNGā€ instead.

Iā€™m using MQTTfx to monitor the MQTT traffic, and when I subscribe to ā€œhome/sensors/irā€ i dont get any messages?

I checked through the OpenMQTTGateway code and i couldnt find anything that publishes MQTT on that particular channel (ā€œhome/sensors/irā€), so Im curious how information gets posted on this channel?

The code publish IR data to user defined variable
#define subjectIRtoMQTT "home/sensors/ir"

into the function boolean sendValuebyMQTT()

Have you used the boolean user input to interact with MQTT messages? Iā€™m thinking a slider bar might be nicer to turn on / off the TV?

Hi 1tecnophile

Iā€™ve been reviewing my Serial Monitor in the Arduino IDE, specifically with trace messages around the section of code that does sendValuebyMQTT() on lines 197-201 (Iā€™ve slightly modified your initial code but line numbers should be close).

Iā€™m only using the IR components but the irrecv.decode(&results)) in my situation is always returning 0 (false) so the code never drops into this if statement to publish the boolean result to the ā€œhome/sensons/irā€ MQTT feed? Not sure why my irrecv message is always returning false? My HA build successfully turns on and off the tv now which is great so I know the build is successful.

if (mySwitch.available() || irrecv.decode(&results)) {
  trc("Sending MQTT message back out with decoded result");
  boolean result = sendValuebyMQTT();
  if(result)
    trc(F("value successfully sent by MQTT"));

Below is my Arduino IDE serial monitor output:
Hey I got a callback
Receiving data by MQTT
home/commands/IR_SAMSUNG
Acknowedgement of reception published
Callback value
3772793023
Converted value to unsigned long
3772793023
Hey I got a callback
Not processing this callback contains $subjectAck

It should go into this code when you send ir signal with your remote control in the direction of the IR receiver connected to pin D4 of your nodemcu. If it is not the case myabe itā€™s a problem with the wiring of the IR receiver.

So there is not meant to be a MQTT message sent to ā€œhome/sensons/irā€ when an IR signal is passed from the IR diode to turn on a device (e.g. Samsung TV)?

it depends where your ir receiver is placed :wink: but I agree it is more difficult to implement an updated switch with IR signals than RF signals due to the directional characteristic of IR

@1technophile I assume i setup the mqtt433 bridge correctly ā€¦As I receive codes from my 433 hand senderā€™s ā€¦ unfortunately the bridge doesnā€™t recognise all buttons. I guess this is very hardware depended? I found one type of hand sender recognising all least button a and b ā€¦Is there a hand sender working 100% with your bridge or can i do something to make other hand senderā€™s 100% working ?

Hello,

If I understand well on one RF remote control you have button reconized by the gateway and other not?
or depending on the remote control all the button are not recognised or all are recognised?

If itā€™s a cheap remote from aliexpress (like that: http://s.aliexpress.com/UVfIrqAB ), when I received mine, one button emitted RF code, the other button still needed to be programmed (they can learn RF code).
Iā€™ve used the RF bridged to program RF code in the remote.

Absolutelyā€¦some remotes just donā€™t work ā€¦With some remotes just two buttons work. How can i train or add the code tth bridge?

Do you have some pictures of these remotes and the model?