Ring Device integration via MQTT w/ Video Streaming

why would i not want to retain my mqtt messages? set retrain: true in my mqtt config

The retain setting in HA’s MQTT option is only going to change whether messages from HA to MQTT are retained, it would have no impact on whether messages from the ring-alarm-mqtt script are retained by MQTT.

I intentionally designed the script not to require any retain messages because I did not want stale data. The problem with retaining state data is that there’s no practical way to tell if the data is stale or not. For example, if the script published state messages with retain, it could be completely not working (for example fail to start due to server down), and yet HA would still show the old status for these devices. I did not want this, I wanted to make sure that the state data in HA represented the actual state of the device at all times and I preferred the device to have no/unknown state vs an inaccurate representation of state, that let me know I needed to determine what is wrong.

Also, publishing configuration data with retain status would mean that devices might be configured even if the script didn’t actually properly discover them. It makes situations like removing/readding a device much more complex to deal with so I made the conscious decision to design the script without requiring any retained state at all.

Can you please share what specific issue you are trying to resolve? Are you still having an issue with missing devices after HA restart? If that’s the problem, we should really work on resolving that as there’s no reason the current script should not be updating state after a HA restart. Of course, there could be a bug in the script that I haven’t discovered, but I’d be happy to work with you on resolving that issue which would improve the script for everyone. If you’d like you can open an issue on the Github page and we can work it there.

I wanted to create a template sensor to let me know if ring alarm in home assistant was down or running. I was able to do it when using the retrain true function was set to true

I have this and it works when its not available, but how would i modify it if it doesn’t exist?

  - platform: template
    sensors:
      mqtt_ring_alarm2:
        friendly_name: "Ring Alarm MQTT Service"
        value_template: "{% if is_state('alarm_control_panel.ring_alarm', 'unavailable') %}off{% else %}on{% endif %}"

is there a way to use this sensor if the entity doesn’t exist at all?

Awesome to see that others are getting this up and running successfully. No matter what I do, I cannot seem to make any of this work with the add-on. I have followed all of the examples in this thread, but only get the output below in the logs. I had thought that maybe a connection was not being made out to Ring’s servers, but looking at my firewall I do see a connection being made. Any ideas?

Ring Alarm Integration
Node Version
v10.14.2
NPM Version
6.4.1
git version 2.20.1
added 121 packages from 86 contributors and audited 406 packages in 60.673s
found 0 vulnerabilities

No output comes after this. No mqtt messages, though I have verified that I can subscribe and post.

I don’t currently own a Ring alarm system, but am considering it. My interest is influenced by options for integrating with other systems, so I’ve been on a search of sorts. I’ve read through the homebridge code, and looked over much of the info here (not much the code yet). If I’m reading right, there isn’t currently a way to get a notification when ring alarm is armed or disarmed on the Ring side (by user) back to HA. Is that correct?

Thanks for all the work on this!

This integration absolutely shows the proper alarm state in HA, that’s pretty much the entire point. The service sends MQTT messages on any state change of a sensor or alarm arm state and these are represented in the HA UI and you can trigger automations/notifications or anything you want.

Great! My confusion started w/ some posts on the homeBridge site, where some users were discussing HomeKit not updating if a user armed/disarmed Ring from the keypad. The description of functionality in the ring-alarm-mqtt “features” section lists “Arm/Disarm via alarm control panel MQTT object”, but I took that to mean one-way arm/disarm from HA to Ring.

The next question has to do w/ the way Ring excludes “faulted” sensors when arming. Per their info, arming w/ a faulted sensor (e.g., door open) must be confirmed by user and, if approved, bypassed for that arm cycle. What happens if you arm via MQTT w/ a faulted sensor?

I’m only using the ring-api component from the homebridge code so I don’t really have the same behaviors as homebridge. That being said, if you’re looking to interface to Homekit, I think it’s safe to say the homebridge code is better.

Regarding the faulted sensors, today it’s not possible to arm the alarm from Home Assistant if there is a faulted sensor. In the backend I believe I could implement it (it’s possible to arm with bypassed sensors via the API for sure), however, based on what I can tell, while I see some support for arm_custom_bypass in the alarm control panel platform, the MQTT alarm control panel component does not support this so I don’t have any way to implement it on the HA side as I’m limited to what can be done via MQTT.

If it’s the desired behavior I could probably code it up so that it would simply automatically bypass any faulted zones and, potentially, report any bypassed zones as an additional JSON attribute on the alarm control panel, but today I believe it will just fail to arm from HA if any zone is not secure.

I do have plans to support this in a future version, but coding on enhancements is currently stalled as I don’t have time to work on this project for the next few months and it’s already achieved (and surpassed) my initial goals.

1 Like

I skimmed over the js code and have a feel for what’s happening now. I’m new to HA, but if I decide to give Ring a try, I’ll play w/ adding “auto-bypass” functionality. Since HA doesn’t explicitly support it, a direct way may be to always force-arm with faulted sensors. Ideally, I’d like another “watcher” routine for “if a faulted sensor closed by the time arm actually enabled (after countdown), then re-arm with sensor included”. That’s how I’d expect Ring to handle it internally to allow a person to arm w/ a door open and close on the way out… but it doesn’t, if I understand correctly.

Thanks again for all the work, and certainly understand priorities vs something like this.

This is somewhat similar to how the existing script works already, just a little more crude. By default, any arm/disarm attempt is retried up to 12 times, once every 10 seconds. During arming, if any sensor is faulted, the base station will speak a message to the effect of “Sensors require bypass”, but if the sensor clears during those two minutes, the arming process will complete during the retry.

My initial thought was to make this tunable in the configuration, allow configuring how many retries and how long between and also provide an failback option that, if the sensors don’t clear in that time, arm and bypass any faulted sensor.

I have some significant changes I want to make to the script. Modularize it and fix a few bugs. I want to add a generic “faulted” property to each object to simplify the logic for detecting changes and get rid of all the ugly case statements. Basically, this was my first ever Javascript code and it was a learning process, and there are so many things I would do differently if I started over. Regardless it’s been running stable for months on my setup so I can’t be too upset over it. Hopefully I’ll get some time over the summer months to refactor it.

Hello,
I am new user of HA and my question regards Ring Alarm integration via MQTT.
I followed your instructions:
I run
cd ring-alarm-mqtt
then
chmod +x ring-alarm-mqtt.js

after this I could not run

npm install

I would appreciate your help.

Thanks

you need nodejs installed my friend. google how to install nodejs on your platform with the nodejs install script. i used v8.x on ubuntu 1604. i goofed and installed nodejs from ubuntu repository which didnt work (v4).

edit your config.json file also.

after that run in debug mode to make sure you can see some output with error. For me, i didnt realize i fat finger a username until i saw the output.

DEBUG=* ./ring-alarm-mqtt.js

Wow what a great project!
Sorry if i am being dense here but for the life of me cant get Ha to find any devices when manually adding to configuration.yaml.
The debug shows mqtt connected and getting correct ring status info but never makes it to HA. When i add it through integrations mqtt gui the device sensors show up. Another person had same issue and eventually got it without knowing how.

Can anyone see a problem with my configuration.yaml? Thank you!

mqtt:
  broker: 127.0.0.1
  discovery: true
  discovery_prefix: homeassistant
  birth_message:
    topic: 'hass/status'
    payload: 'online'
    qos: 0
    retain: false
  will_message:
    topic: 'hass/status'
    payload: 'offline'

{
  "logins": [
    {
      "username": "user",
      "password": "pass"
    }
  ],
  "anonymous": false,
  "quiet_logs": true,
  "customize": {
    "active": false,
    "folder": "mosquitto"
  },
  "certfile": "fullchain.pem",
  "keyfile": "privkey.pem"
}

{
    "host": "192.168.3.111",
    "port": 1883,
    "ring_topic": "ring",
    "hass_topic": "hass/status",
    "mqtt_user": "user",
    "mqtt_pass": "pass",
    "ring_user": "[email protected]"
    "ring_pass": "password"
}

i seem to have progress. what worked to get it talking was adding username/password under mqtt in configuration.yml

mqtt:
  broker: 127.0.0.1
  username: user
  password: pass
  discovery: true
  discovery_prefix: homeassistant
  birth_message:
    topic: 'hass/status'
    payload: 'online'
    qos: 0
    retain: false
  will_message:
    topic: 'hass/status'
    payload: 'offline'

I installed this manually and edited the service file as you stated. However, when i run the

systemctl enable ring-alarm-mqtt

function i get this

Authentication is required to manage system service or unit files.                                                                 │
Multiple identities can be used for authentication:                                                                                │
 1.  ,,, (pi)                                                                                                                      │
 2.  root                                                                                                                          │
Choose identity to authenticate as (1-2): 1                                                                                        │
Password:                                                                                                                          │
==== AUTHENTICATION COMPLETE ===                                                                                                   │
Failed to enable unit: File /etc/systemd/system/ring-alarm-mqtt.service already exists. 

When i try to remove the service file it gives me that the file or directory does not exist. What I changed in the service file was the /opt/ring-alarm-mqtt to /home/pi/Documents/ring-alarm-mqtt/ring-alarm-mqtt.js

Can you please help me find out what is going on?

I also edited the user and group to pi on both as that is what i use to log into the raspberry pi

Hi @tsightler

I got this it working! however, i can’t get the enable command for the systemctl to run. I keep getting that the file already exists. I tried searching around but can’t find it. I’m hopeful that somehow the service will restart automatically anyways. Do you concur?

Did you use root? I see in the notes posted above you did not. You might also want to run “systemctl daemon-reload” as root before attempting to enable. What distro are you installing on?

I am installing on a raspbian stretch. I did run it as sudo, is that not the same thing?

Right now it works but my concern is that it is not enabled so it won’t start on reboot.

Add On does not work with new 2 Factor Authentication recently introduced by Ring. Are there any plans to somehow incorporate Ring’s 2FA into this add on?

It may be due to a mistake in my instructions. The readme file indicated to drop the file in /etc/systemd/system, but really, it should be /lib/systemd/system and then running enable would make a symlink in /etc/systemd/system to the file in /lib/systemd/system.