I’m trying to enumerate the various devices in LUUP code for a scene. I currently have 6 thermostats with potentially more coming. I would like to make adjustments to my temperatures based on outdoor temp, and to plugin devices like GCal Google Calendar monitors. Essentially, I want to check the temperature at midnight and adjust schedules, target temps, etc. Instead of hard coding all of my device ID’s, I am hoping to be able to enumerate all of my devices and make any necessary adjustments.
I have tried using this as a basis:
for k,v in pairs(luup.devices) do
if( v.category_num==4) then
luup.log("SecurityDevice: " .. v.description )
elseif( v.category_num==17 ) then
...
end
end
It hasn’t been totally successful. I haven’t figured out what model I can use to enumerate the multiple services that a device might have (like Temperature Sensor and HVAC Heat in a single thermostat). Is there a way to essentially walk through the state(s) of the objects I see on my “Devices” tab? Do I need to use the user_data/sdata and parse it or does the object model allow me to walk it in a for/while/do or other loop?
Any help would be great. I’ve considered using naming conventions for devices and other strategies. I am trying to make my code a little more dynamic so future changes to the configuration do not require re-coding triggers and scheduled LUUP.
Brian