Global variables always nil  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Inso80
Posts: 12
Joined: Thursday 17 May 2018 13:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Global variables always nil

Post by Inso80 »

Hi,

I have created a "global_data.lua", stored in "/home/pi/domoticz/scripts/dzVents/scripts"

Code: Select all

return {
        helpers = {},
        data = {
	    testini = { initial = 12.4 }
	    testinix = { initial = 12 }
            timedOff = { initial = false }
        }
    }
all three of them are always "nil". When trying to print , f.e.:

Code: Select all

            domoticz.log(domoticz.globalData.testinix, domoticz.LOG_INFO)
I always get the error

Code: Select all

2018-05-24 22:22:21.675 Error: dzVents: Error: An error occured when calling event handler TestGlobalVar
2018-05-24 22:22:21.675 Error: dzVents: Error: /home/pi/domoticz/scripts/dzVents/runtime/Utils.lua:62: attempt to concatenate local 'msg' (a nil value)
there is no other global_data.lua file on my raspi. Also tried to move it to "/home/pi/domoticz/scripts" , same problem. User Variables table in domoticz web interface is empty.

Any ideas?
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Global variables always nil

Post by dannybloe »

It looks like you are using a very old version of dzVents. Can you try this with a more recent one? Yours is located in scripts/ instead of in dzVents/. That is really old.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Global variables always nil  [Solved]

Post by waaren »

Inso80 wrote: Thursday 24 May 2018 22:44 Hi,

I have created a "global_data.lua", stored in "/home/pi/domoticz/scripts/dzVents/scripts"

Code: Select all

return {
        helpers = {},
        data = {
	    testini = { initial = 12.4 }
	    testinix = { initial = 12 }
            timedOff = { initial = false }
        }
    }
Any ideas?
My guess is that you got the syntax not completely right. When I look at my (working) version, which is also in scripts/dzVents/scripts, it has some extra comma's

Code: Select all

         data = {
                             domoticzLatitude                        = { initial = 0},
                            domoticzLongitude                       = { initial = 0 },
                            domoticzLocation                        = { initial = "Nederland" },
                    }
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Inso80
Posts: 12
Joined: Thursday 17 May 2018 13:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Global variables always nil

Post by Inso80 »

The syntax did the trick :oops: thank you very much :D

@dannybloe
the "check for updates" - dialog tells me I am up to date, also my Domoticz is max ~around a year old. As soon as I have more time, I will clean reinstall, hopefully it will not cause any other problems.
User avatar
gizmocuz
Posts: 2484
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Global variables always nil

Post by gizmocuz »

@Inso80, in the settings you can select 'beta' as release channel
Quality outlives Quantity!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest