Plugin Name: Temperature Averaging (TEMPAVG) Plugin v1.0
* Now available in the Apps Store
This plugin has one purpose: to take the CurrentTemperature values from existing temperature sensors/devices using [tt]urn:upnp-org:serviceId:TemperatureSensor1[/tt], average it and display it in its own device.
Here are the variables that the plugin will expose after it initializes:
Devices = a list of Sensors that will be checked.
- Format: Needs to be entered in the format of [sensor id#]=“name”
Example:
71=NewYork,82=LosAngeles,96=Seattle,102=Boston
Refresh = number of seconds to wait between checking the temperature sensors. Default is set to 60 seconds (1 minute). Min = 60, Max = 86400. Anything set/passed outside the min/max range will be ignored, and the default of 60 will be used. Setting this to 0 will disable the automatic polling.
VerboseDebug = turn on/off additional log messages for debugging
0 = Off (default)
1 = On
Additionally, two untested functions are exposed:
ForcePoll = Allows for you to call the polling/checking option in your own scripts/scenes
RestartPolling = Allows you to change to interval for polling. Same rules apply as for setting Refresh variable. You can use this to start or stop polling in your own code/scenes.
Example:
luup.call_action("urn:tempavg-sensor-org:device:TEMPAVG_Sensor1", "RestartPolling",{ delay= 0 }, 66)
This code would turn off polling for your TEMPAVG device (assuming your plugin is device #66)
See attached files for the code.
Please let me know if you find any bugs.
Note: This plugin doesn’t care what format the temperature is in, it just averages out the values it fetches from the temperature sensors/devices defined in Devices. This means that, if any of your sensors/devices are using a mix of different temperature scales (i.e., Fahrenheit and Celsius), the average will be wrong.