Ring Device integration via MQTT w/ Video Streaming

Hi appreciate the response! I tried via the UI and was unable because it wouldn’t recognize the device. I then tried via the YAML but was having issues with the syntax. Do you or anyone else have an example of an automation with the ring motion sensor that was set up in the YAML?

The only ones I can find online are for the Doorbell motion sensor, which I believe is handled differently since it’s through the official add-on.

It’s pretty simple and should really be the same as the examples for the doorbell, the only difference would be the entity name, which you can get from the UI on the Entities screen. Here’s a stripped down/simplified example from one of my automatons:

- alias: Backyard lights on with motion
  trigger:
    - platform: state
      entity_id: binary_sensor.screen_porch_motion
      to: 'on'
    - platform: state
      entity_id: binary_sensor.screen_porch_motion
      to: 'off'
      for:
        minutes: 5
  action:
    - service_template: 'homeassistant.turn_{{trigger.to_state.state}}'
      data_template:
        entity_id: group.back_yard_lights
1 Like

I’ve tried several times today to install via Docker and get an error stating refresh token is not vaild. Ideas?

2020-06-16T16:24:11.324Z ring-mqtt Configuration file read from: ./config
2020-06-16T16:24:11.325Z ring-mqtt Configuration file not found, try environment variables!
2020-06-16T16:24:11.518Z ring-mqtt Error: Refresh token is not valid.  Unable to authenticate with Ring servers.
    at RingRestClient.getGrantData (/ring-mqtt/node_modules/ring-client-api/lib/api/rest-client.js:85:15)
    at RingRestClient.<anonymous> (/ring-mqtt/node_modules/ring-client-api/lib/api/rest-client.js:89:36)
    at Generator.next (<anonymous>)
    at /ring-mqtt/node_modules/ring-client-api/lib/api/rest-client.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/ring-mqtt/node_modules/ring-client-api/lib/api/rest-client.js:4:12)
    at RingRestClient.getAuth (/ring-mqtt/node_modules/ring-client-api/lib/api/rest-client.js:88:16)
    at RingRestClient.<anonymous> (/ring-mqtt/node_modules/ring-client-api/lib/api/rest-client.js:113:33)
    at Generator.throw (<anonymous>)
    at rejected (/ring-mqtt/node_modules/ring-client-api/lib/api/rest-client.js:6:65)
2020-06-16T16:24:11.518Z ring-mqtt Couldn't create the API instance. This could be because the Ring servers are down/unreachable
2020-06-16T16:24:11.519Z ring-mqtt or maybe the refreshToken is invalid. Please check settings and try again.

My first guess would be that the token isn’t valid! :slight_smile:
Did you acquire a new token? I’m not having any issues authenticating with my token.

I’ve tried it like 5 times. I simply copy it from putty and put it in the docker script. I’ll try again.

I don’t know if its just me or what… but today (well last night) my integration stop working… i don’t know why… but i had to get a new token to get it back… weird!!!

another question… can someone help me out… im running docker desktop, i’m trying to find the right command line that i need to type for me to be able to get the debug… i tried a couple that i found on google but there are not working…

I’m trying to get the debug to see if @tsightler can help me out on why my doorbell camera its not showing up and my smart lock…

thanks in advances!

The acquired token should be “long lived” but does eventually expire, and various events can cause it to expire immediately (changing the account password for example). It’s not a completely unusual event to have to get a new one. I’ve been working on code to auto-renew and update the token and store it in a separate file to help avoid this, but I haven’t had time to finish this code or really do much else with this project. I’m hoping to get some time in July to finalize these fixes and implement a few new features such as proper device support.

1 Like

token expiration happened to me last time when my laptop powered off and restarted.

Any other ideas? I get the token right away and copy it into the script. Same error every time.

A few questions. I got this running for the most part I believe. I’m running Home Assistant on Raspberry Pi. Everything via docker. So, I started with the ring-mqtt docker install. Almost immediately I was able to see MQTT messages. Wow! The only thing I was missing was discovery: true in my MQTT config in order to get the devices to show up in HA. Wow X 2.

My questions:

Is ring-mqtt-hassio-addon ONLY for Hass.IO? Is it any different from what I’ve already done “manually”?

I’m using docker-compose. Should ring-mqtt wait for any other services to start?

MQTTHASSTOPIC=hass/status - I never see this in my MQTT topics in the HA developer tools. What is it?

Birth and Last WIll - I don’t understand the purpose of this.

Where is the config file? I currently configure this in my docker-compose.yaml, but would it be better to put the env variables in a ring-mqtt config?

This is great. Thank you very much.

Is ring-mqtt-hassio-addon ONLY for Hass.IO? Is it any different from what I’ve already done “manually”?

Yes, it’s just a simple way for users of Hass.IO to install the script via the addon capability in Hass.IO, functionally there is no difference and I don’t personally use Hass.IO as I really find it just makes things more complex for me, which is weirdly the opposite of it’s goal.

I’m using docker-compose. Should ring-mqtt wait for any other services to start?

MQTTHASSTOPIC=hass/status - I never see this in my MQTT topics in the HA developer tools. What is it?

Birth and Last WIll - I don’t understand the purpose of this.

I’m going to answer all of these together because they are really inter-related. Since the script uses MQTT it has no way to know anything about HASS at all, no idea whether it’s running or not and no method to know if it is restarted and needs to re-send discovery/state data. In general you’d want to start HASS before starting the script. However, the script does have some methods to mitigate if it’s started prior to HASS, when the script first starts and connects to MQTT (or any time it reconnects to MQTT) it starts sending autodiscovery messages and updated state. It does this 10 times at 30 second intervals so, even if the script starts prior to HASS, as long as HASS starts within 5 minutes it’s still OK.

However, what happens, for example, if a configuration error keeps HASS from starting, or HASS is restarted later manually? In this case the script has no idea about this so you either have to manually restart it OR you can configure HASS to send MQTT birth messages. If you configure HASS to enable MQTT birth messages then, when HASS starts and is ready to receive device/state updates, it will send a message to hass/status of “online”. The script looks for this by default, if it sees a new “online” message it knows that HASS was restarted and it re-sends discovery/state info for all devices.

Basically, configuring HASS with birth/last will messages lets the script monitor and be aware of the running state of HASS itself and take appropriate action. It makes the integration more automatic, but isn’t technically required, you just might have to manually restart ring-mqtt after a HASS restart if state information is out-of-data. Since you haven’t enabled birth/last will in HASS, that’s why you’ve seen no messages there (I argue it should be enabled by default because it doesn’t hurt anything but what do I know).

Where is the config file? I currently configure this in my docker-compose.yaml, but would it be better to put the env variables in a ring-mqtt config?

Currently if using the docker version there is no config file, on the environment variables. Originally this was because I didn’t want to require any persistent storage for the docker version, but this may change in the next version since I will likely need to include a mount for persistent storage anyway to store new refresh tokens whenever it’s updated.

Hope that answers your questions.

Thank you for the reply. It all makes sense, more or less. Thanks!

For anyone who is searching (which isn’t easy with this site), I was trying to figure out how to get just the battery level. This seems to need to be done per device, but it works. In the configuration.yaml, I have:

sensor:
   - platform: template
    sensors:
      front_door_bat:
        friendly_name: "front door"
        unit_of_measurement: '%'
        value_template: "{{ state_attr('binary_sensor.front_door', 'battery_level') }}"

Also, this is what I have in my docker-compose.yaml:


  ringmqtt:
    container_name: ringmqtt
    image: tsightler/ring-mqtt
    depends_on:
      homeassistant:
        condition: service_healthy
    environment:
      - MQTTHOST=192.168.10.211
      - MQTTPORT=1883
      - MQTTRINGTOPIC=ring
      - MQTTHASSTOPIC=hass/status
      #- MQTTUSER=mqtt user}
      #- MQTTPASSWORD=mqtt pw}
      - ENABLECAMERAS=false
      #- RINGLOCATIONIDS=comma-separated location IDs
      #- DEBUG=ring-mqtt
      - RINGTOKEN=thevalueigotfromyourtokendockerutility

I have the exact same issue. Now says my token is invalid. I refreshed it (oddly enough it gave me the same token) but no luck.

Hi HA_fanatic,
i have the same problem, did you find the reason why the service stopped working? i was also looking for a log file but it does not exist :frowning:

If you’re getting the same token I would say something is particularly wrong. Even if you request tokens back-to-back they should be different each time. What method are you using to generate the refresh token?

Great integration tsightler!!!

Question: I currently am using the OmniLinkBridge MQTT add on for my OmniPro 2 combo security automation panel and Home Assistant.

Will your Ring Device integration via MQTT work with the current OmniLinkBridge MQTT add on to Home Assistant?

Can I run both?

I want to utilize your integration for a second home with the Ring alarm set up installed?

I already started to install it in Docker but thinking I am missing something…please help me.

Did this so far:
1 - git clone https://github.com/tsightler/ring-mqtt.git
2 - cd ring-mqtt
3 - chmod +x ring-mqtt.js
4 - docker pull tsightler/ring-mqtt

Now want to run it using the configuration file in the ring-mqtt directory doing this:

docker run -d --name=“ring-mqtt” -v /opt/ring-mqtt/config:/config -v /etc/localtime:/etc/localtime:ro --net=host --restart unless-stopped tsightler/ring-mqtt

Is the nomenclature correct to do this?

This is what I am currently running. All of the configuration files are sitting in the /opt directory.

/opt# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ca54f4fcfe2a portainer/portainer “/portainer” 2 weeks ago Up 43 seconds 0.0.0.0:9000->9000/tcp portainer
2e2d1624611e acockburn/appdaemon:latest “./dockerStart.sh” 2 weeks ago Up 50 minutes 0.0.0.0:5050->5050/tcp appdaemon
4b986ea7e23a homeassistant/home-assistant “/init” 4 weeks ago Up 50 minutes home-assistant
d6e6891aaa75 dfarkov/onvif2mqtt “docker-entrypoint.s…” 2 months ago Up 50 minutes onvif2mqtt
8c7d3ee95182 omnilink-bridge “mono OmniLinkBridge…” 7 months ago Up 50 minutes omnilink-bridge

I am also running the Home Assistant Alexa media app and use Alexa show / echo devices for TTS such that I can TTS status of alarm via Home Assistant.

I can’t really answer your question regarding it working with the OmniLinkBridge MQTT addon as I don’t use it, but I don’t know any reason why the two couldn’t co-exist unless they somehow have a conflict with the ring topic, which seems extremely unlikely and is still resolvable since it’s configurable in the script.

I’m somewhat confused by your post, why are you git cloning the script but also pulling the docker container? You should follow either the “Standard Installation” or the “Docker Installation” instructions from the README, but you seem to have a mix of both.

The Docker installation does not use the config file as it was designed to not require any persistent storage in the container (this will likely change in the next major rev). To use the Docker built you pass all options via environment variables as part of the docker run command and those a documented in the README.

Thank you @tsightler

Understood.

but you seem to have a mix of both.

Really it was to keep a directory in place to store the configuration (persisent storage).

Going to give it a try in the next few days…

docker run --rm -e "MQTTHOST={host name}" -e "MQTTPORT={host port}" -e "MQTTRINGTOPIC={ring topic}" -e "MQTTHASSTOPIC={hass topic}" -e "MQTTUSER={mqtt user}" -e "MQTTPASSWORD={mqtt pw}" -e "RINGTOKEN={ring refreshToken}" -e "ENABLECAMERAS={true-or-false}" -e "RINGLOCATIONIDS={comma-separated location IDs}" tsightler/ring-mqtt

OK got it running with the token and validated MQTT messages via MQTT explorer.

Took a few minutes to see the messages.

I am logging in via SSH to the HA server.

Curious when I run the command line that it just stays at a blinking prompt.

Is there a way to exit the terminal window and leave it running?

ring

docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1164dfd80293 tsightler/ring-mqtt “node /ring-mqtt/rin…” 4 minutes ago Up 4 minutes kind_antonelli
ca54f4fcfe2a portainer/portainer “/portainer” 2 weeks ago Up 38 hours 0.0.0.0:9000->9000/tcp portainer
4b986ea7e23a homeassistant/home-assistant “/init” 4 weeks ago Up 39 hours home-assistant
d6e6891aaa75 dfarkov/onvif2mqtt “docker-entrypoint.s…” 2 months ago Up 39 hours onvif2mqtt
8c7d3ee95182 omnilink-bridge “mono OmniLinkBridge…” 8 months ago Up 39 hours omnilink-bridge

Using HA now and created a conditional card which I see when in editing mode but not in standard mode.

ringcard

@tsightler
I just upgraded to 4.0 on my Home Assistant installation. It has broken. When I start the add-on, I immediately get the following in the system log:

20-09-05 09:15:52 ERROR (SyncWorker_1) [supervisor.docker] Can't create container from addon_a98c085d_ring_mqtt: 404 Client Error: Not Found ("No such image: tsightler/ring-mqtt-ha-addon:4.0.0")

I did adjust the configuration as described (i.e., removed the ring_token). I do notice that https://github.com/tsightler/ring-mqtt-ha-addon still says the latest release is 3.0.1. Does that have something to do with it?