Page 1 of 1

Data Logging

Posted: Tuesday 31 October 2017 13:57
by michaldobrotka
Hi Guys,
Is it possible to log my data readings (temperature and humidity) from Domoticz running on Raspberry Pi into internal folder or to LAN attached NAS storage (no external service). I need just hourly log with time stamp in some kind of text file.I have been searching on forum with no success.
Thanks a lot for suggestions.

Re: Data Logging

Posted: Tuesday 31 October 2017 14:13
by emme
what about a script that write a file?
somthing like:

Code: Select all

return {
	on = {
		timer = {
			'every minutes'
		}
	},
	execute = function(domoticz, device)
		local devName = domoticz.devices('myTempHumidDeviceName')
		local fileName = '/path/to/folder/filename.csv'
		local timeStamp = os.date('*t')
		
		fileOut = io.open(fileName, 'a')
		fileOut:write(timeStamp..','..devName.temparature..','..devName.humidity..'\n')
        fileOut:close()
	end
}

Re: Data Logging

Posted: Tuesday 31 October 2017 15:10
by michaldobrotka
Thanks emme, I will try it.

Re: Data Logging

Posted: Thursday 02 November 2017 11:07
by michaldobrotka
Hi emme,
Checked dzVents and changed your script to :

Code: Select all

return {
	on = {
		timer = {
			'every hour'
		}
	},
	execute = function(domoticz, device)
		local devName = domoticz.devices('Terrarium ground')
		local fileName = '/home/domoticz/scripts/Datalogger/Terarriumgroundtemp.csv'
		local timeStamp = os.date('*t')
		
		fileOut = io.open(fileName, 'a')
		fileOut:write(timeStamp..','..devName.temparature..','..devName.humidity..'\n')
        fileOut:close()
	end
}
.csv file was created, but no logs were written after hour.
Am I missing something in script?
Thanks

Re: Data Logging

Posted: Thursday 02 November 2017 20:13
by mack
michaldobrotka wrote: Thursday 02 November 2017 11:07Checked dzVents and changed your script to :
I didn't check your script logic, but wanted to point out for dzVents to be enabled, the checkbox for dzVents needs to be UNchecked.