xannor / ha_reolink_rest

ReoLink REST/Web Camera Integration for Home Assistant
24 stars 3 forks source link

Cameras randomly go "Unavailable" #31

Closed julienmru closed 1 year ago

julienmru commented 2 years ago

Version : 0.6.7

I have two C1-Pro cameras from Reolink and from time to time they are randomly disconnected from HA. To bring them back up, I have to reload the device's integration in HA to bring them back online.

Here's what I found in the logs:

2022-10-22 10:00:00.768 WARNING (MainThread) [custom_components.reolink_rest.push] Camera (Study) refused subscription renewal, probably was rebooted.
2022-10-22 10:00:00.940 WARNING (MainThread) [custom_components.reolink_rest.push] Camera (Livingroom) refused subscription renewal, probably was rebooted.
[...]
2022-10-23 07:36:33.355 WARNING (MainThread) [custom_components.reolink_rest.push] Camera (Study) refused subscription renewal, probably was rebooted.
2022-10-23 07:36:33.435 WARNING (MainThread) [custom_components.reolink_rest.push] Camera (Livingroom) refused subscription renewal, probably was rebooted.

Maybe the component could catch this error and restart a whole connection process automatically (much like when reloading the integration)? Possibly with some fail-safe mechanism to restart the whole connection process if it hadn't be restarted recently?

FYI > HA runs on my Synology NAS (host networking) which also has Surveillance Station and I don't experience any issue in Surveillance Station. Both my cameras are not connected on the same outlet, one is even connected to a UPS, so power failure is not really a likely cause.

svendvd commented 2 years ago

Same here, it is unavailable after some time and stays in the latest state. Which makes it useless.

A component restart helps. Can I create an automation routine to restart the service? 😂

xannor commented 2 years ago

The refused renewal is not bad unless it is followed by a refused subscription. The renew warnings could be because my timing is off and they are expiring before I renew. I hold onto the subscription keys (since the camera's only have a limited number) and if I cannot renew, I will request a new one.

I dont do the same for login though, and need a better approach to handle connectivity issues, which is where I think the unavailable happens.

I believe Synology "cheats" in that they either have a version that uses the native protocol of the cameras, the same the client app uses, or they have better API documentation and resources to build the interface. I do know they are the only officially supported 3rd party app of Reolink.

I am in the process of reworking the codebase as I have not been happy with its performance either. I just managed to deduce how Home Assistants Repairs feature works and have been adding that into areas were user intervention is needed. It may still take me a week or so to get an updated version out as my time has been limited lately.

svendvd commented 2 years ago

As a Workaround: I simply created an action that uses the "Home Assistant Core Integration: Reload config entry" service to reload the config of one of the camera entries. It is simply triggered by the unavailable state change.

Works well since 5h. Normally it stops after few minutes.

alias: Reload Reolink Integration
description: ""
trigger:
  - platform: state
    entity_id:
      - camera.eingang_1_rtmp_extra
    to: unavailable
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition: []
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: camera.eingang_1_rtmp_extra
mode: single
qisbic commented 1 year ago

As a Workaround: I simply created an action that uses the "Home Assistant Core Integration: Reload config entry" service to reload the config of one of the camera entries. It is simply triggered by the unavailable state change.

Works well since 5h. Normally it stops after few minutes.

alias: Reload Reolink Integration
description: ""
trigger:
  - platform: state
    entity_id:
      - camera.eingang_1_rtmp_extra
    to: unavailable
    for:
      hours: 0
      minutes: 0
      seconds: 5
condition: []
action:
  - service: homeassistant.reload_config_entry
    data: {}
    target:
      entity_id: camera.eingang_1_rtmp_extra
mode: single

Same issue (reolink RLC-822A).. Thanks.. this automation seems to have solved the problem.. hopes for a proper solution soon.

xannor commented 1 year ago

I am working on a update to the code, but so far it is a massive overhaul so it is slow going. I am restructuring the code to better handle the multitude of calls that need to be repeated, and trying to not overload the cameras in the processes. Hopefully when they release their webhook firmware it will support better push notifications.

xannor commented 1 year ago

After some testing, and limited time. I think I am going to put this on hiatus, I would recommend using the built in version as it has fundamentally surpassed what I have built and will have better support than I can provide.