duanemck / ezviz.net

Experimental .net library for interacting with the Ezviz API. Based on the excellent work in https://github.com/BaQs/pyEzviz
MIT License
2 stars 0 forks source link

Battery level showing as 0 on Domotics #12

Open duanemck opened 1 year ago

duanemck commented 1 year ago

From #7

rezzalex commented 1 year ago

Hello @duanemck , did you have time to review that one ?

the topic to handle is "ezviz/status/_camreference/battery_level" the corresponding device in DZ is not updating anymore, but the others devices seems to have a correct battery indication icon :

image

image

duanemck commented 1 year ago

Is it only the 1 camera that is not getting battery updated? You have others that are updating?

I don't have any battery operated cameras, the API always returns 0 for mine.

Let me see if there's some way I can diagnose from the logs.

duanemck commented 1 year ago

I've pushed a new preview image with the tag PREVIEW_LOGGING

I have tweaked the request/response logging to allow config to log every response from the EZVIZ API.

In appSettings.json, under polling, make sure logAllResponses is true Then set requestLogLocation is set to /config/log

This will cause every response to be logged to a txt file in the folder where your appSettings is (in a /log subfolder)

If you want to log just 1 specific device, you can add logResponsesForDevice with the device serial number (or * to log all devices)

You should get a file there relatively soon after starting the container up again, the battery level is in the PagedResponse section, under Status.optionals there should be a key called powerRemaining which is the battery level.

duanemck commented 1 year ago

Important, don't leave the logAllReponses flag set to true forever, it will start to fill your disk up quickly depending on how many cameras you're tracking and how often it's polling

rezzalex commented 1 year ago

Thanks a lot but. Is the goal to validate what is the correct battery field , to then apply it to all "sub" DZ devices?

duanemck commented 1 year ago

The goal is to check what you are getting back from the API and make sure it gets all the way to DZ. I can't test it without a battery camera. So if you're able to see what value comes back (if any) then we can hopefully narrow it down to why it's not updating on DZ.

rezzalex commented 1 year ago

Hello @duanemck ,

here it is :

"C67332781": { "diskNum": 1, "diskState": "0---------------", "globalStatus": 0, "pirStatus": 0, "isEncrypt": 0, "encryptPwd": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "upgradeAvailable": 0, "upgradeProcess": 0, "upgradeStatus": 2, "alarmSoundMode": 1, "optionals": { "latestUnbandTime": "1582042965397", "updateCode": "0", "AlgorithmInfo": "[{\u0022SubType\u0022:\u00220\u0022,\u0022channel\u0022:1,\u0022Value\u0022:\u00223\u0022},{\u0022channel\u0022:1}]", "language": "ENG", "wanIp": "xxxxxxxxxxx", "powerRemaining": "88", "Route_LinkageStatus": "-1", "hfullViewURL": "", "daylightSavingTime": "1", "Battery_WorkStatus": "{\u0022KeepAlive\u0022:60,\u0022WorkTime\u0022:120}", "tzCode": "134", "updateProcessExtend": "", "diskHealth": "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1", "OnlineStatus": "1", "ChimeInfo": "{ \u0022type\u0022: 0, \u0022duration\u0022: 0 }", "timeZone": "UTC\u002B01:00", "cloudChannelList": "[{\u0022channel\u0022:0,\u0022status\u0022:0,\u0022type\u0022:0},{\u0022channel\u0022:1,\u0022status\u0022:0,\u0022type\u0022:0}]", "diskCapacity": "122112,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1", "kms_version": "100", "timeFormat": "2", "ICR": "1", "superState": "0", "voiceIndex": "0", "powerType": "1", "lastUpgradeTime": "1689697184075"

duanemck commented 1 year ago

OK, so you're definitely getting something back from the API. And I see now (somehow missed it before) that on MQTT explorer you're seeing the value come through. So the app is sending the value to MQTT correctly.

Sounds like it might be a Domoticz issue? Once it hits MQTT it's no longer withing ezviz.net.

It could possibly be an issue with the auto-discovery config, but you said you had other cameras that show the battery correctly?

rezzalex commented 1 year ago

In fact, only "sleeping", "PIR status" and most of all "Battery Level" have, for my 2 battery cameras, have a 0 value.

The rest seems OK... Is there something different for those MQTT topics ? :

IMG_20230920_232137.jpg

rezzalex commented 1 year ago

Our 3 problematic devices exist in several MQTT topics , could it come from that? :

I suspect those one have a "native" correct battery level information associated : ezviz/status/CAMREF/battery_level ezviz/status/CAMREF/pir_status ezviz/status/CAMREF/sleeping

but what about those :

ezviz/sensor/ezviz_CAMREF/ezviz_CAMREF_pir_status

payload :

{ "state_topic": "ezviz/status/CAMREF/pir_status", "availability": [ { "topic": "ezviz/lwt/CAMREF", "payload_available": "ON", "payload_not_available": "OFF" } ], "availability_mode": "latest", "device": { "connections": [ [ "MAC", "xxxxxxxxxxxx" ] ], "identifiers": [ "ezviz_CAMREF" ], "manufacturer": "Ezviz", "model": "BatteryCamera C3A", "name": "Sud", "sw_version": "V5.2.4 build 211115" }, "enabled_by_default": true, "encoding": "utf-8", "name": "Sud PiR Status", "unique_id": "ezviz_CAMREF_pir_status" }

This Battery level MQTT topic does not contain any battery level value :

ezviz/sensor/ezviz_CAMREF/ezviz_CAMREF_battery_level/config

payload :

{ "state_topic": "ezviz/status/CAMREF/battery_level", "device_class": "battery", "unit_of_measurement": "%", "availability": [ { "topic": "ezviz/lwt/CAMREF", "payload_available": "ON", "payload_not_available": "OFF" } ], "availability_mode": "latest", "device": { "connections": [ [ "MAC", "XXXXXXXXXXX" ]

Between those topics and some values in other topics, which one is used to create devices in DZ or HA ?

duanemck commented 1 year ago

The payloads you quoted there are the Auto Discovery messages. So for battery level it's saying that the level will be sent on the topic ezviz/status/CAMREF/battery_level . There won't be a battery level in that message.

You should see later messages on the topic ezviz/status/CAMREF/battery_level with the level (which I see in your MQTT explorer)

rezzalex commented 1 year ago

After deleting the 3x2 problematic devices in DZ, they had been recreated with the correct battery level Icon, but no specific "batterylevel" device has been recreated...

It Could be fine. Let me confirm in a couple of days...

rezzalex commented 11 months ago

Hello. Sorry, for the "couple of days" delay...

everything is fine concerning battery levels.

What docker Image should I use now ?

rezzalex commented 9 months ago

Hello @duanemck , it seems the autodiscovery is not working for the "new topics" : images, battery level, etc ... I have asked for direct connection on Discord, could be easier