Lua script is stop working

Moderator: leecollings

Post Reply
jandoedel99
Posts: 12
Joined: Tuesday 18 April 2017 21:55
Target OS: -
Domoticz version:
Contact:

Lua script is stop working

Post by jandoedel99 »

Ihave a script ,inside Domoticz, that is ,after update Linux and update domoticz to last beta, not working anymore.

Code: Select all

[/--script_device_deltaT.lua 
--This script subtracts two sensors (aanvoer_dv and retour_dv) from eachother and puts the calculated value in a new sensor (to be configured with 'deltat_idx')
local aanvoer_dv = 'CV Aanvoer'
local retour_dv = 'CV Retour'
local deltat_idx = 51

commandArray = {}

--if devicechanged[aanvoer_dv] then

        aanvoer = otherdevices_svalues[aanvoer_dv]
        retour = otherdevices_svalues[retour_dv]
        aanvoer_temp = (aanvoer)
        retour_temp = (retour)
        commandArray['UpdateDevice'] = deltat_idx .. '|0|' .. string.format("%." .. 1 .. "f", aanvoer_temp - retour_temp)
--end

return commandArray

error in log is now±
2018-01-08 22:30:20.220 Error: EventSystem: in DeltaT: [string "..."]:16: attempt to perform arithmetic on global 'aanvoer_temp' (a nil value)

I have not change the script.
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Lua script is stop working

Post by emme »

2 notes:
aanvoer_temp = (aanvoer)
svalue uses Strings, not number... so it should be converted to
aanvoer_temp = tonumber(aanvoer)

the same for
retour_temp = (retour)
should be
retour_temp = tonumber(retour)

consider to covert to dzVents platform which is MUCH more flexible and realiabe...
I have a similar script for my central heating system in which I calculate the DeltaT between incoming water temp and outcoming water temp

your script will look like:

Code: Select all

return {
	on = {
		devices = {
			'CV Aanvoer',
			'CV Retour'
		}
	},
	execute = function(dz, devTemp)
	    local deltat_idx = 51
	    local aanTemp = dz.round(dz.devices('CV Aanvoer').temperature,2)
	    local retTemp = dz.round(dz.devices('CV Retour').temperature,2)
	    dz.devices(deltat_idx).updateTemperature(aanTemp - retTemp)
	end
}
ciao
M
Last edited by emme on Tuesday 09 January 2018 10:29, edited 1 time in total.
The most dangerous phrase in any language is:
"We always done this way"
jandoedel99
Posts: 12
Joined: Tuesday 18 April 2017 21:55
Target OS: -
Domoticz version:
Contact:

Re: Lua script is stop working

Post by jandoedel99 »

Thanks it is working.
But there is in the log:
2018-01-09 08:54:02.282 Error: dzVents: Error: ...oticz/scripts/dzVents/../../dzVents/runtime/Domoticz.lua:243: attempt to perform arithmetic on local 'x' (a table value)

I have to read me in dzVents.
User avatar
emme
Posts: 909
Joined: Monday 27 June 2016 11:02
Target OS: Raspberry Pi / ODroid
Domoticz version: latest
Location: Milano, Italy
Contact:

Re: Lua script is stop working

Post by emme »

uh... my fault!!!

script corrected

(note also the setTemperature that became updateTemperature :P :P)
The most dangerous phrase in any language is:
"We always done this way"
jandoedel99
Posts: 12
Joined: Tuesday 18 April 2017 21:55
Target OS: -
Domoticz version:
Contact:

Re: Lua script is stop working

Post by jandoedel99 »

Thanks again
This is great.
I try to now convert a other script to dvVent.
When i have problems i write.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest