I wrote script, which update to two dummy sensors (name: temp_max, temp_min) maximum and minimum temperature from 12 hours. Simply I need two sensors with 12 hours historical minimum and maximum temperatures from realy sensor temperature (name: Stacja).
Code: Select all
return {
active = true,
on = {
devices = {'Stacja'}
},
data = {
temperatures = { history = true}
},
execute = function(domoticz, sensor)
-- add new data
domoticz.data.temperatures.add(sensor.temperature)
-- maximum value in the 12 hours:
local max = domoticz.round(domoticz.data.temperatures.maxSince('12:00:00'),2)
-- minimum value in the 12 hours:
local min = domoticz.round(domoticz.data.temperatures.minSince('12:00:00'),2)
domoticz.devices('temp_max').updateTemperature(max)
domoticz.devices('temp_min').updateTemperature(min)
end
}
Dummy sensor temp_max and temp_min display minimal temperature from only 4 hours.

Where is the problem?