Ring Alarm - MQTT Discovery Alarm integration

I’ve seen this topic pop up a few times around the forums so thought I’d mention it here in case there is any interest. I’ve been putzing at this for a month or two and finally have something that sort of works. It’s a semi-functional MQTT alarm setup that integrates with the Ring Alarm system using a fork of a fork of the doorbot repo that I’ve seen referenced here.

Right now it just grabs all of the motion and contact sensors from your Ring system and monitors their status in HA but I’m hoping to improve on it to allow real-time setting of the alarm. Those features (and other interesting stuff) all work in the javascript code in the original repo but I haven’t had the time to integrate them into my mqttAlarm script at present. Be gentle as this is my first time writing javascript and I have not the faintest clue how to convert it into Python as the API integration is far beyond my ability at this point.

7 Likes

An update here for those interested. I’ve pushed a new version to my repo that now monitors the alarm mode (as well as the sensors previously described) and lets you set the alarm mode directly from the sensor that’s created by the MQTT discovery process. I’ve only done some limited testing so far to confirm that it works on a first run and haven’t got it running as a service or anything to know how well it maintains the connection with the Ring servers. But, progress is progress.

3 Likes

Update #2

My latest commits have this to what appear to a functioning state and produces a set of sensors like below. Look at the guidelines on the repo for usage. Let me know if anyone’s interested and I can provide further guidance. I’ve converted my script into a system service on my Hassbian instance and it’s played quite happily with HA so far.

Screenshot%20from%202019-01-05%2020-16-34

3 Likes

I’d love to know how I can integrate this into Hass.io.

I’ve been looking for this exact solution to integrate my Ring Alarm so I’m excited that there is a working solution.

2 Likes

This is fantastic! Stumbled across your Github repo before coming across this post. Any way to reliably get this to automatically load each time Home Assistant comes online? For whatever reason I seem to have to load, then kill, then load the script each time Home Assistant restarts in order to get anything other than an unknown status.

THis is awesome, thank you!!!

How are you getting it to discover devices? I have the script running on another vm, I can see all the mqtt messages coming over when i look at mqtt messages. But it doesnt create devices for me. I have never used the mqtt discovery before, I have my stuff just plugged in. Maybe I need to add that? Ive tried a few combinations like the below, please help this made me really happy after a monday of work:)

mqtt:
broker: xx.xx.xx.xx
port: 1883
discovery: true
discovery_prefix: homeassistant

Ive tried homeassistant - homeassistant/binary_sensor - a lot of differnet things…

Yea I cant get them to discover for anything. I can go around and open each window and door and make my own sensors…that will take forever and I want the functunality of being able to arm/disarm.
Am i missing something to get them to show up?

instead of editing configuration.yaml have you tried just going into the hamburger menu > configuration > integrations and configuring mqtt?

My mqtt configuration looks just like yours:
mqtt:
broker: 192.168.1.XX
port: 1883
discovery: true
discovery_prefix: homeassistant

That said, my setup is one Pi3 running HA and another running the MQTT broker. I’m not sure what else to tell you.

There probably is, but I haven’t gotten that far yet. The one time so far I had to restart HA, I had to do the same thing you did (i.e. kill the service running the Ring script, restart it, kill it, then restart it again) to get the sensor statuses to start showing again. I wonder if it has something to do with the way the MQTT package works in Node. I really don’t know a lot about Node or Javascript so this was painful for me to put together and actually get working.

I have noticed that the mqttAlarm script does seem to disconnect/reconnect to my MQTT broker when I watch the raw script output. I’ll look at maybe having the script restart the alarm status callback when it sees HA restart or come back online. That might solve the issue you’re seeing.

Yeah I even deleted the integration. Removed it from my yaml and then restarted and tried to enable mqtt but it doesn’t find anything.

Gotcha. Thanks for the info. I wasn’t sure if maybe I had something setup incorrectly.

Very much appreciate you putting this together!

alright thanks. so you dont use the integration from the ui either? that in your yaml is detecting the alarm?

Are you able to turn the alarm on and off?

Im gonna make a new vm and install ha with none of my config…enable the integration and see if it finds it…ill let you know.

I just thought of Im on the beta…ill try the stable too.

@Darbos Sorry, I’m not sure what more to tell you other than it sounds like HA isn’t seeing the setup messages. Are you 100% sure that HA is connected to the broker and getting messages?

I’ve got the mqtt setup I posted above in my configuration.yaml and I can both change the alarm mode and see the sensors update status when triggered.

no worries man. I appreciate ya and you sharing your hard work. Ill figure it out.

It is seeing the messages for sure. I when I test with mosquitto_sub -h 127.0.0.1 -v -t “homeassistant/#” i see everything. When it first connects I see all the json out put for each device. I created a couple sensors manually and the status reports perfect…there just not adding automatically for some reason…

I installed a fresh homeassistant with no config files and just enabled the mqtt integration…still did not add them. Ill try moving my mqtt server to another box…I amstill getting updates too…

da@home:~$ mosquitto_sub -h 127.0.0.1 -v -t “home/alarm/connected/#”

home/alarm/connected ON

home/alarm/connected OFF

home/alarm/connected ON

home/alarm/connected OFF

home/alarm/connected ON

home/alarm/connected OFF

home/alarm/connected ONPreformatted text

Alright It found and added all my sensors. I moved my mqtt server but I think what really did it was starting and stopping that script a couple times.

How do you arm/disarm the alarm? I see all my sensors and I got another sensor that is red that is the alarm (pic below) But I dont see how you can change it…

03%20PM

I think I see it…in services. you dont need to put the code in?

On my setup, I just tap that red sensor and it opens to the alarm panel window with arm/disarm options. The code isn’t used in the Ring API as I understand it. This script is accessing the Api the same way as the Ring App so you are already authenticated when you put your credentials in the script.
That said, in your screenshot, it looks like that one sensor thinks its not connected to MQTT, which is odd. The way my script is written, all of the sensors created by the discovery process should either be unavailable together or an have the current status of the ring sensor or alarm mode. I’ll look at the script later today and see if I see anything that would cause that one sensor to get out of sync.