How to write the battery level to a device?

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
jvdk
Posts: 38
Joined: Sunday 11 August 2019 17:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to write the battery level to a device?

Post 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
User avatar
waltervl
Posts: 5843
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: How to write the battery level to a device?

Post 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.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
DewGew
Posts: 581
Joined: Thursday 21 April 2016 12:01
Target OS: Raspberry Pi / ODroid
Domoticz version: V4.10618
Location: Sweden
Contact:

Re: How to write the battery level to a device?

Post by DewGew »

You can use domoticz api in dzVents:

Code: Select all

 domoticz.openURL('http://ipadress/json.htm?type=command&param=udevice&idx=<idx>&battery=<numeric value>')
Raspberry Pi 3 | domoticz | Aeon Labs Z-Stick GEN5 | RFlink gateway
NanoPi NEO-air | REGO6XX interface | Machinon theme | Homebridge | Domoticz Google Assistant | ideAlarm
jvdk
Posts: 38
Joined: Sunday 11 August 2019 17:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to write the battery level to a device?

Post 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&param=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
Kedi
Posts: 575
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to write the battery level to a device?

Post 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.
Logic will get you from A to B. Imagination will take you everywhere.
Dave21w
Posts: 381
Joined: Sunday 29 November 2015 21:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: UK
Contact:

Re: How to write the battery level to a device?

Post 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.
Kedi
Posts: 575
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: How to write the battery level to a device?

Post 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.
Logic will get you from A to B. Imagination will take you everywhere.
jvdk
Posts: 38
Joined: Sunday 11 August 2019 17:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to write the battery level to a device?

Post by jvdk »

Kedi wrote: Friday 23 February 2024 13:04 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.
That works! Thanks!
I'll try to rewrite my current script to add the battery level.

regards,
Jan
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest