433mhz, infrared IR to and from MQTT on ESP8266

Hi Guys,

I have a motion detector that emits a single signal to indicate motion. In order to handle this situation so that in HASS the sensor doesn’t show motion all the time, I put together the following configuration that turns on a template sensor for 5 seconds, controlled by an input boolean that is hidden in the UI. It works pretty well, but I am wondering if there is a better way to do it?

input_boolean:
  front_door_pir:
    name: 'Front Door pir'
    initial: off
    icon: mdi:motion

binary_sensor:
  - platform: template
    sensors:
      front_door_motion:
       friendly_name: Front Door Motion
       value_template: "{{ states.input_boolean.front_door_pir.state == 'on' }}"
       device_class: motion

automations:
  - id: automration_3_8
    alias: Front Door Motion On
    trigger:
      platform: mqtt
      topic: "home/433toMQTT"
      payload: xxxxxxxxx
    action:
      service: input_boolean.turn_on
      entity_id: input_boolean.front_door_pir

  - id: automration_3_9
    alias: Front Door Motion Off
    trigger:
      platform: state
      entity_id: input_boolean.front_door_pir
      to: 'on'
      for:
        seconds: 5
    action:
      service: input_boolean.turn_off
      entity_id: input_boolean.front_door_pir

Hi, you could try the following:

#Binary sensor
- platform: mqtt
  state_topic: 'home/433toMQTT'
  name: 'PIRx'
  payload_on: 'xxxxxx'
  payload_off: 'xxxxxxoff'
  device_class: motion

#Automation
- alias: Reset PIRx state
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.pirx
      to: 'on'
      for: 
         seconds: 5
  action:
    - service: mqtt.publish
      data:
        topic: "home/433toMQTT"
        payload: "xxxxxxoff"
1 Like

Perfect - much better than what I had - thanks :slight_smile:

For the next enhancements of OpenMQTTGateway I would like to have your advices, here is a poll that will take 30 seconds to fill and that will give us usefull insights:

Is there a tutorial for dummies on this :joy: I’ve got a nodemcu set up on a prototyping board with RF and IR receiver and transmitter according to the schematic. I’ve got it connected to the mqtt broker and set up the gateway connectivity in home assistant, which works. The serial monitor in Arduino IDE shows the IR codes. But it doesn’t show anything when I’ve tried with RF remotes (Nexa and Cotech). Also it doesn’t seem to respond to the switch I’ve set up in Home Assistant with the IR code. I’m having trouble finding out what’s wrong. Anyone else who have struggled with this?

regarding RF are you sure your devices are compatible, to check that you can look to the compatibility list, you can go also to the troubleshooting section of the wiki.
There is also example of home assistant integration in the wiki.

I’ve ordered a remote from the compatible list now to test with so will see when it arrives.

Hello to all,
I´m implementing a arduino rf 433mhs receiver and transmitter to control my switches. I was able with the sketch bellow to push the buttons through serial monitor and it´s working fine all switches are responding to the commands.

My big question is, is it possible to integrate this with hassio? I was looking into your project but I´m no programmer and very noobie in all of this so my skill is very low.

I´m running hassio in a rpi , and my arduino it´s a uno with rf transmitter and receiver, I also have a spare nodemcu but I didn´t test the sketch.

Here bellow find the sketch I´m using. Apreaciate any help:

#include <livolo.h>

byte trport =8;              // port of 433-transmitter
Livolo livolo(trport);        // transmitter connected to pin trport
int onoff = 10;               // data from Serial 
unsigned int ID = 6400;       // ID of Remote - type your own ID/ f.e. 6400; 19303; 10550; 8500; 7400
unsigned int IDB = 0;         // Number of remote's button #1: 0, #2: 96, #3: 120, #4: 24, #5: 80, #6: 48, #7: 108, #8: 12, #9: 72; #10: 40, #OFF: 106
unsigned int SCENE1 = 90;     // Number of scene (available 90, 114, 10, 18)

void setup() {
Serial.begin(9600);  // serial init
}

void loop() {

// Serial reading
// 
if (Serial.available() > 0) 
{
onoff = Serial.read()-48;
Serial.println(onoff); 
}

if (onoff == 1)
{
  livolo.sendButton(ID, IDB);
  Serial.println("Button"); 
  delay (1000);
}

if (onoff == 2)
{
  livolo.sendButton(ID, SCENE1);
  Serial.println("Scene"); 
  delay (1000);
}

if (onoff == 0)
{
  
  livolo.sendButton(ID, 106);
  Serial.println("off"); 
  delay (1000);
}
}

To integrate with Home assistant one possibility is to use MQTT, this is where OpenMQTTGateway comes and can answer your need.
Nevertheless I see on your sketch that you use livolo switches and I don’t know if they are compatible with the RF libraries used by OpenMQTTGateway. Maybe some other users already tested that?

1 Like

Hello tks for the quick reply, how could be one way to connect everything to check if it´s possible to work?

I´ve only seen some people using toghther with mysensor and appdaemon but it´s too much for my knowledge.

1 Like

The simple way maybe is to connect your emitter and receiver directly to the PI and find the associated component of HA

Tks for the reply, it seems that someone have already made something here: Livolo RF433 Switches . Quick question for the rpi with hassio comunicate to arduino should I connect them via usb cable? Or should I have transmitters 433mhz and receivers in both? I couldnt understand in the documents.

You don’t need an arduino, just connect your receiver and emitter to raspberry pi and use something like pilight.
Nevertheless I suggest you to go to a dedicated thread related to this solution as this is not related to OpenMQTTGateway

I am trying to decide RF 433 codes,
But unable to decode
I am using nodemcu V3 by wemos but it’s not lolin

Hmm, did you checked the troubleshooting session of the wiki

In all the case if you don’t succeed after reading it we will need more details to help you

Dear,
I have tried all pins,
but am keeping on trying.
Let me know what details do you require?
thanks for taking time.

I am using wemos nodemcu V3 and for RF 433 generic transmitter and receiver,
I would like to get some suggestion.
Is it ok to use generic RF 433 transmitter and receiver, which is not working.
I am trying to get codes from geekcreit 12v 4ch relay module, but got no success.
Do you suggest any other RF 433 transmitter and receiver to get it work with Geekcreit 12v 4ch module relay?

Please guide/suggest

Product which I have
Nodemcu V3

Esp32

Geekcreit 12v 4ch

RF 433mhz

Hello. Did you add antenna to your emitter and receiver ?
If you checked the troubleshooting section , what are your results from it ?
We need more infos about what is working and what is not working.

When I subscribed to home/OpenMQTTGateway on my mosquito,
It does shows me online,
But when I publish message to home/OpenMQTTGateway I can’t see anything on my nodemcu connected on serial port,
I have led attached to my receiver which blinks faster/reacts when I press button of my remote,
Don’t understand where am I wrong.

could you post what the serial monitor say and what you are publishing?