Just a thought.
Might it be an idea to have a variable setting(s) in dzVents_setting.lua for alternative paths for the http fetch file and the storage files?
I then could put them on a tmpfs. It prevents the sd-card for too many writes.
I already optimized my whole system this way.
One thing that's bothering me is that i stil have issues when the httpdata is fetched. I think it has to do with the great amount of devices i have that fetching them via the httprequest is taking a long time.
It might be an issue that the script whats to acces the devices.lua file while it is still being created by the httprequest.
Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:452: attempt to index local 'device' (a nil value)
LUA: devices.lua cannot be loaded
LUA: error loading module 'devices' from file '/home/pi/domoticz/scripts/lua/devices.lua':
/home/pi/domoticz/scripts/lua/devices.lua:2065: unexpected symbol near
Maybe it is a good idea to fetch the devices to a tempfile and then rename it after is has finished. In that case the (previous) devices.lua is still available for the script to read, while being fetched at the same time.
Yes, I have noticed that too. I will try to implement such a scheme.
Hopefully we can get by the need for this http stuff really soon. I see it as a temporary thing (/me looks at giz... )
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:452: attempt to index local 'device' (a nil value)
LUA: devices.lua cannot be loaded
LUA: error loading module 'devices' from file '/home/pi/domoticz/scripts/lua/devices.lua':
/home/pi/domoticz/scripts/lua/devices.lua:2065: unexpected symbol near
Maybe it is a good idea to fetch the devices to a tempfile and then rename it after is has finished. In that case the (previous) devices.lua is still available for the script to read, while being fetched at the same time.[/quote]
I noticed these too, but usually (cannot say with 100% certainty) they happen on the hour xx:00, which coincides with the hourly backup. So I figured that the file is for a brief moment not accesible and thus causing the error
I added support for this in the dev branch. Can you please test it? It now uses a tmp file first when downloading the json and only when it is done writing it copies it over to devices.lua.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dannybloe wrote:I added support for this in the dev branch. Can you please test it? It now uses a tmp file first when downloading the json and only when it is done writing it copies it over to devices.lua.
Thanks! Seems to work. Not getting errors until now. Will continue to test the next days...
2016-07-14 08:00:02.578 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:452: attempt to index local 'device' (a nil value)
Is there a beginners tutorial for dzVents anywhere? It looks so useful, but I've no idea how to get started. I've read the wiki, but I'm still stuck on how to get started. Any guidance for a LUA newb?
return {
active = true,
on = { ['timer'] = 'every minute' },
execute = function(domoticz)
local json = (loadfile "/home/daniel/domoticz/scripts/lua/JSON.lua")()
local sonos=assert(io.popen('curl http://192.168.1.200:5005/Altan/state'))
local sonos_name = 'Utomhus, Sonos'
local status = sonos:read('*all')
sonos:close()
local jsonStatus = json:decode(status)
playerstate = jsonStatus['playerState']
if (playerstate == nil)
then
playerstate = 'OFFLINE'
end
if (playerstate == 'PLAYING')
then
domoticz.devices[sonos_name].level = 10
elseif (playerstate == 'PAUSED_PLAYBACK')
then
domoticz.devices[sonos_name].level = 20
else
domoticz.devices[sonos_name].level = 0
end
domoticz.log(sonos_name .. " state:" .. playerstate, domoticz.LOG_INFO)
end
}
return {
active = true,
on = { ['timer'] = 'every minute' },
execute = function(domoticz)
local json = (loadfile "/home/daniel/domoticz/scripts/lua/JSON.lua")()
local sonos=assert(io.popen('curl http://192.168.1.200:5005/Altan/state'))
local sonos_name = 'Utomhus, Sonos'
local status = sonos:read('*all')
sonos:close()
local jsonStatus = json:decode(status)
playerstate = jsonStatus['playerState']
if (playerstate == nil)
then
playerstate = 'OFFLINE'
end
if (playerstate == 'PLAYING')
then
domoticz.devices[sonos_name].level = 10
elseif (playerstate == 'PAUSED_PLAYBACK')
then
domoticz.devices[sonos_name].level = 20
else
domoticz.devices[sonos_name].level = 0
end
domoticz.log(sonos_name .. " state:" .. playerstate, domoticz.LOG_INFO)
end
}
I think it is because you are not using any of the update methods on a device . You cannot do device.level=xxx. In your case you could use the switchSelector(level) command or the dimTo(level) command. Both result in a 'Set Level xxx' that is sent to domoticz.
Lemme know if that works for you.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
velkrosmaak wrote:Is there a beginners tutorial for dzVents anywhere? It looks so useful, but I've no idea how to get started. I've read the wiki, but I'm still stuck on how to get started. Any guidance for a LUA newb?
Are you talking about a tutorial for Domoticz events in general or using dzVents? For the latter, if you follow the installation instructions you are about 80% done .
Then it's just a matter of creating one or more script files in the scripts/lua/scripts folder. There are a couple of examples in the dzVents folder that may get you started.
So assuming you have Domoticz up and running, got at least one switch (or a dummy switch) created and you installed dzVents to the proper location you can look at dzVents/examples/respond to switch.lua. That's a simple script that will respond to a switch being turned on. Oh, and it sends a notification so you may have to configure that in Domoticz as well.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dannybloe wrote:
I think it is because you are not using any of the update methods on a device . You cannot do device.level=xxx. In your case you could use the switchSelector(level) command or the dimTo(level) command. Both result in a 'Set Level xxx' that is sent to domoticz.
Lemme know if that works for you.
Works perfectly fine, missed that method (switchSelector) when reading the docs. I´m a .net developer, so that kind of justifies that I tried to set a property in that way
dannybloe wrote:
I think it is because you are not using any of the update methods on a device . You cannot do device.level=xxx. In your case you could use the switchSelector(level) command or the dimTo(level) command. Both result in a 'Set Level xxx' that is sent to domoticz.
Lemme know if that works for you.
Works perfectly fine, missed that method (switchSelector) when reading the docs. I´m a .net developer, so that kind of justifies that I tried to set a property in that way
Yeah, I don't think Lua supports this kind of attribute manipulation. (If it does, I'm not gonna change it anymore anyway )
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
2016-07-14 08:00:02.578 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_main.lua: /home/pi/domoticz/scripts/lua/dzVents/Domoticz.lua:452: attempt to index local 'device' (a nil value)
Latest dev-branch is error-free now for the last couple of days