Page 1 of 1

Historical temperature only 4 hours.

Posted: Tuesday 23 January 2018 9:35
by Kajzer
Hi,
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
    }
    
So, script working good. In logs I haven't no errors. But!

Dummy sensor temp_max and temp_min display minimal temperature from only 4 hours.
Image
Where is the problem?

Re: Historical temperature only 4 hours.

Posted: Tuesday 23 January 2018 10:54
by dannybloe
Right now there is a maximum of 100 items that can be stored in an historical variable to make sure things keep performing. For every event the entire historical set is read from disk (it's just a text file). So if this gets too big things might get slow. After all it's not intended to be a database like feature. So, what you can do is limit the amount of samples or do pre-calculations of some sorts.
I know that 100 is quite arbitrary that should be changed perhaps.

Re: Historical temperature only 4 hours.

Posted: Tuesday 23 January 2018 11:50
by dannybloe
I removed this fixed limit in 2.4.0. So, if you do not specify a limit then it will be fixed to 100 but if you do, then that amount is taken.

Re: Historical temperature only 4 hours.

Posted: Tuesday 23 January 2018 13:19
by Kajzer
Thanks. I check this.