DzVents How can I reset History.size?  [Solved]

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

Moderator: leecollings

Post Reply
User avatar
Copitano
Posts: 64
Joined: Friday 28 June 2019 1:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: NL
Contact:

DzVents How can I reset History.size?

Post by Copitano »

I built a script to calculate the average of 60 readings from my SEM228T Pyranometer every 10 minutes. I have the script working to the extent that the 10 minute average is calculated every 10 seconds. However, that is a moving average. What I want is just write the average of the last 10 minutes to a General Custom Sensor once every 10 minutes and then calculate the average of the next 10 minutes and so on. What I have is the following:

Code: Select all

return
{
    
	on = {
        devices = {'Test Total solar radiation'}
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'SEM228T 10 min',
    },

    data =
    {
        SEM228THistory = { history = true, maxMinutes = 10},
    },

    execute = function(domoticz, sensor)

        -- add new data
        domoticz.data.SEM228THistory.add(sensor.radiation)

        -- average
        local RadAverage = domoticz.data.SEM228THistory.avg()
        domoticz.log('average radiation ' .. RadAverage, domoticz.LOG_INFO)

        -- maximum value in the past 10 minutes:
        local RadMax = domoticz.data.SEM228THistory.maxSince('00:10:00')
        domoticz.log('max radiation ' .. RadMax, domoticz.LOG_INFO)

        -- minimum value in the past 10 minutes:
        local RadMin = domoticz.data.SEM228THistory.minSince('00:10:00')
        domoticz.log('min radiation ' .. RadMin, domoticz.LOG_INFO)

	domoticz.log('SEM228THistory entries = ' .. domoticz.data.SEM228THistory.size, domoticz.LOG_DEBUG)

	if (domoticz.data.SEM228THistory.size > 59) then

	RoundAverage = domoticz.utils.round( (RadAverage),0)      
	domoticz.devices('SEM228T 10 min Av.').updateCustomSensor(RoundAverage)

	domoticz.devices('SEM228T 10 min Min.').updateCustomSensor(RadMin)

	domoticz.devices('SEM228T 10 min Max.').updateCustomSensor(RadMax)

           --domoticz.log('Not enough data points yet to produce something useful', domoticz.LOG_DEBUG)
           --domoticz.log(domoticz.data.SEM228THistory.size .. ' entries for ' .. SEM228THistory .. ' in History', domoticz.LOG_DEBUG)
	
	--reset()	

	end


       
    end
}
This is the output:

Code: Select all

2022-04-01 14:57:17.683 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 14:57:17.703 Status: dzVents: Info: SEM228T 10 min: average radiation 672.52542372881
2022-04-01 14:57:17.703 Status: dzVents: Info: SEM228T 10 min: max radiation 733
2022-04-01 14:57:17.703 Status: dzVents: Info: SEM228T 10 min: min radiation 368
2022-04-01 14:57:17.703 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 59
2022-04-01 14:57:17.708 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
The History entries just stays at 59 in the log. Attempts to reset it to 0 after calculating the average of the 60 measurements have so far failed. Well did I find this: https://www.domoticz.com/wiki/DzVents:_ ... %20Returns I tried to use it.
But I don't seem to understand how to use it. I get folowing error message:

Code: Select all

2022-04-01 14:47:17.736 Error: dzVents: Error: (3.1.7) SEM228T 10 min: An error occurred when calling event handler SEM228T10M
2022-04-01 14:47:17.736 Error: dzVents: Error: (3.1.7) SEM228T 10 min: /home/pi/domoticz/scripts/dzVents/scripts/SEM228T10M.lua:50: attempt to call a nil value (global 'reset')
when uncommenting reset()
or this when uncommenting the two rules above reset()

Code: Select all

2022-04-01 14:51:07.370 Error: dzVents: Error: (3.1.7) SEM228T 10 min: An error occurred when calling event handler SEM228T10M
2022-04-01 14:51:07.370 Error: dzVents: Error: (3.1.7) SEM228T 10 min: /home/pi/domoticz/scripts/dzVents/scripts/SEM228T10M.lua:48: attempt to concatenate a nil value (global 'SEM228THistory')
Pls. point me in the right direction.
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: DzVents How can I reset History.size?

Post by waltervl »

Add a timer trigger to the script ( every 10 minutes)
And check in the main script what the trigger is, device change or timer
When device change: update history
When timer trigger: update custom device

To check use something like

Code: Select all

return
{
    on =
    {
        timer =    { 'every 10 minutes', },
	devices = {'Test Total solar radiation'},
    },
        
    execute = function(domoticz, item)
        if item.isTimer then
            --- do Device update
        else
            -- do History update
        end
    end
}
There is no need to clear the history as it will be a running average.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Copitano
Posts: 64
Joined: Friday 28 June 2019 1:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: NL
Contact:

Re: DzVents How can I reset History.size?

Post by Copitano »

Working on it :D
Thanks again
User avatar
Copitano
Posts: 64
Joined: Friday 28 June 2019 1:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: NL
Contact:

Re: DzVents How can I reset History.size?

Post by Copitano »

waltervl wrote: Friday 01 April 2022 15:16 Add a timer trigger to the script ( every 10 minutes)
And check in the main script what the trigger is, device change or timer
When device change: update history
When timer trigger: update custom device

To check use something like

Code: Select all

return
{
    on =
    {
        timer =    { 'every 10 minutes', },
	devices = {'Test Total solar radiation'},
    },
        
    execute = function(domoticz, item)
        if item.isTimer then
            --- do Device update
        else
            -- do History update
        end
    end
}
There is no need to clear the history as it will be a running average.
Unfortunately an earlier error came back.
This is how the script looks right now:

Code: Select all

return
{
    
	on = {
	timer = { 'every 10 minutes', },
        devices = {'Test Total solar radiation'},
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = 'SEM228T 10 min',
    },

    data =
    {
        SEM228THistory = { history = true, maxMinutes = 10},
    },

    execute = function(domoticz, item)
        if item.isTimer then
        -- do Device update

	RoundAverage = domoticz.utils.round( (RadAverage),0)      
	domoticz.devices('SEM228T 10 min Av.').updateCustomSensor(RoundAverage)

	domoticz.devices('SEM228T 10 min Min.').updateCustomSensor(RadMin)

	domoticz.devices('SEM228T 10 min Max.').updateCustomSensor(RadMax)
	
	else

        -- add new data
        domoticz.data.SEM228THistory.add(sensor.radiation)
       
	-- average
        local RadAverage = domoticz.data.SEM228THistory.avg()
        domoticz.log('average radiation ' .. RadAverage, domoticz.LOG_INFO)

        -- maximum value in the past 10 minutes:
        local RadMax = domoticz.data.SEM228THistory.maxSince('00:10:00')
        domoticz.log('max radiation ' .. RadMax, domoticz.LOG_INFO)

        -- minimum value in the past 10 minutes:
        local RadMin = domoticz.data.SEM228THistory.minSince('00:10:00')
        domoticz.log('min radiation ' .. RadMin, domoticz.LOG_INFO)

	domoticz.log('SEM228THistory entries = ' .. domoticz.data.SEM228THistory.size, domoticz.LOG_DEBUG)

	--if (domoticz.data.SEM228THistory.size > 59) then

	--RoundAverage = domoticz.utils.round( (RadAverage),0)      
	--domoticz.devices('SEM228T 10 min Av.').updateCustomSensor(RoundAverage)

	--domoticz.devices('SEM228T 10 min Min.').updateCustomSensor(RadMin)

	--domoticz.devices('SEM228T 10 min Max.').updateCustomSensor(RadMax)

           --domoticz.log('Not enough data points yet to produce something useful', domoticz.LOG_DEBUG)
           --domoticz.log(domoticz.data.SEM228THistory.size .. ' entries for ' .. SEM228THistory .. ' in History', domoticz.LOG_DEBUG)
	
	--reset()	

	end


       
    end
}
This is the error I'm getting now:

Code: Select all

2022-04-01 17:09:59.314 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 17:09:59.316 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 17:09:59.316 Error: dzVents: Error: (3.1.7) SEM228T 10 min: An error occurred when calling event handler SEM228T10M
2022-04-01 17:09:59.316 Error: dzVents: Error: (3.1.7) SEM228T 10 min: /home/pi/domoticz/scripts/dzVents/scripts/SEM228T10M.lua:34: attempt to index a nil value (global 'sensor')
2022-04-01 17:10:00.173 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua:, trigger: "every 10 minutes"
2022-04-01 17:10:00.177 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Av.: Custom sensor device adapter
2022-04-01 17:10:00.178 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Min.: Custom sensor device adapter
2022-04-01 17:10:00.179 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Max.: Custom sensor device adapter
2022-04-01 17:10:00.180 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 17:10:00.175 Error: dzVents: Error: (3.1.7) SEM228T 10 min: nil is not a number!
line 34 is this one:

Code: Select all

        domoticz.data.SEM228THistory.add(sensor.radiation)
When I then replace the script with the original working one, it looks like it is runing perfectly for one run:

Code: Select all

2022-04-01 16:24:29.482 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 16:24:29.501 Status: dzVents: Info: SEM228T 10 min: average radiation 576.41071428571
2022-04-01 16:24:29.501 Status: dzVents: Info: SEM228T 10 min: max radiation 700
2022-04-01 16:24:29.501 Status: dzVents: Info: SEM228T 10 min: min radiation 264
2022-04-01 16:24:29.501 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 56
2022-04-01 16:24:29.505 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 16:24:39.462 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 16:24:39.481 Status: dzVents: Info: SEM228T 10 min: average radiation 578.10526315789
2022-04-01 16:24:39.481 Status: dzVents: Info: SEM228T 10 min: max radiation 700
2022-04-01 16:24:39.481 Status: dzVents: Info: SEM228T 10 min: min radiation 264
2022-04-01 16:24:39.481 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 57
2022-04-01 16:24:39.486 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 16:24:49.339 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 16:24:49.359 Status: dzVents: Info: SEM228T 10 min: average radiation 580.25862068966
2022-04-01 16:24:49.359 Status: dzVents: Info: SEM228T 10 min: max radiation 703
2022-04-01 16:24:49.359 Status: dzVents: Info: SEM228T 10 min: min radiation 264
2022-04-01 16:24:49.359 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 58
2022-04-01 16:24:49.365 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 16:24:59.587 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 16:24:59.606 Status: dzVents: Info: SEM228T 10 min: average radiation 582.47457627119
2022-04-01 16:24:59.607 Status: dzVents: Info: SEM228T 10 min: max radiation 711
2022-04-01 16:24:59.607 Status: dzVents: Info: SEM228T 10 min: min radiation 264
2022-04-01 16:24:59.607 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 59
2022-04-01 16:24:59.788 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 16:25:09.728 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 16:25:09.752 Status: dzVents: Info: SEM228T 10 min: average radiation 584.66666666667
2022-04-01 16:25:09.752 Status: dzVents: Info: SEM228T 10 min: max radiation 714
2022-04-01 16:25:09.753 Status: dzVents: Info: SEM228T 10 min: min radiation 264
2022-04-01 16:25:09.753 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 60
2022-04-01 16:25:09.755 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Av.: Custom sensor device adapter
2022-04-01 16:25:09.759 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Min.: Custom sensor device adapter
2022-04-01 16:25:09.760 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Max.: Custom sensor device adapter
2022-04-01 16:25:09.760 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 16:25:09.760 Error: dzVents: Error: (3.1.7) SEM228T 10 min: An error occurred when calling event handler SEM228T10M
2022-04-01 16:25:09.760 Error: dzVents: Error: (3.1.7) SEM228T 10 min: /home/pi/domoticz/scripts/dzVents/scripts/SEM228T10M.lua:48: attempt to concatenate a nil value (global 'SEM228THistory')
And after that SEM228THistory entries freezes at 59, somewhat later 66

Code: Select all

2022-04-01 16:30:19.573 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 16:30:19.592 Status: dzVents: Info: SEM228T 10 min: average radiation 538.20338983051
2022-04-01 16:30:19.592 Status: dzVents: Info: SEM228T 10 min: max radiation 711
2022-04-01 16:30:19.592 Status: dzVents: Info: SEM228T 10 min: min radiation 255
2022-04-01 16:30:19.592 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 59
2022-04-01 16:30:19.597 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 16:30:29.485 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 16:30:29.504 Status: dzVents: Info: SEM228T 10 min: average radiation 536.15254237288
2022-04-01 16:30:29.505 Status: dzVents: Info: SEM228T 10 min: max radiation 711
2022-04-01 16:30:29.505 Status: dzVents: Info: SEM228T 10 min: min radiation 255
2022-04-01 16:30:29.505 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 59
2022-04-01 16:30:29.509 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua

2022-04-01 17:49:29.484 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 17:49:29.505 Status: dzVents: Info: SEM228T 10 min: average radiation 371.34848484848
2022-04-01 17:49:29.506 Status: dzVents: Info: SEM228T 10 min: max radiation 397
2022-04-01 17:49:29.506 Status: dzVents: Info: SEM228T 10 min: min radiation 283
2022-04-01 17:49:29.506 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 66
2022-04-01 17:49:29.507 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Av.: Custom sensor device adapter
2022-04-01 17:49:29.508 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Min.: Custom sensor device adapter
2022-04-01 17:49:29.509 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Max.: Custom sensor device adapter
2022-04-01 17:49:29.514 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: DzVents How can I reset History.size?  [Solved]

Post by waltervl »

Replace
domoticz.data.SEM228THistory.add(sensor.radiation)
By
domoticz.data.SEM228THistory.add(item.radiation)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Copitano
Posts: 64
Joined: Friday 28 June 2019 1:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: NL
Contact:

Re: DzVents How can I reset History.size?

Post by Copitano »

waltervl wrote: Friday 01 April 2022 18:00 Replace
domoticz.data.SEM228THistory.add(sensor.radiation)
By
domoticz.data.SEM228THistory.add(item.radiation)
Unfortunately:

Code: Select all

2022-04-01 19:50:13.618 Error: dzVents: Error: (3.1.7) SEM228T 10 min: Item data is not a number type. Type is nil
2022-04-01 19:50:13.618 Error: dzVents: Error: (3.1.7) SEM228T 10 min: An error occurred when calling event handler SEM228T10M
2022-04-01 19:50:13.618 Error: dzVents: Error: (3.1.7) SEM228T 10 min: /home/pi/domoticz/dzVents/runtime/HistoricalStorage.lua:289: attempt to perform arithmetic on a nil value (local 'sum')
nil issue keeps comming back :?:

EDIT: Think I got it :D

Code: Select all

022-04-01 21:26:31.597 Status: dzVents: Info: SEM228T 10 min: average radiation 0.0
2022-04-01 21:26:31.598 Status: dzVents: Info: SEM228T 10 min: max radiation 0
2022-04-01 21:26:31.598 Status: dzVents: Info: SEM228T 10 min: min radiation 0
2022-04-01 21:26:31.598 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 59
2022-04-01 21:26:31.602 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 21:26:41.577 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 21:26:41.596 Status: dzVents: Info: SEM228T 10 min: average radiation 0.0
2022-04-01 21:26:41.596 Status: dzVents: Info: SEM228T 10 min: max radiation 0
2022-04-01 21:26:41.597 Status: dzVents: Info: SEM228T 10 min: min radiation 0
2022-04-01 21:26:41.597 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 60
2022-04-01 21:26:41.598 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Av.: Custom sensor device adapter
2022-04-01 21:26:41.599 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Min.: Custom sensor device adapter
2022-04-01 21:26:41.600 Status: dzVents: Debug: SEM228T 10 min: Processing device-adapter for SEM228T 10 min Max.: Custom sensor device adapter
2022-04-01 21:26:42.452 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 21:26:51.694 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 21:26:51.695 Status: dzVents: Info: SEM228T 10 min: average radiation 0.0
2022-04-01 21:26:51.695 Status: dzVents: Info: SEM228T 10 min: max radiation 0
2022-04-01 21:26:51.695 Status: dzVents: Info: SEM228T 10 min: min radiation 0
2022-04-01 21:26:51.695 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 1
2022-04-01 21:26:51.696 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 21:27:01.450 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
2022-04-01 21:27:01.451 Status: dzVents: Info: SEM228T 10 min: average radiation 0.0
2022-04-01 21:27:01.451 Status: dzVents: Info: SEM228T 10 min: max radiation 0
2022-04-01 21:27:01.451 Status: dzVents: Info: SEM228T 10 min: min radiation 0
2022-04-01 21:27:01.451 Status: dzVents: Debug: SEM228T 10 min: SEM228THistory entries = 2
2022-04-01 21:27:01.452 Status: dzVents: Info: SEM228T 10 min: ------ Finished SEM228T10M.lua
2022-04-01 21:27:11.295 Status: dzVents: Info: SEM228T 10 min: ------ Start external script: SEM228T10M.lua: Device: "Test Total solar radiation (Test Total solar radiation)", Index: 610
Reset History should be done like this:

Code: Select all

domoticz.data.SEM228THistory.reset()
Testing tomorrow when the sun is shinning ;) :lol:
User avatar
waltervl
Posts: 6691
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: DzVents How can I reset History.size?

Post by waltervl »

That is good news.
But I think there is no need to reset the history every 10 minutes as it will take the history of the last 60 samples as that is what is stored in the history data table. So if sample 61 is added, sample 1 is deleted.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Copitano
Posts: 64
Joined: Friday 28 June 2019 1:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: NL
Contact:

Re: DzVents How can I reset History.size?

Post by Copitano »

waltervl wrote: Saturday 02 April 2022 0:23 That is good news.
But I think there is no need to reset the history every 10 minutes as it will take the history of the last 60 samples as that is what is stored in the history data table. So if sample 61 is added, sample 1 is deleted.
I think this is more or less the same way KNMI calculates its 10 minutes average global radiation, publised by Buienradar every 10 minutes. Those are chunks of 10 minutes measurements. So setting everything to zero every 10 minutes maybe exactly what I want to achief. I will try to check tomorrow end of the day if it makes any sense compared tot the KNMI data of a weatherstation only 5 km away from my home.
I'll let you know ;) .
User avatar
Copitano
Posts: 64
Joined: Friday 28 June 2019 1:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: NL
Contact:

Re: DzVents How can I reset History.size?

Post by Copitano »

Schermafbeelding 2022-04-03 233820.jpg
Schermafbeelding 2022-04-03 233820.jpg (176.59 KiB) Viewed 807 times
waltervl wrote: Saturday 02 April 2022 0:23 That is good news.
But I think there is no need to reset the history every 10 minutes as it will take the history of the last 60 samples as that is what is stored in the history data table. So if sample 61 is added, sample 1 is deleted.
After one day of testing I think the script is exactly doing what I want it to do. Now I only need one or rather a few clear sky days to calibrate with a nearby official weatherstation. In the graph that is "solar radiation" of KNMI station Berkhout about 5 km as the crow flies from my house .
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest