Change local variable from other script  [Solved]

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

Moderator: leecollings

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Change local variable from other script

Post by poudenes »

Hi ALl,

I use several local variables in some dzVent Scripts. Is it possible to change those local variables from outside the script itself?

Cheers
Peter
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Change local variable from other script

Post by waaren »

poudenes wrote: Saturday 22 June 2019 22:32 I use several local variables in some dzVent Scripts. Is it possible to change those local variables from outside the script itself?
No.
dzVents has global_data.lua to handles these kind of requirements. You could also store your values in a domoticz uservariable or in various fields in devices. (description field in most devices, text field in text-device, etc..)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Change local variable from other script  [Solved]

Post by poudenes »

Yes, I used it before in uservariable. Now put those in the scripts itself. Easier to handle. (ok till now because of this question)
I will take a look to add them in global_data.

Thanks for aswering :)
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Change local variable from other script

Post by poudenes »

Solved:

Added this in global_data:

Code: Select all

    data = {
        LuxEvening    = { initial = 0 },
        LuxMorning    = { initial = 0 },
        HomePeter     = { initial = 0 },
        HomeKay       = { initial = 0 },
        KodiPlayVar   = { initial = 0 },
        KodiStopVar   = { initial = 0 }
        },
And then I can access the data in script with:

Code: Select all

if (domoticz.globalData.KodiPlayVar == 0) then

     domoticz.globalData.KodiPlayVar = 1

end
Now I can read the variables from other scripts :D
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest