Ring Device integration via MQTT w/ Video Streaming

my problem was the mqtt wasnt set up right, now that I got it going, I can see in the logs that is getting snapshots, next question is how can I see those?

I want to ask a question: I have a ring alarm with this integration working completely. When I have a power outage in my house, the base station sends an alarm to ring app. Is there a way to get this working through mqtt? It would be a very useful way to trigger a ā€œpower outageā€ automation.

1 Like

itā€™s a good idea, you could also use a 7 dls sonoff s31 that would do the same thing, you could have that done tomorrow!!!

I have it set up by now with a Tasmota device ā€œrestart reasonā€ entity change from ā€œunavailableā€ to ā€œanyā€, but I thought Ring would be more reliable.

You canā€™t get the alert as itā€™s a different type of push notification, but assuming your Internet connection stays alive during the power outage (required so that ring-mqtt can maintain its connection to the Ring API), you can build automations that trigger using the status of base station attributes. The base station info sensor includes attributes for AcStatus and BatteryStatus. The AcStatus is either ā€œokā€ or ā€œerrorā€, the latter being a pretty good indicator that the power is out. The BatteryStatus will also be ā€œChargedā€, ā€œChargingā€ when on AC power, while it will show ā€œFullā€ or some other lower level when discharging.

1 Like

It would be the perfect solution, because I do keep internet connection available, but I canā€™t see those sensors in my integration.

The info sensor is right there in your screenshot, with status OK, which should be the AcStatus as that is the default attribute for that sensor for the base station device. Simply click to open the info sensor and expand the attributes to see all available data for the base station. Many entities in Home Assistant have attributes in additional to their main state and you can use attributes as triggers for automations just like the primary state.

1 Like

Perfect, now I see! Thanks a lot!!

Love this. Iā€™ve been looking for a way to detect power outages. As soon as I saw this I went and created a template binary sensor. :grinning:

# Template binary sensors
- binary_sensor:
    # Electricity Supply binary sensor
    - name: Electricity Supply
      device_class: problem
      icon: >-
        {%- if is_state('binary_sensor.electricity_supply', 'on') -%}
          mdi:transmission-tower-off
        {%- else -%}
          mdi:transmission-tower
        {%- endif -%}
      state: >-
        {%- if (not is_state('sensor.ring_alarm_base_station_info', 'unavailable'))
        and (not is_state('sensor.ring_alarm_base_station_info', 'unknown'))
        and (not is_state_attr('sensor.ring_alarm_base_station_info', 'acStatus', 'ok')) -%}
          on
        {%- else -%}
          off
        {%- endif -%}
2 Likes

And hereā€™s an automation to go with it. Saves anyone else reinventing the wheel.

# Electricity supply status monitor
- id: CBB1BFFF-0912-4645-9205-CC13B7B65E0D
  alias: "System: Electricity supply status monitor"
  variables:
    var_date: "{{ now().strftime('%d/%m/%Y') }}"
    var_time: "{{ now().strftime('%H:%M:%S') }}"
  trigger:
    # Power Cut
    - platform: state
      entity_id: binary_sensor.electricity_supply
      from: 'off'
      to: 'on'
      id: power_cut
    # Power Restored
    - platform: state
      entity_id: binary_sensor.electricity_supply
      from: 'on'
      to: 'off'
      id: power_restored
  action:
    - choose:
      # Power Cut
      - conditions:
          - condition: trigger
            id: power_cut
        sequence:
          # Send notification
          - service: notify.all_devices
            data_template:
              title: Power Cut
              message: >-
                There is a power cut to the house or a breaker in the consumer unit has tripped.<br>
                {{- var_time }} {{ var_date -}}
              data:
                notification_icon: mdi:transmission-tower-off
                ttl: 0
                priority: high
                color: color: '#FFA500' # orange
                sticky: true
                group: System
                tag: electricity_supply
      # Power Restored
      - conditions:
          - condition: trigger
            id: power_restored
        sequence:
          # Send notification
          - service: notify.all_devices
            data_template:
              title: Power Restored
              message: >-
                Power to the house has been restored.<br>
                <br>
                Power Cut: {{ as_timestamp(trigger.from_state.last_changed) | timestamp_custom('%H:%M:%S %d/%m/%Y') }}<br>
                {{- var_time }} {{ var_date -}}
              data:
                notification_icon: mdi:transmission-tower
                ttl: 0
                priority: high
                color: green
                sticky: true
                group: System
                tag: electricity_supply

Edited template sensor above to ignore unavailable and unknown states, as this was triggering power cut notifications on restart of Home Assistant and likewise would probably do the same if the add-on was restarted.

Having a problem my ring token is no longer working, and when I try to generate a new one, I get this:

Below you can see the saved token attempt fail, then after that on the web ui I enter email and password and click submit to login and get my 2FA but nothing happens - looks like it is due to an invalid argument?

2023-08-16T05:05:11.084Z ring-mqtt Attempting connection to Ring API using saved refresh tokenā€¦
2023-08-16T05:05:13.166Z ring-mqtt Refresh token is not valid. Unable to authenticate with Ring servers. See Refresh Tokens Ā· dgreif/ring Wiki Ā· GitHub
2023-08-16T05:05:13.166Z ring-mqtt Failed to establish connection to Ring API using saved refresh token
2023-08-16T05:05:13.166Z ring-mqtt Failed to connect to Ring API using saved token, generate a new token using the Web UI
2023-08-16T05:05:13.166Z ring-mqtt or wait 60 seconds to automatically retry authentication using the existing token
2023-08-16T05:05:15.386Z ring-mqtt WARNING - Unhandled Promise Rejection
2023-08-16T05:05:15.388Z ring-mqtt argument val is invalid
2023-08-16T05:05:15.389Z ring-mqtt TypeError: argument val is invalid
at Object.serialize (/app/ring-mqtt/node_modules/cookie/index.js:126:11)
at res.cookie (/app/ring-mqtt/node_modules/express/lib/response.js:884:36)
at file:///app/ring-mqtt/lib/tokenapp.js:88:25
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Found this thread: Trying it: Can't refresh token in web UI Ā· tsightler/ring-mqtt Ā· Discussion #605 Ā· GitHub

Following the discussion in 605, setting to dev and picked up 5.5.2, still same issue:

ring-mqtt.js version: 5.5.2
Node version v18.17.0
NPM version 9.1.2
git version 2.38.5

Running ring-mqttā€¦
2023-08-16T05:38:39.743Z ring-mqtt Detected runmode: addon
2023-08-16T05:38:39.745Z ring-mqtt Configuration file: /data/options.json
2023-08-16T05:38:43.444Z ring-mqtt Reading latest data from state file: /data/ring-state.json
2023-08-16T05:38:43.447Z ring-mqtt Succesfully started the token generator web UI
2023-08-16T05:38:43.472Z ring-mqtt Discovered MQTT Host: core-mosquitto
2023-08-16T05:38:43.473Z ring-mqtt Discovered MQTT Port: 1883
2023-08-16T05:38:43.474Z ring-mqtt Discovered MQTT User: addons
2023-08-16T05:38:43.474Z ring-mqtt Discovered MQTT password:
2023-08-16T05:38:43.475Z ring-mqtt MQTT URL: mqtt://addons:********@core-mosquitto:1883
2023-08-16T05:38:43.914Z ring-mqtt Attempting connection to Ring API using saved refresh tokenā€¦
2023-08-16T05:38:46.071Z ring-mqtt Refresh token is not valid. Unable to authenticate with Ring servers. See Refresh Tokens Ā· dgreif/ring Wiki Ā· GitHub
2023-08-16T05:38:46.071Z ring-mqtt Failed to establish connection to Ring API using saved refresh token
2023-08-16T05:38:46.072Z ring-mqtt Failed to connect to Ring API using saved token, generate a new token using the Web UI
2023-08-16T05:38:46.072Z ring-mqtt or wait 60 seconds to automatically retry authentication using the existing token
2023-08-16T05:39:27.003Z ring-mqtt WARNING - Unhandled Promise Rejection
2023-08-16T05:39:27.003Z ring-mqtt argument val is invalid
2023-08-16T05:39:27.003Z ring-mqtt TypeError: argument val is invalid
at Object.serialize (/app/ring-mqtt-dev/node_modules/cookie/index.js:126:11)
at res.cookie (/app/ring-mqtt-dev/node_modules/express/lib/response.js:884:36)
at file:///app/ring-mqtt-dev/lib/tokenapp.js:88:25
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

I am still unable to get token working again. And the tsightler-ring has starting crashing after startup up. I canā€™t seem to find instructions that work for docker setup. Instructions seem changed now after version 5 came out

Each time youā€™ve posted Iā€™ve asked for you to open an issue, or at least a discussion thread, on the ring-mqtt Github project page and I can try to help you. I donā€™t provide deep support in this thread, just try to answer basic questions.

I actually forgot you had suggested that. Sorry I got busy and having trouble shot this in a while.

Iā€™m just opened a new issue on GitHub

I am desperate to figure out what is going on .

Thanks

Hi, so ring-mqtt has been working great since you helped me on GitHub, but I just noticed when the door alert didnā€™t go off that this is streaming through WEBRTC non stop .

Is there something Iā€™m supposed to type in to have the live shut off when I back out of the live feed?

I can ask this on GitHub if you prefer

As a general rule it is always better to use the Github discussions as I donā€™t monitor this thread regularly, only check it randomly from time to time.

The most common issues for the stream running all the time is the snapshot stream not being configured (Home Assistant will keep starting the stream to get a snapshot instead), using a custom integration like WebRTC Camera, that starts streams by default, or having some option like preload stream, having something else on your network scanning for non-secured cameras (if you donā€™t have a username/password set on the camera). Itā€™s pretty much impossible for me to know what is causing it. My first recommended step is always to set a username/password and, if you have one, change it and restart the addon, then change the password on each client until the problem comes back, that way you can at least narrow down the source.

I see in the latest version that @tsightler has added a snapshot on ding. This is amazing news and something I have been waiting for for a long time, as the previous snapshot was always delayed.

Just one question - how do I add the ding snapshot in to an automation? what should the data be set to?
Thanks