433toMQTTto433 Bidirectional Arduino Gateway

Hey @Partybug

Can you please explain to me how and which code did you upload to your esp8266 board for mqtt to 433 and 433 to mqtt.

Thanks.

@bachoo786 I have a arduino uno with an ethernet shield. I used the code at https://github.com/1technophile/OpenMQTTGateway
Which I believe works with either board.

Hi thanks for the reply.

I can see many ino files with different codes. I am confused which one to use and download to my esp8266. Like I mentioned before I only need 433 to MQTT and MQTT to 433.

Just the put the files in the same folder, open openmqttgateway.ino and comment the gateways you don t need in user_config.h. Specify your network and broker parameters.
After that upload the code.

2 Likes

@1technophile thanks I successfully installed it and got my RF switches working. However after a few minutes of publishing the code via the correct MQTT topic I get the following error on my rpi:

pi@raspberry:~ $ mosquitto_pub -t home/commands/PLSL_181/433_1/BITS_24 -m 1381692
Connection Refused: not authorised.
Error: The connection was refused. 

I have other things running on MQTT and they all work fine except for this.

Can you please help?

Thanks.

this is can be an authentication error, try adding an username and a password when publishing

You mean when I am publishing? Can you give an example please

Take a look at this user that seemed to have the same issue as you, as you are using an esp8266 please post also to this topic or to the gitter chat instead of the arduino topic

1 Like

Thanks alot buddy all working fine for now. Keep up the hard work !!

I bought a few door/window sensors but they only send one code when open, whats the best approach to get the correct state on Hass?

Change sensor. Use those with open and close codes.

2 Likes

Feared that already! 1,2sh€ each was too good to be true :stuck_out_tongue:

Are good for anything else?

you could use them on everything where you are sure it will be closed within a certain time.
or you could use them as alarm triggers.

they work, but they only have 1 function. and not 2 (alarm when opened, check if closed)

Hi @Sthope,

I’ve encountered the same problem as you. My door sensors only send a code when the door opens and, as I’m not in the habit of going out and leaving the front door open, I don’t really need to know if I’ve closed it.

I think I’ve solved the problem by creating a sensor for the openMQTTgateway itself, then creating a binary template sensor for each RF sensor/code.

Set up an mqtt sensor. The expire_after: resets the sensor to ‘unknown’ after 2 seconds.

sensor:
  - platform: mqtt
    state_topic: 'home/433toMQTT' # openMQTTgateway topic
    name: '433_code' 
    expire_after: 2

Then create a template binary sensor for each RF sensor. Trigger the sensor, then set the number in the value_template: to the code that’s displayed in the sensor.433_code state. The entity_id: line ensure the state is only updated with when the sensor updates.

binary_sensor:
  - platform: template
    sensors:
      door_opened_front:
        entity_id: sensor.433_code
        friendly_name: "Front door"
        value_template: "{{ is_state('sensor.433_code',  '9357902') }}"
        device_class: opening

      door_opened_back:
        entity_id: sensor.433_code
        friendly_name: "Back door"
        value_template: "{{ is_state('sensor.433_code',  '3142734') }}"
        device_class: opening

I will also be taking @masterkenobi’s advice and getting some that have a close signal, as I’m always leaving the house without checking the windows.

If it sends only one code Hass will never have right state with 100% accuracy. I have ordered few new ones that will send a code for open and another from close only then we can have 100% accuracy on the state

You’re right @Sthope, and I certainly need the accurate state for checking if my windows are open before I leave.

I’m using the single-code door sensors as a safety check: If device tracker thinks my phone is away (disconnected from wifi) and the door hasn’t opened recently, I must still be at home. This stops my ‘has left’ automations from turning off the lights when my phone battery dies.

Which sensors did you order? I’m still trying to find out if the MC-03B which also has a handy looking button, will send open and close codes.

if you want 100% accuracy you shouldnt use 433 mhz :wink:
i have a door that closes itself, so then such an approach as @epsylon has would be enough for that.

but i agree that its much more convenient to have a sensor that reports open and close state :wink:

2 Likes

Hello, i think it is more a question of protocol used rather than frequency, rfm69 use 433mhz and has acknowledgment and encryption for example

rfm69 sounds interesting. im wondering what are the compatible ready-made sensors that is using rfm69?

Hello, you can take a look to lowpowerlab (compatible with the gateway) or jeelab (not yet compatible) websites,
https://lowpowerlab.com/shop/category/67
https://www.digitalsmarties.net