Page 1 of 1
How to write the battery level to a device?
Posted: Thursday 22 February 2024 16:34
by jvdk
I have a number of Zigbee temperature sensors connected to Domoticz via the Deconz plugin. The temperature and the humidity values of a sensor become separate devices in Domoticz. I use a dzVents script I found on Internet to combine these temperate and humidity values into one device.
The problem is, however, that the battery level of the sensor is not written into the new combined device. I can read the battery level of a device with:
local level = device.batteryLevel
How can I write the read battery level into the combined humidity/temperature device? I tried for example:
domoticz.devices('Bijkeuken').batteryLevel=domoticz.devices('$temperature Bijkeuken').batteryLevel
but that does not work.
I hope someone can help.
Regards,
Jan
Re: How to write the battery level to a device?
Posted: Thursday 22 February 2024 17:07
by waltervl
There is no setBatterylevel function in Dzvents like for other values.
You should ask the plugin owner to do that, no need to have a separate battery device and separate Temp and Hum devices.
Re: How to write the battery level to a device?
Posted: Thursday 22 February 2024 18:05
by DewGew
You can use domoticz api in dzVents:
Code: Select all
domoticz.openURL('http://ipadress/json.htm?type=command¶m=udevice&idx=<idx>&battery=<numeric value>')
Re: How to write the battery level to a device?
Posted: Friday 23 February 2024 12:14
by jvdk
DewGew wrote: ↑Thursday 22 February 2024 18:05
You can use domoticz api in dzVents:
Code: Select all
domoticz.openURL('http://ipadress/json.htm?type=command¶m=udevice&idx=<idx>&battery=<numeric value>')
When I try
http://192.168.1.2:8080/json.htm?type=c ... battery=20
I get the error:
{
"status": "ERR"
}
What I do wrong?
Regards,
Jan
Re: How to write the battery level to a device?
Posted: Friday 23 February 2024 13:04
by Kedi
When you send additional parameters like batterylevel you should also send the normal parameter(s)
See:
https://www.domoticz.com/wiki/Domoticz_ ... y_level.29
That's the way I do it in Nodered.
Re: How to write the battery level to a device?
Posted: Friday 23 February 2024 14:29
by Dave21w
It would be great if in the Devices list you could have a tick box next to the battery icon to say show battery level in device widget, the value would be visible at a glance then on any page.
Re: How to write the battery level to a device?
Posted: Friday 23 February 2024 15:04
by Kedi
Most battery operated devices last more then a year on a battery, besides in the device list you can sort on battery level, so you can see which due for a battery change.
You can also use one of the dzVents scripts that warn you when battery goes low.
So I don't think it is a good idea to have some icon/level indicator extra in the already crowded widget.
Re: How to write the battery level to a device?
Posted: Friday 23 February 2024 15:40
by jvdk
That works! Thanks!
I'll try to rewrite my current script to add the battery level.
regards,
Jan