Error /scripts/dzVents/runtime/EventHelpers.lua:69

Easy to use, 100% Lua-based event scripting framework.
Post Reply
jkimmel
Posts: 186
Joined: Monday 25 November 2013 18:51
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Error /scripts/dzVents/runtime/EventHelpers.lua:69

Post by jkimmel » Friday 27 April 2018 21:10

I'm on V3.8153

All of a sudden there is the error

Code: Select all

 Error: EventSystem: in /home/pi/domoticz/scripts/dzVents/runtime/dzVents.lua: /home/pi/domoticz/scripts/dzVents/runtime/EventHelpers.lua:69: attempt to index local 'fileStorage' (a boolean value)
No idea where to look at.

By chance I deactivated the following script and the error has gone.

Code: Select all

-- assumptions:
-- the setpoint is set by a selector dummy device where the values are numeric temperatures
-- but you can easily change it to a setpoint device

local BOILER_DEVICE = 'FB 31 Infrarot' -- switch device
local SWITCH_DEVICE = 'Schalter Bad Infrarot'
local SETPOINT_DEVICE = 'Solltemperatur Bad' -- selector dummy device
local TEMPERATURE_SENSOR = 'Bad'
local HYSTERESIS = 0.5 -- temp has to drop this value below setpoint before boiler is on again
local SMOOTH_FACTOR = 3
local LOGGING = false

return {
	on = {
		timer = {
			'every 1 minutes',
		},
		devices = {
			TEMPERATURE_SENSOR,
			SETPOINT_DEVICE
		}
	},
	data = {
		temperatureReadings = { history = true, maxItems = SMOOTH_FACTOR }
	},
	active = true,
	execute = function(domoticz, device, triggerInfo)

		local avgTemp
		local temperatureReadings = domoticz.data.temperatureReadings

		-- first check if the sensor got a new reading or the setpoint was changed:
		if (triggerInfo.type == domoticz.EVENT_TYPE_DEVICE) then

			local sensor = domoticz.devices(TEMPERATURE_SENSOR)

			if (sensor.changed) then
				-- sensor just reported a new reading
				-- add it to the readings table

				local current = sensor.temperature

				if (current ~= 0 and current ~= nil) then
					temperatureReadings.add(current)
				else
					-- no need to be here, weird state detected
					domoticz.log('Strange sensor reading.. skiping', domoticz.LOG_ERROR)
					return
				end

			elseif (domoticz.devices(SETPOINT_DEVICE).changed) then
				-- a new setpoint was set
				if LOGGING then domoticz.log('Setpoint was set to ' .. device.state) end
			else
				-- no business here, bail out...
				return
			end
		end

		-- now determine what to do

		local boiler = domoticz.devices(BOILER_DEVICE)
		local setpoint = domoticz.devices(SETPOINT_DEVICE)

		if (setpoint.state == nil or setpoint.state == 'Off') then
		    if boiler.state == 'On' then
		        boiler.switchOff()
		        return
		    else
		        return -- we're done here
			end
		end

		local setpointValue = tonumber(setpoint.state)

		-- determine at which temperature the boiler should be
		-- switched on
		local switchOnTemp = setpointValue - HYSTERESIS

		-- don't use the current reading but average it out over
		-- the past <SMOOTH_FACTOR> readings (data smoothing) to get rid of noise, wrong readings etc
		local avgTemp = temperatureReadings.avg(1, SMOOTH_FACTOR)

		if LOGGING then
			domoticz.log('Average: ' .. avgTemp, domoticz.LOG_INFO)
			domoticz.log('Setpoint: ' .. setpointValue, domoticz.LOG_INFO)
			domoticz.log('Current boiler state: ' .. boiler.state, domoticz.LOG_INFO)
			domoticz.log('Switch-on temperature: ' .. switchOnTemp, domoticz.LOG_INFO)
		end
        local irswitch = domoticz.devices(SWITCH_DEVICE)
        
		if avgTemp >= setpointValue and boiler.state == 'On' or ((domoticz.time.hour < 7) or (domoticz.time.hour >= 10 )) then
			if LOGGING then domoticz.log('Target temperature reached or off time, boiler off') end
			boiler.switchOff()
	--	elseif 	 avgTemp < setpointValue and boiler.state == 'Off' and (domoticz.time.hour >= 7) and (domoticz.time.hour < 9 ) then
	--	    if LOGGING then domoticz.log('Target temperature low, boiler On') end
	--	    boiler.switchOn()
		    
		end
	end	

  }
Can't remember having changed anything, has been running fine.
Rfxcom

Akerboom
Posts: 39
Joined: Thursday 15 March 2018 20:40
Target OS: -
Domoticz version:
Contact:

Re: Error /scripts/dzVents/runtime/EventHelpers.lua:69

Post by Akerboom » Wednesday 02 May 2018 20:10

This part:

Code: Select all

	data = {
		temperatureReadings = { history = true, maxItems = SMOOTH_FACTOR }
	},
should be:

Code: Select all

	data = {
		temperatureReadings = { initial = { history = true, maxItems = SMOOTH_FACTOR } }
	},
see: https://www.domoticz.com/wiki/DzVents:_ ... _variables

dannybloe
Posts: 1473
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Error /scripts/dzVents/runtime/EventHelpers.lua:69

Post by dannybloe » Wednesday 02 May 2018 20:41

That last one is not correct. Initial is not a table. Look closely in the doc.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

Akerboom
Posts: 39
Joined: Thursday 15 March 2018 20:40
Target OS: -
Domoticz version:
Contact:

Re: Error /scripts/dzVents/runtime/EventHelpers.lua:69

Post by Akerboom » Monday 07 May 2018 22:56

TS wants a table as initial value... it's supported by dzVents, so why not?

dannybloe
Posts: 1473
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: Error /scripts/dzVents/runtime/EventHelpers.lua:69

Post by dannybloe » Tuesday 08 May 2018 7:40

You are mixing things up. history = true is a setting for the variable declaration type and so is maxItems. In your example you create a non-history persistent variable who's initial value is { history = true, maxItems = SMOOTH_FACTOR }. That doesn't make sense. No to me at least ;-)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

Akerboom
Posts: 39
Joined: Thursday 15 March 2018 20:40
Target OS: -
Domoticz version:
Contact:

Re: Error /scripts/dzVents/runtime/EventHelpers.lua:69

Post by Akerboom » Tuesday 08 May 2018 21:34

@dannybloe: Ah, I thought it was his own table of some kind but I now see it's the 'special kind of persistent variables: history = true (Historical variables API)' my bad.

Linenumber 69 is now commented so I guess updating to the latest beta could resolve the issue.

Post Reply

Who is online

Users browsing this forum: Ascari and 1 guest