starkillerOG / reolink_aio

Reolink NVR/camera API PyPI package
MIT License
65 stars 13 forks source link

CX410 WhiteLed LightAlarm values cannot be set #66

Closed ian1182 closed 2 months ago

ian1182 commented 3 months ago

Environment: Model: CX410 Hardware version: IPC_NT1NA44MP Firmware version: v3.1.0.2948_23112703

There are 4 or 5 modes which can be set in LightLed depending on the CX410 firmware level Off = 0 Night Smart = 1 Timer = 3 Smart = 4 Auto = 5

"Night Smart" is not available after firmware level 2207

Mode#4 makes use of the values in "LightAlarm" to determine when the spotlight should illuminate if movement is detected rather than those from "LightingSchedule" which is used by mode#3 (Timer) I believe. However there is no routine in the current reolnk_aio api to modify these values. Below is an extract of the values when "Smart Mode" is set as taken via "whiteled_settings". The "LightAlarm" values are present independent of the mode setting

"LightAlarm": { "EndHour": 5, "EndMin": 0, "StartHour": 20, "StartMin": 30 }, "LightingSchedule": { "EndHour": 6, "EndMin": 0, "StartHour": 18, "StartMin": 0 }, "bright": 51, "channel": 0, "mode": 4, "state": 0, "wlAiDetectType": { "dog_cat": 1, "people": 1, "vehicle": 0 }

Is it possible to add an option to set the "LightAlarm" values? Perhaps using an option on "set_spotlight_lighting_schedule" as the basic parameters are the same in each case.

The use of "LightAlarm" may also be present for the CX810 or E1 Outdoor CX cameras but I don't have access to either at the moment to verify

starkillerOG commented 2 months ago

@ian1182 the floodlight modes that are available for a particular camera can be retrieved from whiteled_mode_list, that will correctly identify the available modes of the CX410. "Night Smart" (called auto in the reolink_aio library) will not be available in this list on the newer firmware.

If you still want it I can add a function to change the schedual in the reolink_aio library, however I will not be adding this feature to HomeAssistant since setting scheduals in HomeAssistant is a bit too much for now. (there is already a overwhelming amount of entities in HomeAssistant).

Most people will not have to dynamically change the schedual. Moreover in HomeAssistant it makes more sence to have the "schedual" to be 24/7 and then let HomeAssistant swich the camera from mode "off" to "shedual" or "auto" or whatever you want. HomeAssistant has more info to decide when to put the camera spotlight in which mode and in that way you can make more advanced sheduals than just based on time (also possible in HA).

What would your application be to dynamically change the floodlight schedual times?

ian1182 commented 2 months ago

Thanks for the response. I don't use home automation but was rather using your excellent api to retrieve data from my cameras using some of my own python code.

When I got my CX410 I was playing with the spotlight settings to see what worked best. My aim was to have the spotlight come on when motion was detected in darker conditions. The problem I ran into with Smart Mode was that there seems to be no check in the camera for ambient light levels, so for example if the period was 18:00 to 06:00 the spotlight comes on whenever motion is detected during the specified period. I'm in the UK and in late June it's pointless the spotlight illuminating at 19:00 as it's still daylight but in late December it would be appropriate. My camera seems to be in a place of reasonable ambient light and with the Auto setting the spotlight rarely comes on at all. I realise this is not an automation problem but rather how the camera works.

Hence I was considering using a python routine to adjust the on/off period weekly to fit in with the changing seasons. But perhaps my original request was more basic in that there is a parameter in the camera "WhiteLed" options that has no support for retrieving or changing via the api - of course that may be intentional.

However in more closely looking at your code I saw it was easy to perform the action anyway using the generic "send_settings" with these parameters.

[{ "cmd": "SetWhiteLed", "param": {"channel": 0, "mode": 4, "state": 0, "WhiteLed": { "LightAlarm": {"StartHour": 21, "StartMin": 55, "EndHour": 4, "EndMin": 15 } } } } ]

I am ok with you leaving it as is. It was a good exercise for me in looking at your api to see how it retrieved info from the cameras plus running some python to change the settings.

starkillerOG commented 2 months ago

Thank you very much for your explanation. Nice to hear others are also using my reolink-aio library stand-alone.

I should really get to writing proper documentation for this library.... Always so much to do, hahaha

In that case I will leave the current code as is and close this issue.

If you need help in the future, don't hesitate to make a issue.