I would like to create a virtual temp-sensor. This sensor should get data from existing sensors that's been selected. The outcome from this sensor should be the average from the selected sensors.
Example:

Moderators: leecollings, remb0
That's why I want to suggest this as a new feature, so it might get implemented in next version.SweetPants wrote:You can't
You can, if you are prepared to make a lua script which reads the various values from different sensors, calculates the average, and write that back to the virtual temp-sensor. You'll have to alter the lua script to select which readings to involve in the calculation of the average.SweetPants wrote:You can't
I meant with "You can't", you can't get the 'dropdown' menu's in the sensor as panser pointed out. The only way now is to create multiple sensors to display your readings.pwhooftman wrote:You can, if you are prepared to make a lua script which reads the various values from different sensors, calculates the average, and write that back to the virtual temp-sensor. You'll have to alter the lua script to select which readings to involve in the calculation of the average.SweetPants wrote:You can't
Interesting. Unfortunately I don't know LUA....yet =) I will start to learn.Is it possible to create a virtual temp-sensor? (How?)pwhooftman wrote:You can, if you are prepared to make a lua script which reads the various values from different sensors, calculates the average, and write that back to the virtual temp-sensor. You'll have to alter the lua script to select which readings to involve in the calculation of the average.SweetPants wrote:You can't
There are two solutions:panser wrote:As I have 6-7 temp sensor's outside, it would be grate to have one virtual sensor that gives me the average of all those 6-7 sensors to get a more accurate reading.
Code: Select all
tmp1, hum1, humstat1 = string.match(otherdevices_svalues['Device1'], "(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*)")
tmp2, hum2 = string.match(otherdevices_svalues['Device2'], "(%d+%.*%d*);(%d+%.*%d*)")
tmp3 = otherdevices_svalues['Device3']
tmp4 = otherdevices_svalues['Device4']
tmp5, hum3 = string.match(otherdevices_svalues['Device5'], "(%d+%.*%d*);(%d+%.*%d*)")
commandArray = {}
time = os.date("*t")
if((time.min % 1)==0)then
local tempaverage = ((tmp1 + tmp2 + tmp3 + tmp4 + tmp5) / 5)
local humaverage = ((hum1 + hum2 + hum3) / 3)
local humstat = humstat1
commandArray['OpenURL'] = 'http://192.168.1.186:8080/json.htm?type=command¶m=udevice&idx=194&nvalue=0&svalue='..tempaverage..';'..humaverage..';'..humstat
end
return commandArray
Westscott,Westcott wrote:Panser,
Just a suggestion, but if it is a 'time' script, it will run every minute, so you don't need the 'if((time.min % 1)==0)then' check.
Also, have you tried updating device 194 directly, rather than with json?
E.g. commandArray['UpdateDevice'] = '194|0|'..tempaverage..';'..humaverage..';'..humstat
Code: Select all
-- Index for CommandArray update
i = 1
-- The Update function
function UpdateDevice(device, data)
-- Get the device index from its name
idx = otherdevices_idx[device]
commandArray[i] = {['UpdateDevice'] = idx..'|0|'..data}
i = i+1
end
-- Call it like this from your code
UpdateDevice('<deviceName>', '<yourData>')
Code: Select all
tmp1, hum1, humstat1 = string.match(otherdevices_svalues['Device1'], "(%d+%.*%d*);(%d+%.*%d*);(%d+%.*%d*)")
Users browsing this forum: No registered users and 1 guest