Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Moderator: leecollings
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Actually, you should try to prevent at all times to manipulate globals in your library functions. Always a huge risk. Just pass whatever you need as parameters to you function. A function is ideally unaware and independent of its environment.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 485
- Joined: Thursday 17 September 2015 10:13
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Thanks @dannybloe, You are correct, no question about that.dannybloe wrote:Actually, you should try to prevent at all times to manipulate globals in your library functions. Always a huge risk. Just pass whatever you need as parameters to you function. A function is ideally unaware and independent of its environment.
I've spent a few hours trying to figure out how to best use dzVents together with my own custom functions.
My custom functions are quite few but they are crucial for my system and heavily used in my scripts. My functions need a way to access the Domoticz commandArray object, read device status and user defined variables. I could of course pass the needed parameters (domoticz.commandArray, domoticz.variables and/or domoticz.devices etc) to my custom functions as You suggested but it kind of bloats my scripts.
Currently I've solved the problem by inserting my own functions into Domoticz.lua and Utils.lua. I'm aware that my changes will get lost and maybe also incompatible whenever i upgrade dzVents. (They are kept inserted at a single position in the file though so I don't think it would cause me so much work to add them back when needed) If someone has a better idea please let me know.
- Spoiler: show
- remb0
- Posts: 499
- Joined: Thursday 11 July 2013 22:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I have also some functions that you maybe can include in dzentz:
round numbers, log to csv, bestaat_variable,
can you tell when the framework will be merged? and if it is possible to use the online editor/ (makes wrtinging / testing and debugging a lot easier )
round numbers, log to csv, bestaat_variable,
can you tell when the framework will be merged? and if it is possible to use the online editor/ (makes wrtinging / testing and debugging a lot easier )
-
- Posts: 13
- Joined: Monday 19 September 2016 8:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I've already done so & this is working. But then it is not possible anymore to control the blinds during the day though the physical buttons because after a minute the script will move them to the position which is defined in the script. Then there exists a huge problem with the WAF factor if you know what I'm talking aboutdannybloe wrote:So why don't you just set a timer for let's say every couple of minutes and in the script check if it is sunrise or sunset and check the state of your blinds and act accordingly? That shouldn't be too hard I think.Glatzi wrote:dzvEnts is an awesome framework Thx a lot @dannybloe !!!!
Is it possible to use a function in the timer section too?
I've got the problem that I use several scripts for my blinds which should only be executed when it is sunrise or sunset. I'm checking the domoticz.time.isDayTime or domoticz.time.isNightTime attribute
But I've got the problem that not all of them get executed everytime. Sometimes my blinds will open or close, sometimes not because the event is missed by Domoticz. So I want to run the script again e.g. 3 minutes after sunrise/sunset. I've written a lua script which is able to calculate that time but how can I include this with dzevents timer?Code: Select all
return { active = true, on = { ['timer'] = 'at sunset', ['timer'] = 'at sunrise' ... if ( domoticz.time.isNightTime and myLevelBlinds > 20) then domoticz.devices['Blinds'].dimTo(10)
I've already tried to put the value in a globalData Variable & use this with the timer event, but no luck. Alternatively something like '3 minutes after sunset' would be great
Any help is appreciated...
Or do you know a way to identify if a event was triggered through script or through a physical button?!
RPi3+UZB1,FIBARO FGMS001(9x),FIBARO FGD212,FIBARO FGRM222(6x),FIBARO FGSD002(1x),FIBARO FGWPE (3x),Neo CoolCam Power plug(5x),NodOn CRC-3-1 Remote(2x),Qubino ZMNHADx(1x),Qubino ZMNHDD1(2x),Z-Wave Weather Sensor(1x),Z-Wave ZME_WALLC-S,FIBARO System FGK10x
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Well, what you could do is create your own flag that indicates if it is night time. You basically set a time every minute and detect if you switch from day to night and vice versa. Only at that moment you update the flag and do the script-based blind controlling :Glatzi wrote:I've already done so & this is working. But then it is not possible anymore to control the blinds during the day though the physical buttons because after a minute the script will move them to the position which is defined in the script. Then there exists a huge problem with the WAF factor if you know what I'm talking aboutdannybloe wrote:So why don't you just set a timer for let's say every couple of minutes and in the script check if it is sunrise or sunset and check the state of your blinds and act accordingly? That shouldn't be too hard I think.Glatzi wrote:dzvEnts is an awesome framework Thx a lot @dannybloe !!!!
Is it possible to use a function in the timer section too?
I've got the problem that I use several scripts for my blinds which should only be executed when it is sunrise or sunset. I'm checking the domoticz.time.isDayTime or domoticz.time.isNightTime attribute
But I've got the problem that not all of them get executed everytime. Sometimes my blinds will open or close, sometimes not because the event is missed by Domoticz. So I want to run the script again e.g. 3 minutes after sunrise/sunset. I've written a lua script which is able to calculate that time but how can I include this with dzevents timer?Code: Select all
return { active = true, on = { ['timer'] = 'at sunset', ['timer'] = 'at sunrise' ... if ( domoticz.time.isNightTime and myLevelBlinds > 20) then domoticz.devices['Blinds'].dimTo(10)
I've already tried to put the value in a globalData Variable & use this with the timer event, but no luck. Alternatively something like '3 minutes after sunset' would be great
Any help is appreciated...
Or do you know a way to identify if a event was triggered through script or through a physical button?!
Code: Select all
return {
active = false, -- set to true to activate this script
on = {
['timer'] = 'every minute'
},
data = {
isNightTime = { initial = nil }
},
execute = function(domoticz)
if (domoticz.time.isNightTime and domoticz.data.isNightTime == false) then
-- we switch from dayTime to nightTime, only at this moment we do the blinds
domoticz.devices['Blinds'].dimTo(10)
domoticz.data.isNightTime = true
end
if (domoticz.time.isDayTime and domoticz.data.isNightTime == true) then
-- we switch from nightTime to dayTime
domoticz.devices['Blinds'].dimTo(20) -- something else than for the night
domoticz.data.isNightTime = false
end
end
}
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
no.. I'm still waiting for Gizmocus to do stuff. But he is very hard to get in touch with. Or someone else with enough Domoticz C++ knowledge could stand up and do some integration stuff (don't think it is hard if you know C++, it's just more of what is already there).remb0 wrote:I have also some functions that you maybe can include in dzentz:
round numbers, log to csv, bestaat_variable,
can you tell when the framework will be merged? and if it is possible to use the online editor/ (makes wrtinging / testing and debugging a lot easier )
/me looks around to see who raises a hand...
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 13
- Joined: Monday 19 September 2016 8:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Thank you for this input, that idea sounds really interesting. But in the above example the "isNightTime" is initially not set so none of the IF statements will become true?! Am I missing something? Perhaps I should enjoy my vacation on the seaside and just drink another beerdannybloe wrote:
Well, what you could do is create your own flag that indicates if it is night time. You basically set a time every minute and detect if you switch from day to night and vice versa. Only at that moment you update the flag and do the script-based blind controlling :Code: Select all
return { active = false, -- set to true to activate this script on = { ['timer'] = 'every minute' }, data = { isNightTime = { initial = nil } }, execute = function(domoticz) if (domoticz.time.isNightTime and domoticz.data.isNightTime == false) then -- we switch from dayTime to nightTime, only at this moment we do the blinds domoticz.devices['Blinds'].dimTo(10) domoticz.data.isNightTime = true end if (domoticz.time.isDayTime and domoticz.data.isNightTime == true) then -- we switch from nightTime to dayTime domoticz.devices['Blinds'].dimTo(20) -- something else than for the night domoticz.data.isNightTime = false end end }
RPi3+UZB1,FIBARO FGMS001(9x),FIBARO FGD212,FIBARO FGRM222(6x),FIBARO FGSD002(1x),FIBARO FGWPE (3x),Neo CoolCam Power plug(5x),NodOn CRC-3-1 Remote(2x),Qubino ZMNHADx(1x),Qubino ZMNHDD1(2x),Z-Wave Weather Sensor(1x),Z-Wave ZME_WALLC-S,FIBARO System FGK10x
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Yea you can set it to true if you start the stuff in th evening for the first time. That's an easy one
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
- remb0
- Posts: 499
- Joined: Thursday 11 July 2013 22:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I get:
2016-10-16 20:32:59.685 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: boven 4
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Alert 9
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Rolluiken Nacht 10
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Tuingroep 7
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: filmpje 8
since last domoticz update. I think that it's because of https://github.com/domoticz/domoticz/pull/919
because of a new lua table for scenes and groups.
2016-10-16 20:32:59.685 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: boven 4
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Alert 9
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Rolluiken Nacht 10
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Tuingroep 7
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: filmpje 8
since last domoticz update. I think that it's because of https://github.com/domoticz/domoticz/pull/919
because of a new lua table for scenes and groups.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Strange. I'll have to dive into this (or someone else of course )remb0 wrote:I get:
2016-10-16 20:32:59.685 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: boven 4
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Alert 9
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Rolluiken Nacht 10
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Tuingroep 7
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: filmpje 8
since last domoticz update. I think that it's because of https://github.com/domoticz/domoticz/pull/919
because of a new lua table for scenes and groups.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 142
- Joined: Friday 31 July 2015 21:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Sint-Oedenrode, Netherlands
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Got the same problem and also thought it had to do with the new table for scenes and groups idx. Looked around in the dzVents code and changed something that at least made the messages disappear: in Domoticz.lua, line 315 I added 'and tableName ~= 'otherdevices_scenesgroups_idx' to the test. Don't know if this is the real solution but as said, the messages are gone. Maybe @dannybloe can give the answer whether it is the right solution.dannybloe wrote:Strange. I'll have to dive into this (or someone else of course )remb0 wrote:I get:
2016-10-16 20:32:59.685 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: boven 4
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Beneden 5
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Alert 9
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Rolluiken Nacht 10
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: Tuingroep 7
2016-10-16 20:33:00.487 LUA: Cannot find the device. Skipping: filmpje 8
since last domoticz update. I think that it's because of https://github.com/domoticz/domoticz/pull/919
because of a new lua table for scenes and groups.
Gr. Mark
Mark: Domoticz Beta on Raspberry Pi 4 running Debian Bookworm - Z-Stick 7 - RFXCom - P1 - MySensors - SolarEdge - Dahua - Philips Hue - Docker - Zigbee2mqtt (plugin) - Zwave-js-ui - dzVents - Nodered
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I created a new release (v1.1.2):
- More robust way of updating devices.lua
- Added device level information for non-dimmer-like devices
- Support for Nefit Easy thermostat (SetPoint)
- Fixed problem with the new device table otherdevices_scenesgroups_idx.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 9
- Joined: Tuesday 18 October 2016 22:06
- Target OS: Linux
- Domoticz version: v3.5745
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I have a light sensor (1Wire) that the readings flickers for. The historical values API in dzVents seamed to be a good choice to handle the flickering.
But now I have a strange problem, the number of items in the history never increase. To limit the reasons to fault I made the testscript below.
What am I missing/doing wrong?
Versions used:
Domoticz: v3.5745
dzVents: v1.1.2
But now I have a strange problem, the number of items in the history never increase. To limit the reasons to fault I made the testscript below.
What am I missing/doing wrong?
Code: Select all
return {
active = true,
on = {
'Lightsensor'
},
data = {
history = {history = true, maxItems=10},
},
execute = function(domoticz, sensor)
local reading = tonumber(sensor.rawData[1])
domoticz.data.history.add(reading)
local avg = domoticz.data.history.avg()
local size = domoticz.data.history.size
print (sensor.name .. ": last=" .. reading .. ", avg=" .. avg .. ", size= " .. size)
end
}
Domoticz: v3.5745
dzVents: v1.1.2
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
What exactly do you mean by 'never increase'? It should hold 10 readings at most. You can check this by opening the side-car file for this script (in scripts/storage). Sometimes it helps to remove that file completely when it behaves weird. This file holds the persistent data for the variables defined in the data section.Wroopy wrote:I have a light sensor (1Wire) that the readings flickers for. The historical values API in dzVents seamed to be a good choice to handle the flickering.
But now I have a strange problem, the number of items in the history never increase. To limit the reasons to fault I made the testscript below.
What am I missing/doing wrong?
Versions used:Code: Select all
return { active = true, on = { 'Lightsensor' }, data = { history = {history = true, maxItems=10}, }, execute = function(domoticz, sensor) local reading = tonumber(sensor.rawData[1]) domoticz.data.history.add(reading) local avg = domoticz.data.history.avg() local size = domoticz.data.history.size print (sensor.name .. ": last=" .. reading .. ", avg=" .. avg .. ", size= " .. size) end }
Domoticz: v3.5745
dzVents: v1.1.2
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 9
- Joined: Tuesday 18 October 2016 22:06
- Target OS: Linux
- Domoticz version: v3.5745
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Number of items in the history table is always one.dannybloe wrote: What exactly do you mean by 'never increase'? It should hold 10 readings at most. You can check this by opening the side-car file for this script (in scripts/storage). Sometimes it helps to remove that file completely when it behaves weird. This file holds the persistent data for the variables defined in the data section.
I've tested to remove the file in storage and restart domoticz. But no change.
Between the updates I did no change to files, restart.
Storage file after first sensor update
Code: Select all
-- Persistent Data
local multiRefObjects = {
} -- multiRefObjects
local obj1 = {
["history"] = {
[1] = {
["time"] = "2016-10-19 06:27:59";
["data"] = 7;
};
};
}
return obj1
Code: Select all
-- Persistent Data
local multiRefObjects = {
} -- multiRefObjects
local obj1 = {
["history"] = {
[1] = {
["time"] = "2016-10-19 06:28:52";
["data"] = 7.1;
};
};
}
return obj1
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Could you try to throw away that data file and try again. And, if that doesn't work, rename the variable history to something else.Wroopy wrote:Number of items in the history table is always one.dannybloe wrote: What exactly do you mean by 'never increase'? It should hold 10 readings at most. You can check this by opening the side-car file for this script (in scripts/storage). Sometimes it helps to remove that file completely when it behaves weird. This file holds the persistent data for the variables defined in the data section.
I've tested to remove the file in storage and restart domoticz. But no change.
Between the updates I did no change to files, restart.
Storage file after first sensor updateStorage file after second sensor updateCode: Select all
-- Persistent Data local multiRefObjects = { } -- multiRefObjects local obj1 = { ["history"] = { [1] = { ["time"] = "2016-10-19 06:27:59"; ["data"] = 7; }; }; } return obj1
As I understand it there should be two record in the storage file after the second update?Code: Select all
-- Persistent Data local multiRefObjects = { } -- multiRefObjects local obj1 = { ["history"] = { [1] = { ["time"] = "2016-10-19 06:28:52"; ["data"] = 7.1; }; }; } return obj1
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 9
- Joined: Tuesday 18 October 2016 22:06
- Target OS: Linux
- Domoticz version: v3.5745
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I've removed the file and checked after ½ hour, according to the log I got several updates, but still one item in the list.dannybloe wrote: Could you try to throw away that data file and try again. And, if that doesn't work, rename the variable history to something else.
Tested to rename the varaible to "light" but still the same.
When/how is the storage file read?
When/how is the content cleared?
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Every time the script is executed it reads the persistent data and stores it when the script is finished. So each time the switch changes.Wroopy wrote:I've removed the file and checked after ½ hour, according to the log I got several updates, but still one item in the list.dannybloe wrote: Could you try to throw away that data file and try again. And, if that doesn't work, rename the variable history to something else.
Tested to rename the varaible to "light" but still the same.
When/how is the storage file read?
When/how is the content cleared?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
I just tested it here and it works with this script:dannybloe wrote:Every time the script is executed it reads the persistent data and stores it when the script is finished. So each time the switch changes.Wroopy wrote:I've removed the file and checked after ½ hour, according to the log I got several updates, but still one item in the list.dannybloe wrote: Could you try to throw away that data file and try again. And, if that doesn't work, rename the variable history to something else.
Tested to rename the varaible to "light" but still the same.
When/how is the storage file read?
When/how is the content cleared?
Code: Select all
return {
active = true,
on = {
'mySensor'
},
data = {
history = {history = true, maxItems = 10}
},
execute = function(domoticz, sensor)
local reading = sensor.temperature
domoticz.data.history.add(reading)
local avg = domoticz.data.history.avg()
local size = domoticz.data.history.size
print(sensor.name .. ": last=" .. reading .. ", avg=" .. avg .. ", size= " .. size)
end
}
Code: Select all
-- Persistent Data
local multiRefObjects = {
} -- multiRefObjects
local obj1 = {
["history"] = {
[1] = {
["time"] = "2016-10-19 09:45:59";
["data"] = 16.799999237061;
};
[2] = {
["time"] = "2016-10-19 09:45:58";
["data"] = 16.799999237061;
};
[3] = {
["time"] = "2016-10-19 09:45:30";
["data"] = 16.799999237061;
};
[4] = {
["time"] = "2016-10-19 09:45:29";
["data"] = 16.799999237061;
};
[5] = {
["time"] = "2016-10-19 09:44:59";
["data"] = 16.799999237061;
};
[6] = {
["time"] = "2016-10-19 09:44:58";
["data"] = 16.799999237061;
};
[7] = {
["time"] = "2016-10-19 09:44:29";
["data"] = 16.799999237061;
};
[8] = {
["time"] = "2016-10-19 09:44:28";
["data"] = 16.799999237061;
};
[9] = {
["time"] = "2016-10-19 09:43:59";
["data"] = 16.799999237061;
};
[10] = {
["time"] = "2016-10-19 09:43:58";
["data"] = 16.89999961853;
};
};
}
return obj1
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 9
- Joined: Tuesday 18 October 2016 22:06
- Target OS: Linux
- Domoticz version: v3.5745
- Contact:
Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!
Yes I'm sure it is calles several times. I can see it both in Domoticz log and the timestamp of the item is changed in the storage-file.dannybloe wrote:I just tested it here and it works with this script:dannybloe wrote:Every time the script is executed it reads the persistent data and stores it when the script is finished. So each time the switch changes.Wroopy wrote:
I've removed the file and checked after ½ hour, according to the log I got several updates, but still one item in the list.
Tested to rename the varaible to "light" but still the same.
When/how is the storage file read?
When/how is the content cleared?
and the data file is like this:Code: Select all
return { active = true, on = { 'mySensor' }, data = { history = {history = true, maxItems = 10} }, execute = function(domoticz, sensor) local reading = sensor.temperature domoticz.data.history.add(reading) local avg = domoticz.data.history.avg() local size = domoticz.data.history.size print(sensor.name .. ": last=" .. reading .. ", avg=" .. avg .. ", size= " .. size) end }
Are you sure that the script is called multiple times?Code: Select all
-- Persistent Data local multiRefObjects = { } -- multiRefObjects local obj1 = { ["history"] = { [1] = { ["time"] = "2016-10-19 09:45:59"; ["data"] = 16.799999237061; }; [2] = { ["time"] = "2016-10-19 09:45:58"; ["data"] = 16.799999237061; }; [3] = { ["time"] = "2016-10-19 09:45:30"; ["data"] = 16.799999237061; }; [4] = { ["time"] = "2016-10-19 09:45:29"; ["data"] = 16.799999237061; }; [5] = { ["time"] = "2016-10-19 09:44:59"; ["data"] = 16.799999237061; }; [6] = { ["time"] = "2016-10-19 09:44:58"; ["data"] = 16.799999237061; }; [7] = { ["time"] = "2016-10-19 09:44:29"; ["data"] = 16.799999237061; }; [8] = { ["time"] = "2016-10-19 09:44:28"; ["data"] = 16.799999237061; }; [9] = { ["time"] = "2016-10-19 09:43:59"; ["data"] = 16.799999237061; }; [10] = { ["time"] = "2016-10-19 09:43:58"; ["data"] = 16.89999961853; }; }; } return obj1
I've tested to increase the logging, i.e. change ['Log level'] = 3 in dzVents_settings.lua too see if I would get som extra useful information. Got some very confusing result
1. The size of the history variable where increasing. So finally I got 10 items as expected.
2. Changed back to ['Log level'] = 2 and now I get only one hisory item.
3. Switch to level 3 again and it worked as expected.
4. Changed back to 2 and got only one history item.
Does that give any hint on what the problem could be?
Who is online
Users browsing this forum: No registered users and 1 guest