for u,v in pairs(luup.devices)
do
if luup.device_supports_service( 'urn:upnp-org:serviceId:SwitchPower1', v.udn )
then
luup.log( 'Service OK: '.. v.description )
end
end
plausible?
Some of my motion sensors and some of my HSM100 show up …
You should replace: if luup.device_supports_service( ‘urn:upnp-org:serviceId:SwitchPower1’, v.udn )
with: if luup.device_supports_service( ‘urn:upnp-org:serviceId:SwitchPower1’, v.udn ) == “1”
In Lua, any value but nil is considered true, so even if luup.device_supports_service returns “0”, the expression it’s considered true.
I could be wrong, but I thought I came across this function a couple weeks ago in one of the stock Vera energy-related XML files. You may be able to check how mcv uses it - I believe they are using it to go through all devices to see if they support energy metering.
for u,v in pairs(luup.devices)
do
local res = luup.device_supports_service( 'urn:upnp-org:serviceId:SwitchPower1', v.udn )
luup.log('TTT '..type(res)..' '..tostring(res))
if res
then
luup.log( 'Service OK1: '.. v.description )
end
end
luup.log( 'Service OK End')
and the HSM100 itself is an [tt]urn:schemas-micasaverde-com:device:ComboDevice:1[/tt].
AFAIK, GenericIO is used for the Danfoss ‘thermostat’, not for the HSM100.
… and there is a standalone motion sensor (battery-operated) on my list (not shown in my previous posting), which - according to Vera - does support ‘urn:upnp-org:serviceId:SwitchPower1’ …
the function just checks to see if either a command or state variable is defined for the device using that service. So if you set a variable with the switchpower service for the hsm100, then the hsm100 will be listed as supporting switchpower. Setting upnp variables is unrestricted and free form, and the engine doesn’t real know if a device actually uses it or does anything with it. So this function isn’t really definitive. In our Luup code we usually use the category instead to see what type of device it is and have hardcoded rules for lights, thermostats, etc.
IIUC, the device category gets mapped to a static(?) set of UPnP services. It shouldn’t be too difficult to use this mapping to implement a bullet-proof version of [tt]device_supports_service[/tt].
Best Home Automation shopping experience. Shop at Ezlo!