fwestenberg / reolink_dev

Home Assistant Reolink addon
MIT License
550 stars 102 forks source link

Binary sensor is available in HA, but motion detection is not working #122

Open jjpeet opened 3 years ago

jjpeet commented 3 years ago

Hi @fwestenberg, Thanks for this integration - I've been using it for a few months and it has been rock solid. I run a RLN8-410-E NVR with 5 cameras (RLC-410 & RLC-522). I've been running v0.07 since new (I think) with the following config and it has been running pretty much perfectly; Cameras;

 - platform: reolink_dev
    host: 192.168.0.46
    username: !secret dvr_username
    password: !secret dvr_password
    name: Front Door
    stream: sub
    protocol: rtmp
    channel: 0
    scan_interval: 5

Motion Sensors;

- platform: template
    sensors:
      motion_front_door:
        friendly_name: Motion Front Door
        device_class: motion
        entity_id: camera.front_door
        value_template: "{{ is_state('camera.front_door', 'motion') }}"
        delay_off: 
            seconds: 0

In the last month or so I enabled object detection (people only using Tensor Flow), and the this is triggered by motion. It has been working great and only alerts me when it sees people in the cameras.

However, since upgrading to v0.10, and removing the old config, whilst the cameras are all displaying fine, motion has stopped working reliably, and there are a few other issues worth mentioning. Here are the symptoms;

  1. Two of the five motion sensors are unavailable at any one time (and this changes on HA restart - sometimes the front door is unavailable, and then it becomes available and another becomes unavailable)
  2. Motion on the available motion sensors is unreliable (at best). Sometimes it works, other times not. I have verified that it is working fine from the Reolink app (and the console screen).
  3. Sensitivity status within HA does not match sensitivity status within the Reolink app. (eg, one cam is set to medium(33) in the Reolink app, but displays as 18 within HA entity attribute. (See below)
    
    access_token: xxxxxxxxxxxxxxxxx
    daynight_state: AUTO
    sensitivity: 
    - id: 0
    sensitivity: 18
    begin: '00:00'
    end: '06:00'
    - id: 1
    sensitivity: 18
    begin: '06:00'
    end: '12:00'
    - id: 2
    sensitivity: 18
    begin: '12:00'
    end: '18:00'
    - id: 3
    sensitivity: 18
    begin: '18:00'
    end: '23:59'

friendly_name: Front Door entity_picture: /api/camera_proxy/camera.front_door?token=xxxxxxxxxxxxxxxxxx supported_features: 2



<img width="414" alt="image" src="https://user-images.githubusercontent.com/7045758/103392320-ebd1a880-4b68-11eb-8717-dbb6c4ae7ab4.png">

I am running HASSIO, in http mode, and with a reverse proxy enabling HTTPS (using Caddy add-on). I use a bought certificate and the same hostname inside and outside of my home network (using local and internet DNS to change the IP resolution depending whether you're at home or away).

What information do you need from me to help sort this out?
Thx
James
badabing2005 commented 3 years ago

In the last month or so I enabled object detection (people only using Tensor Flow),

Wow, How do you get people detection to work with RLN8-410-E NVR What firmware are you on? Does it only work with RLC-522 ? or with RLC-410 as well Reolink support tells me that in order for person detection to work, both the camera and the NVR need to support it, and according to them neither RLN8-410-E NVR nor RLC-410 can support it. I'm really curious to know how you got it working, even if it means that I'd have to replace one of my cameras with one that supports it. But replacing NVR + 8 Cameras is a non starter.

Motion detection wasn't working for me either until I switched to this branch https://github.com/fwestenberg/reolink_dev/tree/NVR-Webhook-subscription You might want to give it a try.

andriej commented 3 years ago

Motion detection stopped to work because you use internal SSL probably. Same issue as mine (although issue name doesn't show it - will change)

jjpeet commented 3 years ago

Hi @andriej My install runs at http://192.168.0.11. No SSL. Although I also run Caddy to create an SSL reverse proxy as well - and that is the primary address I use for access. I’m not sure how to tell which access the Reolink integration is using though so you might be the cause. How can I check this? Thx JP

jjpeet commented 3 years ago

Hi @badabing2005 I’m sending the camera feed to the DOODS object detection integration in HA (https://www.home-assistant.io/integrations/doods/). It’s talking to a DOODS docker image I’m running on a seperate host (but could equally run the DOODS as an add-on on the HA hardware. See useful video here - https://youtu.be/8XbA-dbi3n0

Thx JP

badabing2005 commented 3 years ago

Hi @badabing2005 I’m sending the camera feed to the DOODS object detection integration in HA (https://www.home-assistant.io/integrations/doods/). It’s talking to a DOODS docker image I’m running on a seperate host (but could equally run the DOODS as an add-on on the HA hardware. See useful video here - https://youtu.be/8XbA-dbi3n0

Thx JP

This is awesome, thanks for sharing, I will definitely set it up, once we get motion detection working on the NVR, I plan to only process on motion events using: image_processing.scan instead of constant image processing.

Thanks again.

fwestenberg commented 3 years ago

I just found out, the Motion detection sensitivity in the APP is separate from the motion detection in the Reolink windows application, webUI and our HA integration. I think this is something we should just accept.

Imperial-Guard commented 3 years ago

Here also with a RLC-422 and RLC-410W motion detection is not working. Internally no SSL, Reolink camera's are working under a separate VLAN.

While Switching IR lights I will get the following response:

2021-01-14 15:51:52 DEBUG (MainThread) [reolink.camera_api] Sending command: SetIrLights to: 192.168.30.45 with body: [{'cmd': 'SetIrLights', 'action': 0, 'param': {'IrLights': {'state': 'Auto'}}}] 2021-01-14 15:51:52 DEBUG (MainThread) [reolink.camera_api] Response from 192.168.30.45: [{'cmd': 'SetIrLights', 'code': 0, 'value': {'rspCode': 200}}] 2021-01-14 15:51:54 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.30.45 should renew in: 430 seconds... 2021-01-14 15:51:54 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.316 seconds 2021-01-14 15:51:57 DEBUG (MainThread) [reolink.camera_api] Sending command: SetIrLights to: 192.168.30.45 with body: [{'cmd': 'SetIrLights', 'action': 0, 'param': {'IrLights': {'state': 'Off'}}}] 2021-01-14 15:51:57 DEBUG (MainThread) [reolink.camera_api] Response from 192.168.30.45: [{'cmd': 'SetIrLights', 'code': 0, 'value': {'rspCode': 200}}] 2021-01-14 15:52:04 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.30.45 should renew in: 420 seconds... 2021-01-14 15:52:05 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.30.112 should renew in: 419 seconds... 2021-01-14 15:52:05 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.243 seconds 2021-01-14 15:52:05 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.770 seconds 2021-01-14 15:52:26 DEBUG (MainThread) [reolink.camera_api] Sending command: SetIrLights to: 192.168.30.45 with body: [{'cmd': 'SetIrLights', 'action': 0, 'param': {'IrLights': {'state': 'Auto'}}}] 2021-01-14 15:52:26 DEBUG (MainThread) [reolink.camera_api] Response from 192.168.30.45: [{'cmd': 'SetIrLights', 'code': 0, 'value': {'rspCode': 200}}] 2021-01-14 15:52:26 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.30.45 should renew in: 398 seconds... 2021-01-14 15:52:26 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.199 seconds 2021-01-14 15:52:37 DEBUG (MainThread) [reolink.camera_api] Sending command: SetIrLights to: 192.168.30.45 with body: [{'cmd': 'SetIrLights', 'action': 0, 'param': {'IrLights': {'state': 'Off'}}}] 2021-01-14 15:52:37 DEBUG (MainThread) [reolink.camera_api] Response from 192.168.30.45: [{'cmd': 'SetIrLights', 'code': 0, 'value': {'rspCode': 200}}] 2021-01-14 15:52:38 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.30.45 should renew in: 386 seconds... 2021-01-14 15:52:38 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.277 seconds

Any thoughts on this matter?

fwestenberg commented 3 years ago

No errors in the log right? And subscription looks good. What is not working here? Please explain.

Imperial-Guard commented 3 years ago

@fwestenberg: Motion detection itself is not working, for both camera's while I see motion detection on the Reolink app itself.

fwestenberg commented 3 years ago

Switches are working well?

fwestenberg commented 3 years ago

I renamed the issue a bit. Logging shows: 'Host 192.168.30.45 should renew in: 430 seconds... ' so the subscription manager itself works well (no http 400). But the motion detection is not working.

badabing2005 commented 3 years ago

I can confirm that with version 0.12 and NVR with RLC-410 and RLC-420 cameras switching IR light are still functional with no errors.

Here's how I use the switch

platform: template
switches:
  camera_front_door_ir_lights:
    # value_template: "{{ is_state_attr('camera.front_door', 'daynight_state', 'AUTO') }}"
    turn_on:
      service: reolink_dev.set_daynight
      data:
        entity_id: camera.front_door
        mode: AUTO
    turn_off:
      service: reolink_dev.set_daynight
      data:
        entity_id: camera.front_door
        mode: COLOR
    icon_template: >-
      {% if is_state_attr('camera.front_door', 'daynight_state', 'AUTO') %}
        mdi:flash-auto
      {% elif is_state_attr('camera.front_door', 'daynight_state', 'BLACKANDWHITE') %}
        mdi:flash
      {% elif is_state_attr('camera.front_door', 'daynight_state', 'COLOR') %}
        mdi:flash-off
      {% else %}
        mdi:flash-alert-outline
      {% endif %}
Imperial-Guard commented 3 years ago

For some reason motion sensors from both camera's became unavailable. I've inserted below some debug logs.

`Logger: custom_components.reolink_dev.base Source: custom_components/reolink_dev/base.py:241 Integration: Reolink IP camera (documentation, issues) First occurred: 18:24:45 (2 occurrences) Last logged: 19:09:54

Host 192.168.30.45 error renewing the Reolink subscription Host 192.168.30.112 error renewing the Reolink subscription`

`2021-01-14 18:24:45 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.30.45 error renewing the Reolink subscription 2021-01-14 18:24:45 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.30.45 got response status: 200. Payload: {<?xml version="1.0" encoding="UTF-8"?>

http://192.168.30.45:8000/onvif/Notification?Idx=00_02021-01-14T17:24:45Z2021-01-14T17:39:45Z }`
jjpeet commented 3 years ago

Hi @fwestenberg and @Imperial-Guard I tried 0.12 and now the motion sensor entities are permanently unavailable. Previously is sporadic.

All other sensors are working fine across my 5 cameras.

Here’s a tail of my log (grep reo);

2021-01-16 05:20:21 INFO (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 subscribed successfully to webhook http://192.168.0.11:8123/api/webhook/3e458f5e2a74cb230fee04516875121329119b42e4f5cbcbe9fef7314504880c 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.0.46 should renew in: 899 seconds... 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:20:21 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.296 seconds 2021-01-16 05:20:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.713 seconds 2021-01-16 05:20:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.789 seconds 2021-01-16 05:20:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.800 seconds 2021-01-16 05:20:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.859 seconds 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.camera] Setting up camera.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.switch] Setting up switch.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.camera] Setting up camera.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.switch] Setting up switch.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.camera] Setting up camera.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.switch] Setting up switch.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.camera] Setting up camera.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.switch] Setting up switch.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.camera] Setting up camera.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.switch] Setting up switch.reolink_dev 2021-01-16 05:20:22 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.reolink_dev 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.0.46 should renew in: 839 seconds... 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.248 seconds 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?> 2021-01-16 05:21:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.830 seconds 2021-01-16 05:21:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.889 seconds 2021-01-16 05:21:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.930 seconds 2021-01-16 05:21:22 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.959 seconds

aisbergde commented 3 years ago

motion detections worked great until ugrade from 0.8 to 0.13 I used binary sensors like

And the worked great in my automations

After upgrading to 0.13 and re-adding cameras via "integration" the binary sensors are still there but the do not change on motion.

I found additinal new sensors like

but they also doesn't work. On the following picture you see the history of motion sensors with detected motions in v 0.8 (1) and the new sensors from v .13 (3)

image

jjpeet commented 3 years ago

motion detections worked great until ugrade from 0.8 to 0.13 I used binary sensors like

  • binary_sensor.camera_garage
  • binary_sensor.camera_hinterhof
  • ...

And the worked great in my automations

After upgrading to 0.13 and re-adding cameras via "integration" the binary sensors are still there but the do not change on motion.

I found additinal new sensors like

  • binary_sensor.vorhof_motion
  • binary_sensor.garage_motion

but they also doesn't work. On the following picture you see the history of motion sensors with detected motions in v 0.8 (1) and the new sensors from v .13 (3)

Yes same with me - but the motion stopped working with 0.12. I just tried 0.13 and the only change is that subscription errors have disappeared (as intended by the 0.13 update). JP

aisbergde commented 3 years ago

@jjpeet

es same with me - but the motion stopped working with 0.12

did you upgrade from 0.11 to 0.12? is there a chance to get it to work downgrading to 0.11?

@fwestenberg in the readme you write:

Please notice: for using the motion detection, your Homa Assistant should be reachable (within you local network) over http (not https).

Has this changed compared to older versions? This was added to the readme 2020-12-18 (v 0.10?) But even if I try to compare the code I don't understand what has changed. Did you only change the description or was this changed in the implementation?

My Home Assistant is not reachable over http but only over https. But motion detection worked in the past also using Home Assistant via https.

Why it is important to use http and not https? Should I disable https to get motion detection to work again? Or did you find a way to use http and https at the same time?

fwestenberg commented 3 years ago

Until v0.8 HA was polling every second on the cgi API for motion. Because it was polling, https or http didn't matter. Now it has switched to real-time push motion detection, the camera should be able to reach the HA webhook. And for some unknown reason, this only works over http for now. So IMO this is a great improvement, with some things to fix:

mathmaniac43 commented 3 years ago

I am also using HTTPS for my setup and it is having this exact problem. In order to work around the issue, I followed the example at the following post to set up essentially the same polling behavior as older version of this integration, but via separate binary sensors in HA. Once the integration or HA is improved to natively work with HTTPS without this extra polling step, I look forward to switching to the new and more efficient callback way. https://github.com/home-assistant/core/issues/42784#issuecomment-755231028

aisbergde commented 3 years ago

I am ready to use "http" instead of "https" to get the sensors back. Unfortunately I don't remember where and how I switched from "http" to "https". I don't know how to disable https.

IMHO "https" is a big bullshit and fake, and I only use it because of the f***g browsers which alert users about "non-secure" sites and this way force site owners to use this pseudo secure "https". I think it is part of the plan to first force all websites to use it and then to be able to block political not correct or not mainstream conform sites by disabling certificates.

I remember enabling "https" was related to the DuckDNS Add-on which I use and which I want to use also in the future (in the required case via "http"). But in the add-on configuration is no switch to enable or disable "https"

Maybe it is this part in configuration.yaml?

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
  ssl_certificate: /ssl/fullchain.pem
  ssl_key: /ssl/privkey.pem

Should I remove the ssl-parts?

andriej commented 3 years ago

^^ your approach is wrong in so many ways that I can't even start listing the issues. Securing your home (by encrypting traffic) is not bullshit, so at least don't spread misinformation widely.

Anyway, it's where you have declared your SSL keys and setting internal and external URL in configuration.

jjpeet commented 3 years ago

Hi @fwestenberg thanks for your hard work on this!!
My setup uses http (http://192.168.0.11:8123), and I also run a reverse proxy (Caddy) so the URL I normally use is https://hass.mydomain.com. I can visit HASS using either of these URLs inside my network.

Can you tell me how I can tell which one your integration is using? In my configuration.yaml, I have the http: section with no options at all - just http:

Thx JP

andriej commented 3 years ago

@jjpeet integration uses the URL provided by HA to it, so in HA Configuration (in UI) do you use domain name internally or it's HTTPs? (Internal and external both can be defined there)

jjpeet commented 3 years ago

@jjpeet integration uses the URL provided by HA to it, so in HA Configuration (in UI) do you use domain name internally or it's HTTPs?

(Internal and external both can be defined there)

Hi @andriej thanks for that I just checked and the only entry is the internal, and it's the http IP address.

So my motion sensors not working mustn't be related to https then I assume 👍

JP

aisbergde commented 3 years ago

@andriej

^^ your approach is wrong in so many ways that I can't even start listing the issues. Securing your home (by encrypting traffic) is not bullshit, so at least don't spread misinformation widely.

Securing is very important, but I don't trust US tech firms in this question. We see, what happens, if they have the monopoly: Censorship, shutdown of cloud services for political enemies. That's why I think SSL is a Trojan horse and the real goal is censorship. To my great chagrin, I (as a BI architect and developer) am completely dependent on Microsoft.

Anyway, it's where you have declared your SSL keys and setting internal and external URL in configuration.

Yes, this was very easy and now my motion sensors are working again. In case they will work with https I could enable https again (because there is no better way I know to secure).

andriej commented 3 years ago

Total offtopic so last post from my side on this topic: but you can always get an SSL not-for-free from issuer of choice (outside of US) or use free SSL cert i.e. from ZeroSSL which is EU-based. So I'm not quite sure how did you connect censorship of own home automation software to something that you can always choose from and disable at any time and is not connected to leaking any data except hostname.

aisbergde commented 3 years ago

Yes, total off-topic. Sorry for this.

@andriej you are right, it is a partial solution to get the SSL cert from outside US.

I think encryption in general is also (not only) a Trojan horse to lull individuals and companies into a false sense of security. We see that only encryption with backdoors is allowed and promoted. Real encrypted communication without backdoors for intelligence agencies is very strongly opposed. Genuine specialists in cryptography even have their careers destroyed on occasion to avoid the "threat" of real security. Services that are too secure are fought against.

And you are right, our own home automation software is not (yet) really related. And SSL is a good solution. That's why SSL was enabled until I needed to disable to get the motion sensors work. And I will enable again if this will work with SSL.

badabing2005 commented 3 years ago

@aisbergde Your statements are far fetched

IMHO "https" is a big bullshit and fake Even if US government or any other government can decrypt your ssl, it doesn't render https bullshit or fake, Http is plain text, which means anybody snooping the traffic can see it in plain sight. Do you prefer to be vulnerable to anyone who knows how to snoop, or do you rather be vulnerable to a government?

Of course your prefer neither, but their is a wide difference between one or the other.

In any case, this is still off topic, and this is also my last comments on this topic.

jjpeet commented 3 years ago

Hi @fwestenberg, just the last query related to this issue. Everything works perfectly except that all of my 5 motion sensors are unavailable. Can you let me know what you need from me to diagnose the issue? Thx JP

dave-parsons commented 3 years ago

@fwestenburg I love your work on this integration. Coming late to this, but having same issue with motion detection sensor. 7 cams connected to NVR 410 all work great but motion sensors unavailable. I started on .13. Http internal. I do have HA and CAMs on separate VLANS, but comms between HA and NVR are unrestricted. I get

Host 192.168.5.8 error renewing the Reolink subscription 12:39:43 PM – Reolink IP camera (ERROR) - message first occurred at 12:33:34 PM and shows up 49 times

Not sure where to go from here. Dave

dave-parsons commented 3 years ago

After multiple tests on .12 and.13, I've narrowed my motion detection woes down to having multiple cameras on the NVR. One channel works perfectly on either version. As soon as I add a second, I get the subscription error. Remove the second and it works again. Any ideas on how to fix?

gregoryduckworth commented 3 years ago

I completed the same testing as @dave-parsons and also do not get the subscription error when having a single camera. As soon as I add a second the issue reappears.

aisbergde commented 3 years ago

I often lost the motion, some sensors become not available. For now, I restart HASS to get them back. But is there a better way to re-enable the motion sensors?

dave-parsons commented 3 years ago

Restarting HASS doesn't work for me to get the sensors back. When I first add channels (cameras) 2-7 the entities are initially created and available. On HA restart - all motion sensors (other sensors are fine) become unavailable. Restart of HA, Supervisor, and / or host doesn't bring them back. Something to do with subscription but I'm not able to determine what. I've tested with all components on the same VLAN and no change, so that's not it.

badabing2005 commented 3 years ago

For NVR users, Get the code from this branch.

If after restarting HASS, you still have unavailable motion entities and are getting subscription errors, restart your NVR

Although the motion entities are active, I'd love to hear from you guys if you manage to get it to correctly trigger on anything other than camera 1. This is a Reolink NVR onvif implementation limitation, Reolink is currently working on a fix.

dave-parsons commented 3 years ago

Thank you @badabing2005.

  1. I replaced my custom_integration/reolink_dev with NVR-single-push-manager branch.
  2. I removed my reolink integration
  3. I restarted HA
  4. I added 7 cameras - all sensors added perfectly including motion
  5. I restarted HA - all motion sensors not available. Unfortunately no fix for me :(

Error below 2021-01-22 19:34:14 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.5.8 error renewing the Reolink subscription 2021-01-22 19:34:14 ERROR (MainThread) [custom_components.reolink_dev] Unexpected error fetching reolink data: 'ReolinkPush' object is not subscriptable

fwestenberg commented 3 years ago

I merged the branch @badabing2005 mentioned with the master. This branch implements the reuse of the push manager entity, so not every camera try to create it's own. Please see if the current master improves the situation.

jjpeet commented 3 years ago

I merged the branch @badabing2005 mentioned with the master. This branch implements the reuse of the push manager entity, so not every camera try to create it's own. Please see if the current master improves the situation.

Hi @fwestenberg, HACS doesn’t report an update is available. What’s the process to get the master branch you mentioned loaded into HASS?

Thx JP

fwestenberg commented 3 years ago

Just download the ZIP file from this branch. Copy all the files from the custom_components/reolink_dev folder to your HA custom_conponents/reolink_dev folder (and overwrite). If you reinstall or update the HACS component at some point, it will overwrite the files so nothing gets broken. Reboot after this action.

jjpeet commented 3 years ago

ok; I've done that, and restarted both HASS and the NVR. Still getting the following error 5 times (I have 5 cameras);

Let me know what else you'd like me to try... :)

Thx JP

`2021-01-24 05:45:07 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.0.46 error renewing the Reolink subscription 2021-01-24 05:45:07 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.0.46 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?>

Nonehttp://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeRequestSOAP-ENV:Sender `
Imperial-Guard commented 3 years ago

After updating with the version from this morning i'm facing the following issues.

2021-01-23 23:02:00 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/reolink_dev/base.py", line 177, in stop await self._hass.async_add_executor_job(func) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 418, in <lambda> return lambda: self.update_listeners.remove(weak_listener) ValueError: list.remove(x): x not in list 2021-01-23 23:02:00 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/config/custom_components/reolink_dev/base.py", line 177, in stop await self._hass.async_add_executor_job(func) File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 418, in <lambda> return lambda: self.update_listeners.remove(weak_listener) ValueError: list.remove(x): x not in list

fwestenberg commented 3 years ago

@Imperial-Guard this error has is just about deregistering the update function that's called after you called the options menu. For some reason, HA gives this error sometimes. Not always I noticed. It is for sure nog related to the binary function.

fwestenberg commented 3 years ago

@jjpeet can you try to give HA a reboot now? I expect the NVR still has too many subscriptions, which will be gone by now. Thanks!

Imperial-Guard commented 3 years ago

@fwestenberg all camera's removed and restarted Home Asisstant, seems to be that all motion sensors are unavailable.

Added the debug logs:

`2021-01-23 23:18:23 INFO (MainThread) [custom_components.reolink_dev.base] Host 192.168.30.45 subscribed successfully to webhook http://192.168.1.2:8123/api/webhook/48e1513e84744126780ad3fe376efbc27b3a061a081a1808fa382cd472fad2cc 2021-01-23 23:18:23 DEBUG (MainThread) [reolink.subscription_manager] Host 192.168.30.45 should renew in: 899 seconds... 2021-01-23 23:18:23 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.228 seconds 2021-01-23 23:18:41 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.30.112 got response status: 400. Payload: {<?xml version="1.0" encoding="UTF-8"?>

Nonehttp://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/RenewRequestSOAP-ENV:Sender } 2021-01-23 23:18:41 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.30.112 got response status: 400. Payload: { Nonehttp://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeRequestSOAP-ENV:Sender } 2021-01-23 23:18:41 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.30.112 error renewing the Reolink subscription 2021-01-23 23:18:41 DEBUG (MainThread) [reolink.subscription_manager] Reolink host 192.168.30.112 got response status: 200. Payload: { http://192.168.30.112:8000/onvif/Notification?Idx=00_22021-01-23T22:18:41Z2021-01-23T22:33:41Z } 2021-01-23 23:18:41 DEBUG (MainThread) [reolink.subscription_manager] Local time: 2021-01-23 22:18, camera time: 2021-01-23 22:18 (difference: -0.08797693252563477), termination time: 2021-01-23 22:33 2021-01-23 23:18:41 DEBUG (MainThread) [custom_components.reolink_dev] Finished fetching reolink data in 0.325 seconds `
fwestenberg commented 3 years ago

Thanks! Are you sure all are unavailable?? In the log host 192.168.30.112 gives a success message... I remember I did add some more code later today to the same branch. This might help here. But if you trigger motion, anything in the log?

Imperial-Guard commented 3 years ago

@fwestenberg after switching off and on IR lights, motion sensors are changed from unknown to no motion.

Small update: even with these updates I don't get any motion events in Home Assistant. While in the Reolink App I see the motion events from my camera.

dave-parsons commented 3 years ago

Fresh start on testing today.

  1. Rebooted NVR then Host with same NVR-single-push-manager branch
  2. ALL sensors available for first time! Cautious internal celebration :)
  3. Restart HA ... Half Motion Sensors Unavailable, Half Available :{
  4. Error below
Nonehttp://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeRequestSOAP-ENV:Sender
}
2021-01-23 14:06:08 ERROR (MainThread) [custom_components.reolink_dev.base] Host 192.168.5.8 error renewing the Reolink subscription
2021-01-23 14:06:08 ERROR (MainThread) [custom_components.reolink_dev] Unexpected error fetching reolink data: 'ReolinkPush' object is not subscriptable
  1. removed HACS integration. Reinstalled using master version
  2. restarted supervisor and HA
  3. None of the motion sensors available :(
  4. restarted NVR and rebooted host system (with simultaneous upgrade to supervisor-2021.01.5)
  5. ALL Motion Sensors UNavailable :(
fwestenberg commented 3 years ago

Thanks for testing and reporting. For sure NVR-single-push-manager branch creates too many subscriptions and this creates issues. Forget about this branch is my advice. The latest master had already a fix for the subscriptable error, but I did add it just 30? minutes ago. Any chance you can make sure all files from the latest master branch are there?

Imperial-Guard commented 3 years ago

I've did the checks with all the latest files, please keep in mind I don't have a NVR.

fwestenberg commented 3 years ago

No, me neither. But I'm running it with 3 different Reolink cams and all work well with this latest master. But because of an issue in all previous versions, the integration did not unsubscribe after a reboot/reload. So the camera got too many subscriptions.