Anyone up for creating a plugin (or code) that would create a virtual sensor (or switch) made up of the average values of a specific set of devices? Examples could be to give the average value of a number of temp sensors, light sensors, or even the average units that are on or off - I don’t think it would make a difference what you are measuring just need to define which devices you want to include. Once set up this “device’s” value can be used as a trigger for all sorts of things.
Anyone have time to do this? I wish I knew how and it seems fairly simple.
There is probably an easier way to do this but this works.
Create a Virtual Device. I created a Virtual Temperature because it will dispaly the Variable.
Go to Mios Developer. Create Device. Use “D_TemperatureSensor1” for the UpnpDevFilename and “S_TemperatureSensor1” for the UpnpImplFilename
Create a scene.
Add a timer to the scene that runs as often as you like. I set mine to every 2 minutes to test.
Add the following code to the LUUP in the scene:
local temp1 = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”,116)
local temp2 = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”,25)
local temp3 = luup.variable_get(“urn:upnp-org:serviceId:TemperatureSensor1”,“CurrentTemperature”,47)
S_TemperatureSensor1 is a service file and shouldn’t be used as an implementation file. The temperature sensor device doesn’t require any implementation file, because no actions are defined for it.
When creating a device it’s not necessary to specify the device type, because it is read from the device file.
After creating a device a reload of Luup is required. Otherwise the device will come up as a generic device.
I cannot seem to get this to work to trigger a scene - When I set the scene to trigger based on the temp of another thermostat it fires the scene just fine. When I use this virtual device it just doesn’t seem to work - I set the trigger as “temp goes below x”
I have read in a few other threads in the past day or two that people have issues with the trigger “temp goes below”. It sounds like you are experiencing the same issues as they are.
[quote=“garrettwp, post:10, topic:171528”]I have read in a few other threads in the past day or two that people have issues with the trigger “temp goes below”. It sounds like you are experiencing the same issues as they are.
Garrett[/quote]
it is so odd, The Google weather virtual sensor (which seems to be of the same type) triggers scenes and notifications just fine. Any idea why this Avg Temp sensor won’t trigger anything? I even tried changing the type to thermostat and it did nothing.
I couldn’t reproduce this. I tired both Temperature goes below and Temperature goes above and they triggered both notifications and scenes. Can you post here the full code that you’re using?
I am not using any code - i just created a scene that should trigger based on “temp goes above” - temp went above and nothing happens nor do I get a notification . There are no luup codes or conditions attached.