Page 15 of 17

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 12 October 2016 15:14
by dannybloe
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.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Thursday 13 October 2016 9:33
by BakSeeDaa
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.
Thanks @dannybloe, You are correct, no question about that.

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

Code: Select all

	-- Below	- My own custom functions

	function self.homeAwake()
		return (self.devices['Z1 Alarm'].text == self.SECURITY_DISARMED and true or false)
	end

	function self.AutoRemote(arMessage, deliverTo)
		local url
		if ((deliverTo == "") or (deliverTo == nil) or (deliverTo == "Narva2")) then deliverTo = "Default" end

		if (self.devices['Internet'].state == 'On') then
			-- We have Internet access, use GCM Server for delivery
			url = "https://autoremotejoaomgcd.appspot.com/sendmessage?key="
			url = url .. (deliverTo == "MastersCellPhone" and self.variables['ARKey1'].value or (deliverTo == "SonsCellPhone" and self.variables['ARKey2'].value or (deliverTo == "Uth" and self.variables['ARKey4'].value or self.variables['ARKey3'].value))) .. "&message=" .. utils.urlencode(arMessage) .. "&password=" .. self.variables['ARPassw'].value .. "&sender=Domoticz"
		elseif (deliverTo == "Default") then -- No Internet but Use LAN access to device for inhouse Speaker
			url = "http://vera-voice.private.narva2:1817/?message=" .. utils.urlencode(arMessage) .. "&password=" .. self.variables['ARPassw'].value .. "&sender=Domoticz"
		else
			print('No Internet access. Communicating with external host isn\'t possible.')
			return
		end
		self.openURL(url)
	end

	function self.speak(speakMessage, deliverTo, canSpeakAtNight)
		local NOTHINGTOSAY = 'Nothing to say'
		speakMessage = speakMessage or NOTHINGTOSAY
		canSpeakAtNight = canSpeakAtNight or 0
		if ((not self.homeAwake()) and canSpeakAtNight == 0)
		or (self.devices['Mobiltelefon'].state  == 'Off' and deliverTo == 'SonsCellPhone' and canSpeakAtNight == 0) then
			return -- Not a good time to speak
		end
		if (speakMessage ~= '') then
			self.AutoRemote('SpeakIt=:=' .. speakMessage, deliverTo)
		end
	end

	-- SMS messages are sent by making HTTP calls through the Clickatell API
	function self.sendSMS(SMSText, PhoneNumber)
		if ((PhoneNumber == '') or (PhoneNumber == nil) or (PhoneNumber == 'SMS-Away')) then PhoneNumber = self.variables['SMS-Away'].value end
		self.openURL('https://api.clickatell.com/http/sendmsg?user='..self.variables['ClickatellAPIUser'].value.."&password="..self.variables['ClickatellAPIPassw'].value.."&api_id="..self.variables['ClickatellAPIId'].value.."&from=+"..self.variables['ClickatellSender'].value.."&to="..PhoneNumber.."&text=".. utils.smsEncode(SMSText))
		print('Sending out a SMS to ' .. PhoneNumber)
	end

	-- End		- My own custom functions

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Thursday 13 October 2016 20:49
by remb0
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 :P)

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Friday 14 October 2016 1:30
by Glatzi
dannybloe wrote:
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

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)
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?

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...
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.
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 about :D

Or do you know a way to identify if a event was triggered through script or through a physical button?!

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Friday 14 October 2016 8:06
by dannybloe
Glatzi wrote:
dannybloe wrote:
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

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)
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?

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...
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.
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 about :D

Or do you know a way to identify if a event was triggered through script or through a physical button?!
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
}


Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Friday 14 October 2016 8:09
by dannybloe
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 :P)
:cry: 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).

/me looks around to see who raises a hand...

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Friday 14 October 2016 12:53
by Glatzi
dannybloe 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
}

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 beer :-)

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Friday 14 October 2016 13:59
by dannybloe
Yea you can set it to true if you start the stuff in th evening for the first time. That's an easy one ;)

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 17 October 2016 9:22
by remb0
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.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 17 October 2016 10:16
by dannybloe
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.
Strange. I'll have to dive into this (or someone else of course ;-) )

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 17 October 2016 12:03
by Doler
dannybloe wrote:
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.
Strange. I'll have to dive into this (or someone else of course ;-) )
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.
Gr. Mark

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Monday 17 October 2016 21:35
by dannybloe
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.
Enjoy (again) :)

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Tuesday 18 October 2016 22:24
by Wroopy
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?

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
}
Versions used:
Domoticz: v3.5745
dzVents: v1.1.2

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 19 October 2016 8:13
by dannybloe
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?

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
}
Versions used:
Domoticz: v3.5745
dzVents: v1.1.2
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.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 19 October 2016 9:26
by Wroopy
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.
Number of items in the history table is always one.
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
Storage file after second sensor 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
As I understand it there should be two record in the storage file after the second update?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 19 October 2016 10:08
by dannybloe
Wroopy wrote:
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.
Number of items in the history table is always one.
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
Storage file after second sensor 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
As I understand it there should be two record in the storage file after the second update?
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.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 19 October 2016 11:32
by Wroopy
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.
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?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 19 October 2016 11:37
by dannybloe
Wroopy wrote:
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.
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?
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.

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 19 October 2016 11:48
by dannybloe
dannybloe wrote:
Wroopy wrote:
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.
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?
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.
I just tested it here and it works with this script:

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
}
and the data file is like this:

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

Are you sure that the script is called multiple times?

Re: Introducing dzVents - Domoticz Lua file based event scripting made e-z!

Posted: Wednesday 19 October 2016 14:47
by Wroopy
dannybloe wrote:
dannybloe wrote:
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?
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.
I just tested it here and it works with this script:

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
}
and the data file is like this:

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

Are you sure that the script is called multiple times?
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.

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?