fwestenberg / reolink_dev

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

Switch for push notifications #250

Closed mama31 closed 3 years ago

mama31 commented 3 years ago

Hello,

Is it possible to expose the push notifications to HA. Recording, FTP, email are working fine but I didn't find the push function.

Thanks a lot for all the great job already!

Hamad

cpainchaud commented 3 years ago

I would love to get that one too !

maggar commented 3 years ago

Yes, this would be nice. Given that I enabled push notifications on the NVR and the Android client app, I'm hoping that by disabling just on the NVR, it would not send push notifications to any mobile device that had notifications turned on. That way I could I have an automation to toggle 'global' push notifications on certain events (switching to 'Night mode') and off again in the morning, rather than at times hardcoded on the NVR.

fischit commented 3 years ago

Even though this feature is in the latest 0.20 realease unfortunately it doesnt work for me. Pushing the button in HA does not change the status for the camera. Changing the status in the app does not change the status in HA. However, when I disable Push Notification in the App, disable it in HA as well (because it does not sync) and then reopen the App, push notification still deactivated there, it gets activated in HA.

There is nothing in the log. I'm new to HA so I dont know yet how to give you any more information to help you.

cpainchaud commented 3 years ago

Hi!

Depending on your firmware version it may not work (the latest versions had an API change which I requested Reolink support to clarify)

cpainchaud commented 3 years ago

should work now with next release using dependency version 0.23 , wait for @fwestenberg to publish it.

it does work in my lab

cpainchaud commented 3 years ago

changes are now live and should work with v0.21

markaggar commented 3 years ago

Thank you! I can confirm that I can now connect to the NVR and the push notification switch toggles the NVR push notification state! Note that as expected, toggling any camera push notification on/off does it for every camera managed by the NVR (although it's not reflected in HA straight away - not sure how long it takes to poll).

cpainchaud commented 3 years ago

@markaggar I don't think we can disable per camera in their API but I dont have any NVR to check the output of this one:

https://ip_address/cgi-bin/api.cgi?cmd=GetPushV20&rs=&user=admin&password=blabla

Can you get that for me?

mama31 commented 3 years ago

Hello. It doesn't work for me in 0.21. I removed the push switch from 0.20 as requested by HA and no new switch appeared. I only have cameras no NVR.

cpainchaud commented 3 years ago

@mama31 it's probably an HA caching issue or someting like that because at bare minimum the button MUST BE there, code change between 0.21 didn't change the button code itself only the way its trigger was processed.

Also please check if you have any error message in your logs. You can as well try to remove plugin-restart-add again plugin-restart to see if it gets better

markaggar commented 3 years ago

@cpainchaud here's the output of the URL that you requested. I note that there is a distinction between person/vehicle and regular motion detection. Is it possible to expose that as separate sensors?

[ { "cmd" : "GetPushV20", "code" : 0, "value" : { "Push" : { "enable" : 0, "schedule" : { "channel" : 0, "table" : { "AI_PEOPLE" : "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "AI_VEHICLE" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "MD" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" } } } } } ]

markaggar commented 3 years ago

@mama31 I think your issue may be related to on an old integration that didn't get cleaned up properly. On my system I have a bunch of entities from a camera that are still on my system even though the corresponding integration was deleted a while back. I removed them manually via configuration/entities.

mama31 commented 3 years ago

I tried many uninstall / reboots unsuccessfully. I tried to call https://ip_address/cgi-bin/api.cgi?cmd=GetPushV20&rs=&user=admin&password=blabla with my credentials and I got : [ { "cmd" : "Unknown", "code" : 1, "error" : { "detail" : "not support", "rspCode" : -9 } } ] I have an RLC-520 and RLC-423

mama31 commented 3 years ago

The push on the android app and the web interface are not consistent. It looks like the GetPushV20 doesn't work on my camera, but the GetPush exists but works only on the push of the web interface but no the android app. Very strange...

cpainchaud commented 3 years ago

The push on the android app and the web interface are not consistent. It looks like the GetPushV20 doesn't work on my camera, but the GetPush exists but works only on the push of the web interface but no the android app. Very strange...

Hi @mama31 , What firmware is it? GetPushV20 should be there.

Can you provide the output of : https://xxxxxxx/cgi-bin/api.cgi?cmd=GetDevInfo&user=admin&password=....

cpainchaud commented 3 years ago

@cpainchaud here's the output of the URL that you requested. I note that there is a distinction between person/vehicle and regular motion detection. Is it possible to expose that as separate sensors?

[ { "cmd" : "GetPushV20", "code" : 0, "value" : { "Push" : { "enable" : 0, "schedule" : { "channel" : 0, "table" : { "AI_PEOPLE" : "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111", "AI_VEHICLE" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "MD" : "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" } } } } } ]

@markaggar as of version 0.22 it's now exposed as sensors :)

markaggar commented 3 years ago

@cpainchaud, excellent! Thanks so much! Looking forward to trying it out!

mama31 commented 3 years ago

The push on the android app and the web interface are not consistent. It looks like the GetPushV20 doesn't work on my camera, but the GetPush exists but works only on the push of the web interface but no the android app. Very strange...

Hi @mama31 , What firmware is it? GetPushV20 should be there.

Can you provide the output of : https://xxxxxxx/cgi-bin/api.cgi?cmd=GetDevInfo&user=admin&password=....

I got this : [ { "cmd" : "GetDevInfo", "code" : 0, "value" : { "DevInfo" : { "B485" : 0, "IOInputNum" : 0, "IOOutputNum" : 0, "audioNum" : 1, "buildDay" : "build 20121112", "cfgVer" : "v3.0.0.0", "channelNum" : 1, "detail" : "IPC_515B16M5MS10E1W01100000001", "diskNum" : 1, "firmVer" : "v3.0.0.136_20121112", "frameworkVer" : 1, "hardVer" : "IPC_515B16M5M", "model" : "RLC-520", "name" : "Facade", "pakSuffix" : "IPC_515B16M5M", "serial" : "00000000065536", "type" : "IPC", "wifi" : 0 } } } ]

cpainchaud commented 3 years ago

Please also note that Push toggle on the App and in the API are totally independant! The one in API is GLOBAL (and not accessible to the App) and will turn off notitcations for any kind of device. The in APP concerns only your phone (which registers a googla/apple api token to receive notifications)

Concerning your issue, it might be caused by the fact only AI enabled models have PushV20, which is something I cannot confirm as Reolink has not communicated much about their API. I will try to issue a fix in the underlying library after @fwestenberg has given me access to that other repo

mama31 commented 3 years ago

Ah Ok, I've tested and you're right, so I guess everything was working in my case in the 0.19 with GetPush and I didn't see it as it wasn't visible in the Android App.

cpainchaud commented 3 years ago

I will issue a fix for GetPush vs GetPushV20 and let you know

cpainchaud commented 3 years ago

@mama31 please try with the new version 0.23. It make take 2 restarts instead of one : I have noticed that the underlying library 'reolink v0.24' was getting updated after HA had started . You can check for prsence of a file called 'site-packages/reolink-0.0.24.dist-info' on your system

mama31 commented 3 years ago

Hello, Thanks for the update! From a quick test, it seems HA captures the state properly but doesn't manage to change it.

markaggar commented 3 years ago

Neither version 24 nor 23 work for me - can't connect to camera. I've had to stay on V22.

Also, the sensors aren't working - they are not picking up motion. Wondering if there's a polling problem or if push notifications need to be turned on server side for the HA sensors to pick up changes?

cpainchaud commented 3 years ago

@markaggar 0.26 just released with same fixes which may impact you but please open your own ticket

fischit commented 3 years ago

Sorry for reopening, but it still doenst work for me. Installed 0.26 but HA always switches the button to "on" no matter what the camera has set.

cpainchaud commented 3 years ago

@fischit there is no way to see push notification states in the phone App or windows client. Remember what I wrote earlier:

"Please also note that Push toggle on the App and in the API are totally independant! The one in API is GLOBAL (and not accessible to the App) and will turn off notitcations for any kind of device. The in-APP toggle concerns only your phone (which registers a google/apple api token to receive notifications)"

mama31 commented 3 years ago

For information, I manage to switch in Insomnia the state of the API push : POST http://IP/cgi-bin/api.cgi?cmd=SetPush&user=xxx&password=xxx

[ { "cmd": "SetPush", "param": { "Push": { "schedule": { "enable": 1, "table": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" } } } } ]

So maybe it is something in the camera_api.py