Code: Select all
-- example using an explicit set of names.
local mysensors = domoticz.devices({ 'sensor1', 'sensor2', 'sensor3' })
-- example using a variable that is a set of names
local switch_names = { 'switch1', 'switch2', 'switch8', 'switch 3' }
local myswitches = domoticz.devices(switch_names)
-- or using idx values:
local myothersensors = domoticz.devices({ 23, 31, 221, 222 })
-- or both mixed:
local mythingies = domoticz.devices( { 'switch3', 43 })
Some additional rules to make the behavior unambigious:
- If an empty set is passed in (f.e. domoticz.devices({})), an empty set should be returned. Do not raise an error like devices( <name/idx> ) does.
- if a name or an idx value is in the specified set that does not exist on a device in domoticz, ignore such non-existent names and idx-es. Do not raise an error. If you want to make sure all devices in a set exist, an easy check can be built using .filter(), or .foreach(). If however domoticz.devices({ <empty set or set with invalid name or idx> }) would raise an error, it is very hard to detect the situation and/or work around the error.
- the set can contain both idx values and names intermixed.
- if the same device can be identified by one or more names or idx values in the set, such device is only included once in the returned set. In other words, domoticz.devices({<set>}) always returns a set of unique devices.