DzVents/LUA: How to identify PIR devices?
Moderators: leecollings, remb0
-
rrozema
- Posts: 470
- Joined: Thursday 26 October 2017 13:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Delft
- Contact:
DzVents/LUA: How to identify PIR devices?
I have several z-wave PIR devices (infra red motion detection) in my home, of various brands and all work fine. They can be used in scripts to switch lights on and off, etc. That is, if you known the name or idx-number of the PIR device. I would like to find automatically all PIR devices from groups like domoticz.devices() without having to specify their name/idx value. So I had a look at the properties exposed for these devices using device.dump() and it turns out they are identified like any normal switch. For example: deviceType: Light/Switch, subType: Switch, switchType: On/Off. I have not been able to locate any property that is unique to a PIR device. Please anyone, can you give me a property that could be useful for this purpose?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: DzVents/LUA: How to identify PIR devices?
If the trigger devices can be identified by a wildcard you could use the description field
domoticz.devices().forEach(function(device)
if device.description ~= nil then
to identify the PIR devices based on what you put in the description field.
domoticz.devices().forEach(function(device)
if device.description ~= nil then
to identify the PIR devices based on what you put in the description field.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
rrozema
- Posts: 470
- Joined: Thursday 26 October 2017 13:37
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Delft
- Contact:
Re: DzVents/LUA: How to identify PIR devices?
Yeah, I had that idea too. I think I'm going to put json in those description fields, so I can put a lot more information in there, not just for this one purpose. I have entered a suggestion some time ago to have a field added to each device that should contain json for use by scripts. But as long as such a field is not there I think I will have to mis-use the description fields for this purpose.waaren wrote: Tuesday 03 April 2018 12:39 If the trigger devices can be identified by a wildcard you could use the description field
domoticz.devices().forEach(function(device)
if device.description ~= nil then
to identify the PIR devices based on what you put in the description field.
I was hoping that some way of detecting the type of devices existed already. Using this workaround I still need to enter some data for each device. It's a big improvement over having to enter the names/idx values into the scripts, but it would be even better if I could detect the device type programmatically.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: DzVents/LUA: How to identify PIR devices?
Good idea; I already use the description field for multiple additional "device attributes"
to identify when a device should be considered dead
or
to identify when a light should be switched off (in case the initial off command failed, which sometimes happens with my rflink)
These additional attributes can live together in the description area.
Code: Select all
domoticz.devices().forEach(function(device)
if (device.description ~= nil) then
_, _, threshold = string.find(device.description,"CDA:(%d+)")
or
Code: Select all
domoticz.devices().forEach(function(device)
if (device.description ~= nil) then
_, _, threshold = string.find(device.description,"MaxOnTime:(%d+)")
These additional attributes can live together in the description area.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest