tsightler / ring-mqtt

Ring devices to MQTT Bridge
MIT License
574 stars 103 forks source link

Wrong Image on movement event #391

Closed zibous closed 2 years ago

zibous commented 2 years ago

First of all congratulations on the great project.

Describe the problem

When a movement is detected, I try to save the camera image. Unfortunately, it is not the current image of the movement that is saved, but another one.

Describe your environment
Version core-2022.6.7
Installation Type   Home Assistant Container
Development false
Supervisor  false
Docker  true
User    root
Virtual Environment false
Python Version  3.9.12
Operating System Family Linux
Operating System Version    5.15.0-40-generic
CPU Architecture    x86_64
Timezone    Europe/Vaduz

ring-mqtt.js version: 5.0.2
Node version v16.14.2
NPM version 8.1.3
git version 2.34.2

ring video doorbell wired (doorbell_graham_cracker) - Firmware 9.0.66 + Chime

Bildschirmfoto 2022-07-02 um 18 03 30

Describe any steps you've taken to attempt to resolve the problem

Homeassistant Automation

# --------------------------------------------------
# save image ring doorbell on motion event
# --------------------------------------------------
- id: "2022062914500"
  alias: Haustür Security
  initial_state: true
  trigger:
    - platform: state
      entity_id: binary_sensor.kamera_haustur_motion_2
      to: "on"
  condition: []
  variables:
      filename: '/media/frontdoor/{{ now().strftime("%Y%m%d-%H.%M.%S") }}_motion.jpg'
  action:      
    - delay: 5s
    - service: camera.snapshot
      target:
        entity_id: camera.kamera_haustur_snapshot
      data:
        filename: "{{filename}}"
  mode: single

Bildschirmfoto 2022-07-02 um 18 08 27

Log

2022-07-02T16:12:38.343Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/state OFF
2022-07-02T16:12:38.343Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/attributes {"status":"inactive"}
2022-07-02T16:12:38.344Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/state OFF
2022-07-02T16:12:38.344Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656778023,"lastMotionTime":"2022-07-02T16:07:03Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-02T16:12:38.344Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/state OFF
2022-07-02T16:12:38.344Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/attributes {"lastDing":0,"lastDingTime":""}
2022-07-02T16:12:38.344Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot_mode/state All
2022-07-02T16:12:38.344Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/image <binary_image_data>
2022-07-02T16:12:38.345Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/attributes {"timestamp":1656778349}
2022-07-02T16:12:38.345Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot_interval/state 30
2022-07-02T16:12:38.348Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/volume/state 11
2022-07-02T16:12:38.348Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze/state OFF
2022-07-02T16:12:38.349Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze/attributes {"minutes_remaining":0}
2022-07-02T16:12:38.349Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze_minutes/state 1440
2022-07-02T16:12:38.350Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/play_ding_sound/state OFF
2022-07-02T16:12:38.350Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/play_motion_sound/state OFF
2022-07-02T16:12:38.759Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/info/state {"wirelessNetwork":"Microwelle","wirelessSignal":-40,"firmwareStatus":"Up to Date","lastUpdate":"2022-07-02T16:07:14Z"}
2022-07-02T16:12:38.759Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-40}
2022-07-02T16:12:38.899Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/info/state {"firmwareStatus":"Up to Date","lastUpdate":"2022-07-02T16:07:21Z","wirelessNetwork":"Microwelle","wirelessSignal":-40,"stream_Source":"rtsp://172.17.0.4:8554/54e019cfa225_live","still_Image_URL":"https://localhost:8123{{ states.camera.haustür_snapshot.attributes.entity_picture }}"}
2022-07-02T16:12:38.899Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-40}
2022-07-02T16:12:58.210Z ring-mqtt [Haustür] Requesting an updated interval snapshot
2022-07-02T16:12:58.959Z ring-mqtt [Haustür] Successfully retrieved updated snapshot
2022-07-02T16:12:58.959Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/image <binary_image_data>
2022-07-02T16:12:58.960Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/attributes {"timestamp":1656778379}
2022-07-02T16:13:23.618Z ring-mqtt [Haustür] Received motion push notification, expires in 180 seconds
2022-07-02T16:13:23.618Z ring-mqtt [Haustür] Requesting an updated motion snapshot
2022-07-02T16:13:23.618Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/state ON
2022-07-02T16:13:23.619Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656778403,"lastMotionTime":"2022-07-02T16:13:23Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-02T16:13:24.327Z ring-mqtt [Haustür] Successfully retrieved updated snapshot
2022-07-02T16:13:24.327Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/image <binary_image_data>
2022-07-02T16:13:24.328Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/attributes {"timestamp":1656778404}
tsightler commented 2 years ago

It's not really clear to me, is the incorrect image also displayed in Home Assistant? Based on the logs it does not appear you have rich notifications enable, so ring-mqtt has to request the camera to take a standard snapshot, but this was retrieved and updated in less than 1 second, which should be pretty close.

zibous commented 2 years ago

@tsightler Thanks for your support.

I don't understand that either, but by the ring APP I see the correct picture (but only for a very short time for 1 sec.) when a movement is recognized.

The image of the home assistant is not updated correctly. The status is always on "idle". I suspect that it is a timing problem and because the image is only available for a very short time and is therefore not retrieved from the ring server.

Bildschirmfoto 2022-07-02 um 19 47 37

The MQTT message is delivered flawlessly. It is interesting that the movement status at ring-mqtt comes earlier than that of the ring integration.

@ 2022-07-02T19:47:06.777432+02:00 vs. @ 2022-07-02T17:46:58Z

<template TemplateState(<state binary_sensor.haustur_motion=off; attribution=Data provided by Ring.com, device_class=motion, friendly_name=Haustür Motion @ 2022-07-02T19:47:06.777432+02:00>)>

<template TemplateState(<state binary_sensor.kamera_haustur_motion_2=off; lastMotion=1656784018, lastMotionTime=2022-07-02T17:46:58Z, personDetected=True, motionDetectionEnabled=True, device_class=motion, friendly_name=Kamera Haustür Motion @ 2022-07-02T19:49:59.773632+02:00>)>
tsightler commented 2 years ago

Do you have a Ring protect plan? If so, can you enable rich notifications and see if that changes the behavior. When rich notifications are enabled ring-mqtt can request the snapshot that caused the motion event via the UUID which should allow it to retrieve the same image used for the app notifications.

The fact that it's only showing the image in the Ring app for 1 second seems strange, I've never seen behavior like that. I don't see how anything ring-mqtt is doing could cause that.

It is interesting that the movement status at ring-mqtt comes earlier than that of the ring integration.

This is fully expected since ring-mqtt uses the Ring push API, while the HA native Ring integration still uses the old school polling API, and polls only every 5 seconds.

zibous commented 2 years ago

@tsightler

Do you have a. Ring protect plan?

No, i do not have a Ring protect plan.

To rule out the error with the home assistant, I wrote a simple python script and there I see that I never get the picture via MQTT when I get a motion message.

20220703-101250 IMAGE: images/image_20220703-101250.jpg
20220703-101250 TIMESTAMP: 2022-07-03 10:12:50.000000
20220703-101254 IMAGE: images/image_20220703-101254.jpg
20220703-101254 TIMESTAMP: 2022-07-03 10:12:54.000000
20220703-101310 IMAGE: images/image_20220703-101310.jpg
20220703-101310 TIMESTAMP: 2022-07-03 10:13:10.000000
20220703-101310 MOTION: b'ON'
20220703-101310 IMAGE: images/image_20220703-101310.jpg < -- wrong image
20220703-101310 TIMESTAMP: 2022-07-03 10:13:11.000000

I'm not sure, but I got this from the previous version of. Either something has changed or ring prevents this if there is no ring protect plan.

Testcase see: https://github.com/zibous/ring-mqtt-test

zibous commented 2 years ago

@tsightler

Testet with DOCKERIMAGE=tsightler/ring-mqtt:4.9.1

Bildschirmfoto 2022-07-03 um 10 46 58

This version is working perfect (homassistant also), so something has change to the version 5.0.2

20220703-104156 IMAGE: images/image_20220703-104156.jpg
20220703-104156 TIMESTAMP: 2022-07-03 10:41:49.000000
20220703-104226 MOTION: b'ON'
20220703-104226 IMAGE: images/image_20220703-104226.jpg --> o.k
20220703-104226 TIMESTAMP: 2022-07-03 10:41:49.000000
20220703-104256 MOTION: b'ON'
20220703-104256 IMAGE: images/image_20220703-104256.jpg  --> ok
20220703-104256 TIMESTAMP: 2022-07-03 10:41:49.000000
20220703-104439 MOTION: b'OFF'

By the way, what is doorbell_graham_cracker ??

tsightler commented 2 years ago

By the way, what is doorbell_graham_cracker ??

That is Ring's internal designation for the model of doorbell, this should be a Doorbell Wired. Is that correct?

It's good you brought that up because I keep forgetting that these cameras exist and it likely explains why you are seeing this behavior, which is already covered in the FAQ. Basically, while these are wired cameras, they behave like battery cameras, and battery cameras are unable to take snapshots while they are recording. Since motion events trigger the camera to start recording, ring-mqtt 5.x has no method to get a snapshot for motion events if you don't have rich notifications, which require a Ring protect plan, thus the behavior you are seeing is expected.

zibous commented 2 years ago

@tsightler

That is Ring's internal designation for the model of doorbell, this should be a Doorbell Wired. Is that correct?

Yes it is a Ring Video Doorbell Wired

I also have (had) a Video Doorbell Pro, but with this I only had problems with the connections, which were always broken and WIFI didn't work properly either. The Ring Video Doorbell Wired has worked flawlessly so far

Bad luck, if ring-mqtt 5.x doesn't have this option, I have no choice but to stay with version 4.9.1.

The variants with Motion-eye or iSpy would offer me the possibility, but the tests show that the quality is too bad and that I lose the events when streaming video because Ring turns them off during streaming.

Thanks for your help and time 💯

tsightler commented 2 years ago

The Video Doorbell Pro behaves as a high powered device and does support snapshots while recording. I own one of those and have never had the slightest problem with it even though it is on the outside of a brick house and is not very close to my access points, at least in relative terms, so I'm surprised you had issues with it.

It would be somewhat interesting to see the ring-mqtt logs during a motion event to see how the snapshot is being acquired. I don't own one of the cameras (I'll likely never own a Ring low-powered camera, far too limited devices IMO) so I only have feedback from other users to go on, and this camera seems to behave as a low power camera. Since the 4.x versions of ring-mqtt didn't have push notifications these versions had to resort to a very complex method to get a motion image for low power cameras. Basically, if it detected a low-power camera it would connect to the live stream and grab a still frame image from that vs attempting to take a snapshot. It was only about 90% reliable and had several seconds of delay to get an image, but it seemed better than nothing.

With the advent of push notifications, it made much more sense to use the rich notifications feature for battery camera because that way it would always provide the same image as the one in the Ring app, which was the behavior users expected, and was far simpler and more reliable, but it does require a Ring protect subscription, which a significant majority of users have.

That being said, it would be interesting to verify that this is why 4.9.1 is working, because that version also used an alternate method for acquiring snapshots as well (basically, a manually coded call to the API instead of the ring-client-api version), so it would be interesting to see for sure which method you were using. While I have zero plans to re-introduce the old "grab snapshot from livestream" method, I would be willing to consider implementing the older snapshot method in 5.x as that's not complex. If you can provide the logs from a working 4.9.1 event it will tell me clearly what is happening.

zibous commented 2 years ago

It would be somewhat interesting to see the ring-mqtt logs during a motion event to see how the snapshot is being acquired. If you can provide the logs from a working 4.9.1 event it will tell me clearly what is happening.

Bildschirmfoto 2022-07-03 um 20 09 44

2022-07-03T18:04:38.031Z ring-rtsp INF [path 54e019cfa225_live] runOnDemand command stopped
2022-07-03T18:04:38.032Z ring-rtsp INF [RTSP] [conn 127.0.0.1:42204] closed (terminated)
2022-07-03T18:04:38.032Z ring-rtsp INF [RTSP] [session 200463395] closed (terminated)
2022-07-03T18:04:38.033Z ring-rtsp [Haustür] Deactivating live stream due to signal from RTSP server (no more active clients or publisher ended stream)
2022-07-03T18:04:38.045Z ring-mqtt [Haustür] Received set live stream state OFF
2022-07-03T18:04:38.057Z ring-mqtt [Haustür] Live video stream ended
2022-07-03T18:04:38.057Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/state OFF
2022-07-03T18:04:38.058Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/attributes {"status":"inactive"}
2022-07-03T18:04:40.699Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656871411,"lastMotionTime":"2022-07-03T18:03:31Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-03T18:04:40.701Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/state OFF
2022-07-03T18:04:40.702Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/attributes {"status":"inactive"}
2022-07-03T18:04:40.704Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_stream/state OFF
2022-07-03T18:04:40.705Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_stream/attributes {"status":"inactive"}
2022-07-03T18:04:40.707Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_select/state Motion 1
2022-07-03T18:04:40.708Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_select/attributes {"recordingUrl":null,"eventId":null}
2022-07-03T18:04:40.710Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/state ON
2022-07-03T18:04:40.713Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656871411,"lastMotionTime":"2022-07-03T18:03:31Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-03T18:04:40.714Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/state ON
2022-07-03T18:04:40.716Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/attributes {"lastDing":1656871424,"lastDingTime":"2022-07-03T18:03:44Z"}
2022-07-03T18:04:40.717Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/image <binary_image_data>
2022-07-03T18:04:40.720Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/attributes {"timestamp":1656871418}
2022-07-03T18:04:40.721Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot_interval/state 180
2022-07-03T18:04:40.738Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/volume/state 11
2022-07-03T18:04:40.739Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze/state OFF
2022-07-03T18:04:40.741Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze/attributes {"minutes_remaining":0}
2022-07-03T18:04:40.742Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze_minutes/state 1440
2022-07-03T18:04:40.743Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/play_ding_sound/state OFF
2022-07-03T18:04:40.744Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/play_motion_sound/state OFF
2022-07-03T18:04:41.198Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/info/state {"batteryLevel":null,"firmwareStatus":"Up to Date","lastUpdate":"2022-07-03T16:58:59Z","wirelessNetwork":"Microwelle","wirelessSignal":-41,"stream_Source":"rtsp://172.17.0.17:8554/54e019cfa225_live","still_Image_URL":"https://localhost:8123{{ states.camera.haustür_snapshot.attributes.entity_picture }}"}
2022-07-03T18:04:41.201Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-41}
2022-07-03T18:04:41.203Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/battery/attributes {"batteryLevel":null}
2022-07-03T18:04:41.323Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/info/state {"wirelessNetwork":"Microwelle","wirelessSignal":-40,"firmwareStatus":"Up to Date","lastUpdate":"2022-07-03T18:03:37Z"}
2022-07-03T18:04:41.325Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-40}
2022-07-03T18:05:40.794Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656871411,"lastMotionTime":"2022-07-03T18:03:31Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-03T18:05:40.808Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/volume/state 11
2022-07-03T18:05:40.809Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze/state OFF
2022-07-03T18:05:40.810Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze/attributes {"minutes_remaining":0}
2022-07-03T18:05:40.811Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/snooze_minutes/state 1440
2022-07-03T18:05:40.812Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/play_ding_sound/state OFF
2022-07-03T18:05:40.813Z ring-mqtt [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/play_motion_sound/state OFF
2022-07-03T18:05:41.260Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/info/state {"wirelessNetwork":"Microwelle","wirelessSignal":-40,"firmwareStatus":"Up to Date","lastUpdate":"2022-07-03T18:03:50Z"}
2022-07-03T18:05:41.262Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-40}
2022-07-03T18:05:41.380Z ring-mqtt [Haustür] Failed to retrieve motion event recording URL for event
2022-07-03T18:05:41.380Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/state OFF
2022-07-03T18:05:41.380Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/attributes {"status":"inactive"}
2022-07-03T18:05:41.381Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_stream/state OFF
2022-07-03T18:05:41.381Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_stream/attributes {"status":"inactive"}
2022-07-03T18:05:41.382Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_select/state Motion 1
2022-07-03T18:05:41.383Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/event_select/attributes {"recordingUrl":null,"eventId":null}
2022-07-03T18:05:41.383Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/state ON
2022-07-03T18:05:41.384Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656871411,"lastMotionTime":"2022-07-03T18:03:31Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-03T18:05:41.385Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/state ON
2022-07-03T18:05:41.385Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/attributes {"lastDing":1656871424,"lastDingTime":"2022-07-03T18:03:44Z"}
2022-07-03T18:05:41.386Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/image <binary_image_data>
2022-07-03T18:05:41.387Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/attributes {"timestamp":1656871418}
2022-07-03T18:05:41.388Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot_interval/state 180
2022-07-03T18:05:41.819Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/info/state {"batteryLevel":null,"firmwareStatus":"Up to Date","lastUpdate":"2022-07-03T18:04:40Z","wirelessNetwork":"Microwelle","wirelessSignal":-41,"stream_Source":"rtsp://172.17.0.17:8554/54e019cfa225_live","still_Image_URL":"https://localhost:8123{{ states.camera.haustür_snapshot.attributes.entity_picture }}"}
2022-07-03T18:05:41.820Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-41}
2022-07-03T18:05:41.821Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/battery/attributes {"batteryLevel":null}
2022-07-03T18:06:27.559Z ring-mqtt [Haustür] Failed to retrieve motion event recording URL for event
2022-07-03T18:06:29.203Z ring-mqtt [Haustür] All doorbell dings for camera have expired
2022-07-03T18:06:29.203Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/state OFF
2022-07-03T18:06:29.205Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/ding/attributes {"lastDing":1656871424,"lastDingTime":"2022-07-03T18:03:44Z"}
2022-07-03T18:06:29.889Z ring-mqtt [Haustür] All motion dings for camera have expired
2022-07-03T18:06:29.889Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/state OFF
2022-07-03T18:06:29.889Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656871411,"lastMotionTime":"2022-07-03T18:03:31Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-03T18:07:29.370Z ring-mqtt [Haustür] Failed to retrieve motion event recording URL for event
2022-07-03T18:08:01.807Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/info/state {"batteryLevel":null,"firmwareStatus":"Up to Date","lastUpdate":"2022-07-03T18:04:40Z","wirelessNetwork":"Microwelle","wirelessSignal":-41,"stream_Source":"rtsp://172.17.0.17:8554/54e019cfa225_live","still_Image_URL":"https://localhost:8123{{ states.camera.haustür_snapshot.attributes.entity_picture }}"}
2022-07-03T18:08:01.809Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-41}
2022-07-03T18:08:01.811Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/battery/attributes {"batteryLevel":null}
2022-07-03T18:08:01.936Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/info/state {"wirelessNetwork":"Microwelle","wirelessSignal":-40,"firmwareStatus":"Up to Date","lastUpdate":"2022-07-03T18:03:50Z"}
2022-07-03T18:08:01.938Z ring-attr [Flur] ring/0342513a-3251-4707-4cfe-68cedaa02db8/chime/c4f31257e0ac/wireless/attributes {"wirelessNetwork":"Microwelle","wirelessSignal":-40}
2022-07-03T18:08:19.638Z ring-mqtt [Haustür] Camera received motion ding at 1656871699, expires in 176 seconds
2022-07-03T18:08:19.642Z ring-mqtt [Haustür] Motion event detected on battery powered camera snapshot will be updated from live stream
2022-07-03T18:08:19.642Z ring-mqtt [Haustür] Starting a snapshot stream for camera
2022-07-03T18:08:19.652Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/state ON
2022-07-03T18:08:19.653Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/motion/attributes {"lastMotion":1656871699,"lastMotionTime":"2022-07-03T18:08:19Z","personDetected":true,"motionDetectionEnabled":true}
2022-07-03T18:08:19.678Z ring-mqtt [Haustür] The snapshot stream has started
2022-07-03T18:08:19.685Z ring-rtsp INF [RTSP] [conn 127.0.0.1:42208] opened
2022-07-03T18:08:19.687Z ring-rtsp INF [path 54e019cfa225_live] runOnDemand command started
2022-07-03T18:08:19.719Z ring-rtsp [Haustür] Activating live stream via topic ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/command
2022-07-03T18:08:19.728Z ring-mqtt [Haustür] Received set live stream state ON-DEMAND
2022-07-03T18:08:19.728Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/state ON
2022-07-03T18:08:19.729Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/attributes {"status":"activating"}
2022-07-03T18:08:19.729Z ring-mqtt [Haustür] Establishing connection to live stream
2022-07-03T18:08:19.866Z ring-rtsp [Haustür] Live stream is activating...
2022-07-03T18:08:20.150Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/stream/attributes {"status":"active"}
2022-07-03T18:08:20.423Z ring-rtsp [Haustür] Live stream is active!
2022-07-03T18:08:22.315Z ring-rtsp INF [RTSP] [conn 127.0.0.1:42210] opened
2022-07-03T18:08:22.318Z ring-rtsp INF [RTSP] [session 548008159] opened by 127.0.0.1:42210
2022-07-03T18:08:22.332Z ring-rtsp INF [RTSP] [session 548008159] is publishing to path '54e019cfa225_live', 3 tracks with TCP
2022-07-03T18:08:22.334Z ring-rtsp INF [RTSP] [session 921833576] opened by 127.0.0.1:42208
2022-07-03T18:08:22.337Z ring-rtsp INF [RTSP] [session 724629771] opened by 127.0.0.1:42208
2022-07-03T18:08:22.347Z ring-rtsp INF [RTSP] [session 724629771] is reading from path '54e019cfa225_live', 3 tracks with TCP
2022-07-03T18:08:26.251Z ring-mqtt [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/image <binary_image_data>
2022-07-03T18:08:26.252Z ring-attr [Haustür] ring/0342513a-3251-4707-4cfe-68cedaa02db8/camera/54e019cfa225/snapshot/attributes {"timestamp":1656871706}

I I would be willing to consider implementing the older snapshot method in 5.x as that's not complex. Great, i like it 👍

tsightler commented 2 years ago

2022-07-03T18:08:19.642Z ring-mqtt [Haustür] Motion event detected on battery powered camera snapshot will be updated from live stream

Unfortunately, this confirms previous expectations, this camera, although wired, behaves as a battery powered camera so the 4.x code failed back to the live stream method to gather the snapshot image (and it took about 7 seconds!). I don't have any plans to put this code back in 5.x as it was far too complex and failure prone and, even when it worked, was generally too slow.

It would be possible to implement same behavior with an automation, basically run a script which fired off an ffmpeg process which connected to the live stream and saved a single frame to disk is all that would be needed. This is really all 4.x was doing internally. Otherwise, I guess you can run 4.9.1 until it breaks at some point in the future.

Since this is expected behavior, I'm going to close this for now. I do appreciate all the details and confirmation. Unfortunately, Ring cameras are very limited without a Ring protect plan, even more so for low power models.

zibous commented 2 years ago

@tsightler

Thanks.

It would be possible to implement same behavior with an automation, basically run a script which fired off an ffmpeg process which connected to the live stream and saved a single frame to disk is all that would be needed. This is really all 4.x was doing internally. Otherwise, I guess you can run 4.9.1 until it breaks at some point in the future.

Does this mean that I have to keep the live stream switched on at all times? Because my attempts with a "generic camera" were unsuccessful. I am therefore looking for a way to use the live stream, but without losing the motion- | ding events.

...method to gather the snapshot image (and it took about 7 seconds!).

Yes that is correct.

Ring protect plan is out of the question for me, it's too expensive for me. Before that, I'll look for another doorbell that works without a cloud and ring protect plan.

tsightler commented 2 years ago

Does this mean that I have to keep the live stream switched on at all times? Because my attempts with a "generic camera" were unsuccessful. I am therefore looking for a way to use the live stream, but without losing the motion- | ding events.

No, the stream would only stay alive for probably 10-15 seconds, just long enough for the stream to start, ffmpeg to grab a frame, and then the stream to time out. It's really just something crude like:

ffmpeg -i <rtsp_url> -vframes 1 output.jpg

I'm not saying that's the exact command, but something simple like that is all that is required to grab a frame. Another option would be to record a small video and then extract a frame after the fact.

Ring protect plan is out of the question for me, it's too expensive for me. Before that, I'll look for another doorbell that works without a cloud and ring protect plan.

Fair enough, this would really be my suggestion. IMO, Ring cameras are basically the worst cameras for people that don't want cloud based services and a monthly fee.

zibous commented 2 years ago

@tsightler

My tests show that it is probably not possible without a ring plan, because the messages about a movement, ding is too late to create a snapshot. Added to this is the high latency (ring server), which leads to another error.

I also see when I integrate the stream via motioneye that I lack pictures.

It will be easier to install a small second WLAN KAMERA, with which I can use the livestream directly w/o a cloud.

Another problem is that no correct images are delivered during a ding event or the ding Event does not come at all because the motion message prompts the Ring Server to be streamed beforehand and therefore no ding event is sent.

ffmpeg -i -vframes 1 output.jpg

Thanks, here is my simple bash:

#!/bin/bash

## sudo apt-get install fonts-freefont-ttf

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

[[ -z "$1" ]] && { echo "Missing Filename"; exit 1; }

## get the snapshoot image and add the timestamp
ffmpeg -y \
   -hide_banner  \
   -loglevel quiet  \
   -rtsp_transport tcp \
   -i rtsp://10.1.1.217:8554/54e019cfa225_live \
   -s 640x360  \
   -vframes 1 \
   -vf drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSans.ttf:\
                fontcolor=white:fontsize=38:x=40:y=1000: \
                text='Snapshoot  %{localtime\:%Y.%m.%d %H\\\\\:%M\\\\\:%S}'"  \
    $1

All test you can see here: https://github.com/zibous/ring-mqtt-test

tsightler commented 2 years ago

That's somewhat counter to above where you said that 4.9.1 worked, but there's nothing surprising in those results and the limitations are largely explained in the FAQ (no events during streaming, etc).

In general, I personally don't believe Ring cameras are worth owning without a subscription. If I only had cameras, I don't think I would even consider Ring.