home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.2k stars 30.22k forks source link

REOLINK CAMERA: Support GetIrLights #98361

Closed JohnMcLear closed 1 year ago

JohnMcLear commented 1 year ago

Please auto assign to https://www.home-assistant.io/integrations/reolink/

The problem

Reolink cameras trigger a motion event on IR change. This results in a false positive.

This can be suppressed by an automation if the GetIrLights API endpoint is exposed to HA.

Page 335 of Reolink cam API docs has the URI and is exposed as https://IPC_IP/api.cgi?cmd=GetIrLights&token=TOKEN

Thanks!

What version of Home Assistant Core has the issue?

n/a

What was the last working version of Home Assistant Core?

n/a

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

JohnMcLear commented 1 year ago

Cc @starkillerOG

starkillerOG commented 1 year ago

The GetIrLights is already exposed as the "Infra red lights in night mode" entity state.

It does however not provide the current on/off state of the IR lights, but only if the IR lights turn on when the camera is in black&White (night) mode.

This is also explained in the docs.

JohnMcLear commented 1 year ago

Is there any way to get the current state of the IR lights?

starkillerOG commented 1 year ago

@JohnMcLear yes: combine the states of the "Infra red lights in night mode" entity and the select "Day night mode" entity state. When IR is ON and DayNight is set to Black&White they are ON, if it is set to "Color" They are off. When it is set to Auto, there is no way I know of to determine the state, unless you analyse the stream and see if it is in black&white or in color.

If you appreciate the reolink integration and want to support its development, please consider sponsering the upstream library or purchase Reolink products through this affiliate link.

JohnMcLear commented 1 year ago

I set "Day nighty mode" from Auto to Colour.

I then covered up the camera to trigger the IR lights to come on.

I set "Day nighty mode" from Colour to Black & White.

I then covered up the camera to trigger the IR lights to come on.

No states were changed other than the states I manually modified.

What am I missing here? I never see the "Infra red lights in night mode" state change.

Thanks for your time/efforts!

starkillerOG commented 1 year ago

@JohnMcLear No the states do not change and it is not possible to get the state of the IR light, however it is possible to predict the state:

When "Day nighty mode" is set to Black&White mode while "Infra red lights in night mode" is ON, The IR lights schould always be ON, regardless of the amount of light (I think), could you check if that is also true for your camera?

Wen "Day nighty mode" is set to Color mode (regardless of "Infra red lights in night mode"), the IR lights schould always be OFF,

Therefore if you use a automation to switch "Day nighty mode" between Black&White and Color instead of letting the camera do it on its own (auto), you know exactly when the IR lights will turn on.

starkillerOG commented 1 year ago

You could contact reolink support and request as a new feature an API command to retrieve the current status of the IR lights, once such a API command is available I can add it to HomeAssistant.

JohnMcLear commented 1 year ago

Oh I see. So make automation to change mode manually instead of using cameras baked in method. Gotcha. I'll give it a go. Thanks

starkillerOG commented 1 year ago

If that works, please let me know such that I van close the issue

JohnMcLear commented 1 year ago

If I try to call the service "Set Day/Night Mode" no entities are available.. The cameras are functioning properly..

image

As a workaround I can access the device properties directly but as the service exists I'm surprised it doesn't list the entities...

starkillerOG commented 1 year ago

@JohnMcLear there is not supposed to be a Set Day/Night Mode service, you are using a custom reolink component instead of the build-in reolink integration (which at this point has a lot more entities supported and countless bug fixes).

Please remove all reolink integrations, remove the reolink folder from your custom_components folder, restart HomeAssistant, and then setup the (build in) reolink integration again.

home-assistant[bot] commented 1 year ago

reolink documentation reolink source

JohnMcLear commented 1 year ago

oh wow great spot @starkillerOG , HACS integration was still left in there! Nicely done!

starkillerOG commented 1 year ago

You should be getting a lot more entities and also a select.daynight entity, that is the one you need.

JohnMcLear commented 1 year ago

@starkillerOG just for clarities sake, I am using the native integration but I had previously tested and used the HACS integration and the cruft you saw was from that.

starkillerOG commented 1 year ago

@JohnMcLear alright, I see. Did you get it working using the select.select_option service?

JohnMcLear commented 1 year ago

I did, fwiw I think this can be closed now.. Thanks for all your support.

I think the solution here is:

It's not ideal but it's the best we can do given the APIs exposed to us :)

If you appreciate this Reolink integration and want to support its development, please consider sponsoring the upstream library or purchase Reolink products through this affiliate link. <-- Slightly polished