Historical temperature only 4 hours.

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Kajzer
Posts: 5
Joined: Tuesday 07 June 2016 12:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Historical temperature only 4 hours.

Post 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?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Historical temperature only 4 hours.

Post 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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Historical temperature only 4 hours.

Post 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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Kajzer
Posts: 5
Joined: Tuesday 07 June 2016 12:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Historical temperature only 4 hours.

Post by Kajzer »

Thanks. I check this.
Post Reply

Who is online

Users browsing this forum: madpatrick and 1 guest