Using domoticz.devices(idx) for unused device returns nothing. Is this wanted behavior?

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

Moderator: leecollings

Post Reply
Timmiej93
Posts: 64
Joined: Saturday 26 December 2015 0:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Using domoticz.devices(idx) for unused device returns nothing. Is this wanted behavior?

Post by Timmiej93 »

My z-wave setup for domoticz is quite flaky. On a reboot, it has a 50/50 chance of getting up and running without needing help. Since I only have a couple of devices connected through z-wave, I'm not really interested in fixing it (since it's most likely due to me using a RaZberry v1), and I'd rather just set up an automated check, by looking at the last update for a device. However, the only value that updates regularly on the piece of hardware I'm interested in, is its power consumption data. The other 'devices' are things like the RGB channels, so they only change whenever the item gets used.

Now comes the issue though: If I try to get the device through domoticz.devices(deviceIdx), I get nothing for the power consumption device, most likely because it's not set to "used" in the devices tab, and I don't want it to be, since I don't care about the usage data, I only care about when it was last updated.

Is this wanted behavior? I feel like it's a bit weird for when I'm targeting a device directly by its index. Unused devices not showing up in the list when iterating through all devices, I can understand (although that probably should be an option too), but when I target a device directly by index, I expect to get its data, regardless if it's set to used or unused.

If this is wanted behavior, is there any way to get around it?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Using domoticz.devices(idx) for unused device returns nothing. Is this wanted behavior?

Post by waaren »

Timmiej93 wrote: Friday 05 February 2021 18:10 If this is wanted behavior, is there any way to get around it?
It is wanted behavior. If you have a unused device, you cannot expect it to be usable by dzVents or any other system.
Changing this behavior would mean that for many users the amount of device objects passed to dzVents will double or triple causing degraded response times.
The work around for users who want to get information in dzVents from unused devices would be to use a combination of openURL and httpResponses and process the result of http://<domoticz IP:domoticz PORT>/json.htm?type=devices&used=false
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Timmiej93
Posts: 64
Joined: Saturday 26 December 2015 0:37
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using domoticz.devices(idx) for unused device returns nothing. Is this wanted behavior?

Post by Timmiej93 »

Hmm, that's odd to me. Nevertheless, thank you for your reply and suggestion.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest