I want avgtemp with two decimal places
Posted: Monday 23 December 2019 14:03
A simple script gives me the average of two sensors
I get the result as in the logs
how to make the result be e.g. 21.53? What I do below does not work
Code: Select all
return {
on = { timer = { 'every 2 minutes' }},
execute = function(dz, item)
local Temp1 = dz.devices('Temp Salon').temperature
local Temp2 = dz.devices('Temp Biuro').temperature
local Tempavg = (Temp1+Temp2)/2
dz.devices('Temp Srednia').updateTemperature(Tempavg)
dz.log('Średnia wyliczona temperatura: ' .. Tempavg, dz.LOG_INFO)
end
} Code: Select all
2019-12-23 12:58:00.359 Status: dzVents: Info: ------ Start internal script: Srednia:, trigger: every 2 minutes
2019-12-23 12:58:00.362 Status: dzVents: Info: Średnia wyliczona temperatura: 21.529999732971
2019-12-23 12:58:00.362 Status: dzVents: Info: ------ Finished Srednia
Code: Select all
return {
on = { timer = { 'every 2 minutes' }},
execute = function(dz, item)
local Temp1 = dz.devices('Temp Salon').temperature
local Temp2 = dz.devices('Temp Biuro').temperature
local decimals = 2
local Tempavg = ((Temp1+Temp2)/2).decimals
dz.devices('Temp Srednia').updateTemperature(Tempavg)
dz.log('Średnia wyliczona temperatura: ' .. Tempavg, dz.LOG_INFO)
end
}