Please add the possibility to add custom name-value pairs to each device for use by (for example) scripts. An example of what the screen could look like is shown below. The picture shows the properties page for a light has a custom attribute called "AutoOff", which has a value of 15. Multiple attributes can be specified and there is no restriction on the names listed in this list. The actual user interface can be designed completely different, this is just a mock-up to illustrate the idea.

- Device properties with custom attributes.jpg (115.06 KiB) Viewed 624 times
We can then add a script that may use the existence of a particular attribute to determine which devices the script needs to operate on and optionally the value to apply for this particular device. Here's an example of such a script. This example script will turn off each switch that has the "AutoOff" attribute and has been on for more minutes than the period specified in the "AutoOff"-value. It uses 2 new device-methods: hasAttribute(<name>) and attributeValue(<name>), the meaning of which should be pretty clear. Again, this is just a mock-up to illustrate the idea, the actual implementation may require other syntax or names:
Code: Select all
return {
on = {
timer = {
'every minute'
}
},
execute = function(domoticz, triggeredItem, info)
local Devices = domoticz.devices().filter
(
function(device)
if device.hasAttribute('AutoOff') and device.state == 'On' then
if device.lastUpdate.minutesAgo >= device.attibuteValue('AutoOff') then
return true
end
end
return false
end
)
Devices.forEach
(
function(d)
domoticz.log(d.name .. ' is switched off because it was on for to long.', domoticz.LOG_INFO)
d.switchOff()
end
)
end
}
Now, if I want to make more lights switch off automatically, I simply add the "AutoOff" attribute to that device. Also, if I want to change the period after which the light is switched off, I simply change the value for it's "AutoOff" attribute. After you've added the "AutoOff"-script once, there is no need to ever go into the scripts page any more and no need to remember device names or index values. Plus, it is a lot easier to see what functions apply to a particular device: all settings that apply to a device, are shown in the device's properties page and can be changed in that same page.