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
4 stars 0 forks source link

Auto discover a "general text device" to set the last alarm picture when alarm occurs #11

Open duanemck opened 10 months ago

duanemck commented 10 months ago

From #7

rezzalex commented 9 months ago

Hello @duanemck , did you have time to review that one ? How can I help ?

duanemck commented 9 months ago

I can set it up to set a sensor to the picUrl when an alarm occurs but it won't be much use to you. The picUrl can only be viewed with an authenticated session on the API.

The alarm MQTT message sends the picture as a Base64 encoded image, I can spin that out into a standalone sensor too but you'll need to figure out how to decode and display that in Domoticz.

rezzalex commented 9 months ago

Thank you.

The idea would be to authenticate, decode and download the image so that Dz could send the snapshot with Telegram, for instance.

duanemck commented 9 months ago

OK, if you have the ability to authenticate before downloading then it should work. Let me see what I can do.

Just to check that we're aligned, the "general text device" should be a separate device from the camera? i.e. not a property of the camera?

rezzalex commented 9 months ago

https://www.domoticz.com/wiki/Developing_a_Python_plugin#Devices

Paragraph 4.5

Device type general (243), text (19)

Or a "user variable", both offers the possibility to read a character chain...

https://www.domoticz.com/wiki/User_variables

I hope it helps.

duanemck commented 9 months ago

OK, I'll give that a read and see how it maps to the HA Autodiscover messages.

duanemck commented 9 months ago

I don't see a way to create a General Text device through the MQTT auto discovery image

The links you sent above are for developing custom Domoticz plugins and unfortunately that's not something I am able to do as I don't have a Domoticz instance and don't know Python very well.

duanemck commented 9 months ago

What I have done so far is add an additional image sensor/attribute to the Camera device that contains the last alarm image as Base64 as well as a regular sensor/attribute with the PicUrl.

I'm not sure if you're able to use either of those? I will release that change shortly.

rezzalex commented 9 months ago

I'm not sure if you're able to use either of those? I will release that change shortly.

I don't know yet .... how the 2 infos picURL and Base64 image are different. :

duanemck commented 9 months ago

picUrl is a link to the image on the ezviz API, you can download from there if you can authenticate. Base64 is a way to encode binary data as strings. So it's the actual image data, you will need to convert it back to a binary file though.

HA supports it natively, but this should give you an idea of how it works: https://codebeautify.org/base64-to-image-converter

rezzalex commented 6 months ago

Hello @duanemck ,

While using the latest docker Image :

In this auto discovery topic : "dz_ezviz/camera/ezviz_D67745001/ezviz_D67745001_camera/config" , I can see that specified as real status topic : " { "image_encoding": "b64", "topic": "ezviz/status/D67745001/image/set", ....

But I don't have this topic anywhere...

Beside that, the autodiscovery prefix for . Last Alarm . last alarm URL . Alarm_schedule_enable

are not working, no devices are created in DZ. For those topics, no "device class" is specified in the topic; is it normal ?

rezzalex commented 6 months ago

Also, for inspiration, Here is an auto discovery topic for a zwave device that creates a TEXT device in Domoticz :

Could it be used for the base 64 image ?

image

{ "value_template": "{{ {22: \"Window/door is open\",23: \"Window/door is closed\",5632: \"Window/door is open in regular position\",5633: \"Window/door is open in tilt position\"}[value_json.value] | default(value_json.value) }}", "icon": "mdi:alarm-light", "state_topic": "zwave/Chambre_Arthur/multi_capteur_fenêtre_ch_Arthur/113/0/Access_Control/Door_state", "json_attributes_topic": "zwave/Chambre_Arthur/multi_capteur_fenêtre_ch_Arthur/113/0/Access_Control/Door_state", "device": { "identifiers": ["zwavejs2mqtt_0xe573130e_node50"], "manufacturer": "Philio Technology Corp", "model": "Slim Multi-Sensor (PIR/Door/Temperature/Illumination) (PST02A)", "name": "Chambre Arthur-multi capteur fenêtre ch Arthur", "sw_version": "1.16" }, "name": "Chambre Arthur-multi capteur fenêtre ch Arthur_notification_access_control_door_state", "unique_id": "zwavejs2mqtt_0xe573130e_50-113-0-Access_Control-Door_state" }