Honeywell 5800 series 345Mhz door and window sensor integration with HA

First, thank you for this. I thought my RTL-SDR dongle was going to be useless after discovering that I can’t successfully capture packets from my smart meter from Duke Energy. This pot revives it for me.

However, I do have a question. How are you getting your command to run? Specifically, I don’t want to have to enter this command in every time. I created a service in systemd and made sure it would autostart at boot. Unfortunately, it looks like the rtl_433 runs, but it doesn’t add the mosquitto part to it.

Any insight?

1 Like

Hrm… Well for testing, I usually only had to run it once on the RTL vm and then it just chooched without issue. If it crashes and says user cancellation after you open a door then there’s an error in your mosquitto_pub command. As for auto-starting it, I’d probably dump that command line into a shell script and set that script to autostart instead of just the command line. I’m not sure if you can pipe stdout of commands when using systemd for autoexec. creating a shell script and the associated handling code in rc.local is probably the easiest way rather than using systemd. But I’m a n00b according to my friends so what do I know?

Let me know what you find out. I’m soon going to be putting this into production on an AIO RPi installation so I, too, would like to know the best way to keep it chooching proper.

I ran a script through rc.local on my Pi. Wasn’t an easy task at first because I couldn’t get it to also execute the “|” in the script at first, and then after messing around with it, I got it to autostart. I’ll past my findings when I get home.

I tried using systemd to autostart it as well and got confused. I think it’s in /etc/rc.local and then there is a .sh file I created to execute.

Another thing you can do in your shell script is a do while true block to handle when the rtl crap the bed and dies out it just restarts again. Currently, I’m just running the script with nohup ./rtlstartup.sh & which seems to work rather well.

FYI, this doesn’t work well on the RPi because of interference from the Zstick. Everything installs and runs but the radio doesn’t receive crap.

Just throwing this out here for those people use Docker, this docker image works perfectly

https://hub.docker.com/r/roflmao/rtl2mqtt/

Chris

1 Like

I just thought I’d post this here to see if anyone else has experienced and solved this particular issue. I have a range of Honeywell sensors that I am capturing packets from (contact sensors for doors, motion sensors, and a smoke detector).

I’m getting a real hit and miss with the sensors and it’s starting to look like there is a missing piece to the puzzle. Two of the four contact sensors work perfectly, but two work at first and then stop working. Likewise, one of my two motion sensors work great!

All of the sensors have brand new batteries – so that’s not it.

It seems to me like some versions of the sensors might need to be “poked” into transmitting? I’ve read elsewhere that, in an effort to conserve battery life, the motion sensors for example won’t “turn on” until they receive a command indicating the house has been put in “away” mode (to avoid unnecessary transmissions of state when they aren’t normally needed). This obviously doesn’t make sense in a home automation situation – does anyone have a clue what might be going on?

John

I have seen the same thing too. It’s REALLY frustrating, and I haven’t been able to resolve it. That said, I found this:

https://products.z-wavealliance.org/products/1173

This actually works with the Honeywell 5800 series sensors, and translates them to Z-wave. I just ordered it, and I think it will work (provided the command classes are there).

Chris

Could this be used to control 315mhz gear too?

That is the bomb! I switched out for Zwave sensors since I wrote this. MUCH easier and more consistent. Just cost that sweet sweet green.

Good info here, thank you!

In implementing my own solution to utilize these sensors, I’ve made it to the point that I want to implement an actual sensor component for this device under custom_components (https://home-assistant.io/developers/platform_example_sensor/). The value_template method offers little ability to handle all the bit conditions that could be present (battery low and state on, for example), and there’s a lot of boilerplate code that could be done once for a home full of honeywell sensors instead of cut-and-paste to each instance (with all the bugs that arise from a cut-and-paste coding style).

Does anyone have a custom_components implementation? Or any advice on creating one? If not, I’m going to work on creating one to use myself as well as share.

Has anyone gotten a “signal caught, exiting now” code? I put fresh batteries in my honeywell sensors and it seems to quit responding after an unknown amount of time.

I know there was a comment about sending a signal to keep the honeywell sensors awake, was that true? and was that resolved?

I am having an issue waking the devices up. I have probably close to 10 devices on different doors and windows, but whenever I reboot HA the device state returns to unknown. I have to then open/close the window or door for the device to register with the proper open or closed state. Once I have all the sensors up and running I don’t want to have to manually wake all of them up every time I reboot. The device will be fine until the raspberry pi is rebooted… Please any help would be awesome!!

back

@brakow87 My RTL-SDR is supposed to be arriving today. I think I have an idea on how to solve this problem. My MVP would be a program that caches the rtl events, keeping a last_seen_event for each of the devices. Then, on an interval, it would rebroadcast those to the mqtt topic.

I think a fancier solution, which I may look into after getting the above to work, would be to make this program/service also consume the HA mqtt event stream and listen for some sort of event signal HA is starting back up (I’m new to HA, I’m assuming this exists). On that event, it’d send the last seen events for each of the components.

Edit: Now that I think of it, if HA restarts or goes away then the mqtt connection would be lost. So that itself would be an indicator to resend all of the last seen events, once the mqtt event stream comes back up.

Having a difficult time getting my service to start automatically. I can get it to start, however, after a trigger or time (not sure which yet), the service comes up with an exit code. Here’s my service file:

[Unit]
After=network.target

[Service]
Type=simple
ExecStart=/bin/bash /home/pi/433Mhz_auto.sh
User=pi
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

Here’s the error I’m getting:

pi@hassbian:/etc/systemd/system $ sudo systemctl status rtlsdr
● rtlsdr.service
Loaded: loaded (/etc/systemd/system/rtlsdr.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2018-06-17 11:50:18 EDT; 18s ago
Main PID: 11581 (code=exited, status=127)
Jun 17 11:49:34 hassbian bash[11581]: Exact sample rate is: 250000.000414 Hz
Jun 17 11:49:35 hassbian bash[11581]: [R82XX] PLL not locked!
Jun 17 11:49:35 hassbian bash[11581]: Sample rate set to 250000.
Jun 17 11:49:35 hassbian bash[11581]: Bit detection level set to 0 (Auto).
Jun 17 11:49:35 hassbian bash[11581]: Tuner gain set to Auto.
Jun 17 11:49:35 hassbian bash[11581]: Reading samples in async mode…
Jun 17 11:49:35 hassbian bash[11581]: Tuned to 344975000 Hz.
Jun 17 11:50:18 hassbian systemd[1]: rtlsdr.service: Main process exited, code=exited, status=127/n/a
Jun 17 11:50:18 hassbian systemd[1]: rtlsdr.service: Unit entered failed state.
Jun 17 11:50:18 hassbian systemd[1]: rtlsdr.service: Failed with result ‘exit-code’.

However, if I run the bash script manually:

rtl_433 -f 344975000 -F json -U | mosquitto_pub -t homeassistant/sensor/honeywell -l -V mqttv311

it gives me this:

mosquitto_pub: command not found
[R82XX] PLL not locked!
rtlsdr_demon_write_reg failed with -9
r82xx_write: i2c wr failed=-9 reg=06 len=1

It does show that PLL is not locked

EDIT: Fixed. For some reason after I had to do a reinstall of my entire system (MicroSD failure), I forgot to install mosquitto_clients:

sudo apt-get install mosquitto-clients

then, edited my .sh file, took off the -v mqttv311 and added:

-u username -P password

after mosquitto_pub. Reloaded daemons, restarted, tested, and now my doors are showing in HASS again! horray!

Not much of a coder but her is the python script I use to periodically send updates (debug junk still present). I pipe rtl_433 to this script instead of directly to mosquitto_pub.

#!/usr/bin/env python3

import sys, os
import json
import signal
import threading
import time

HOST_NAME = "host"
PORT = 1883
CA = "/etc/ssl/certs/ca-certificates.crt"
USERNAME = "user"
PASSWORD = "password"
BASE_TOPIC = "base/topic"
PUBLISH_RATE = 120

_sensors = {}
_debug = False
_running = True

def publish(id, value):
    try:
        #Ignore mqtt errors and timeouts
        if (PORT == 1883):
            #Normal
            runCMD = 'mosquitto_pub -h {} -p {} -u {} -P {} -t {}/{} -m {}'.format(HOST_NAME, PORT, USERNAME, PASSWORD, BASE_TOPIC, id, value)
        else:
            #SSL
            runCMD = 'mosquitto_pub -h {} -p {} --cafile {} -u {} -P {} -t {}/{} -m {}'.format(HOST_NAME, PORT, CA, USERNAME, PASSWORD, BASE_TOPIC, id, value)
        debug_out(runCMD)
        #Using os to avoid setting up client
        os.system(runCMD)
    except:
        pass

def publish_thread():
    loop_timer = 0
    while _running:
        time.sleep(1)
        #Use loop timer so thread kill happens within 1 second
        loop_timer += 1
        if (loop_timer >= PUBLISH_RATE):
            loop_timer = 0
            debug_out("PUBLISH")
            #Publish last values periodicly
            for key, value in _sensors.items():
                publish(key, value)  

def debug_out(message):
    if _debug:
        print(message)

def set_exit_handler(func):
    signal.signal(signal.SIGTERM, func)

def on_exit(sig, func=None):
    global _running
    debug_out("EXIT")
    #Kill thread
    _running = False            
    sys.exit(0)

if __name__ == '__main__':
    debug_out("Started mqtt")
    set_exit_handler(on_exit)
    #Start periodic publish thread
    thread = threading.Thread(target=publish_thread)
    thread.start()
    for line in sys.stdin:
        #Have line from rtl_433
        try:
            #Throw error if something not valid
            data = json.loads(line)
            sensor_id = data['id']
            sensor_event = data['event']
            #Save and publish only once - sensors repeat themselves
            if (sensor_id in _sensors):
                if (_sensors[sensor_id] != sensor_event):
                    debug_out("CHANGE")
                    publish(sensor_id, sensor_event)
                    _sensors[sensor_id] = sensor_event
            else:
                debug_out("NEW")
                publish(sensor_id, sensor_event)
                _sensors[sensor_id] = sensor_event                
        except (KeyboardInterrupt) as error: # Ctrl-C
            debug_out("STOP")
            #Kill thread
            _running = False            
            break;
        except (SystemExit) as error: # sys.exit()
            debug_out("STOP")
            #Kill thread
            _running = False            
            break;
        except (Exception) as error:
            debug_out("ERROR")
            #Ignore and keep going
            pass
    debug_out("END")
1 Like

I just came across this today, and wanted to thank @Vexamus for it. I have an Andersen Verilock sensor on my sliding door and had it reporting through the Andersen Translator that I could only get working with z-wave on my old smartthings. It was the last remaining thing I needed to move over. The Verilocks show up as honeywell sensors, and the evernts/states show the lock and opening status. So know with an RTL usb stick and a pi-zero I have this working and going right into HA without a need for the translator and z-wave/smartthings!

I set it up like this:

- platform: mqtt
  state_topic: "homeassistant/sensor/honeywell"
  name: "Sliding Door"
  qos: 0
  value_template: '{% if value_json.id is equalto 591203 %} {{value_json.state}} {% else %} {{states.sensor.sliding_door.state}} {% endif %}'
 
- platform: mqtt
  state_topic: "homeassistant/sensor/honeywell"
  name: "Sliding Door Lock"
  qos: 0
  value_template: '{% if (value_json.id is equalto 591203) and (value_json.event is equalto 32) %} unlocked {% elif (value_json.id is equalto 591203) and (value_json.event is equalto 0) %} locked {% else %} {{states.sensor.sliding_door_lock.state}} {% endif %}'
2 Likes

Thanks for pointing me towards this docker image.

I tweaked it a little to allow for each sensor to have it’s own MQTT topic and persistent states.

I added ‘jq’ to the Docker file build and added $USER and $PASS environment variables.

I also configured my docker run command to restart=unless-stopped

Here’s the content of my rtl2mqtt.sh file

rtl_433 -f 344975000 -F json -M utc | while read line
do
  sensor_id=`echo $line |  jq -c ".id"`
  sensor_data=`echo "$line"`
  
  echo $sensor_id
  echo $sensor_data
  #send sensor data to unique MQTT topic by sensor ID. MQTT debug on '-d'
  echo $sensor_data | mosquitto_pub -h $MQTT_HOST -p 1883 -i RTL_433 -l -t honeywell/sensor/$sensor_id -u $USER -P $PASS -d

done

Chris, were you able to integrate the Anderson Translator with one of the door/window sensors to communicate with Home Assistant’s z-wave integration? I’m thinking about ordering the Verilock and the Translator.

Would this only work with Honeywell 345mhz devices? Or can it work with other 345mhz devices (like vivint’s stuff)?

If you look at the GitHub page, it shows all compatible sensors.it doesn’t look like Vivint is there but you can probably check who supplies vivint their sensors. https://github.com/merbanan/rtl_433