CommandArray command in LUA doesn't work anymore Topic is solved
Moderators: leecollings, remb0
Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.
Use the following template when posting here:
Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....
If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly
If you are replying, please do not quote images/code from the first post
Please mark your topic as Solved when the problem is solved.
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.
Use the following template when posting here:
Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....
If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly
If you are replying, please do not quote images/code from the first post
Please mark your topic as Solved when the problem is solved.
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
CommandArray command in LUA doesn't work anymore
Dear All
again this error happening either on Release or Beta version
I have a VIRTUAL SWITCH called DEBUG
I just run this code:
if (otherdevices['DEBUG']) == 'On' then
print('debug')
commandArray['DEBUG'] = 'Off'
end
Debug appears in the LOG
command array is not executed and the switch remains ON
any ideas ?
thansk again for your help !!
cheers
sebastien
again this error happening either on Release or Beta version
I have a VIRTUAL SWITCH called DEBUG
I just run this code:
if (otherdevices['DEBUG']) == 'On' then
print('debug')
commandArray['DEBUG'] = 'Off'
end
Debug appears in the LOG
command array is not executed and the switch remains ON
any ideas ?
thansk again for your help !!
cheers
sebastien
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: CommandArray command in LUA doesn't work anymore
Is that your whole script?
Please show the total script.
Please show the total script.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: CommandArray command in LUA doesn't work anymore
commandArray ={}
if (otherdevices['DEBUG']) == 'On' then
print('debug')
commandArray['DEBUG'] = 'Off'
end
return commandArray
it seems that my modifications on the meter calendar DB have an issue on this behavior as trying a previous day save seems to work but this does not explain why it does that
if (otherdevices['DEBUG']) == 'On' then
print('debug')
commandArray['DEBUG'] = 'Off'
end
return commandArray
it seems that my modifications on the meter calendar DB have an issue on this behavior as trying a previous day save seems to work but this does not explain why it does that
Last edited by sebitop on Wednesday 13 November 2024 22:54, edited 1 time in total.
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: CommandArray command in LUA doesn't work anymore
That last line is wrong as the arrayname has a typo, so nothing is returned!
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: CommandArray command in LUA doesn't work anymore
it was a typo here
on my LUA the code is correct
on my LUA the code is correct
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: CommandArray command in LUA doesn't work anymore
I restored previous adatabase
It worked until this morning again the same issue....
It worked until this morning again the same issue....
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: CommandArray command in LUA doesn't work anymore
Typo?
Just show us the real code, not something typed, doing a cut&paste so we can check the code for issues.
Just show us the real code, not something typed, doing a cut&paste so we can check the code for issues.

New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: CommandArray command in LUA doesn't work anymore
I'm trying to replicate the error finding which activation generates this issue as restoring a previous DB saved works well
nothing related to the domoticz version itself, behavior is the same with a stable or beta version
Do you have any idea of what could generate an issue preventing the commandArray command working on domoticz?
could it be linked to the database ?
I'm wondering as I have seen something this morning :
I have a script which works well since months and the aim is to retreive the color code of the french electricity (pricing is based on a color which changes every day)
this script parses an http address with JSON and extracts the color
but I realised that this morning the HTTP address was not reacheable showing an error message (error 403) but the JSON parsed some HTTP code and raised an error in the log
after I also realized that Domoticz was not working again
then I suspect this like an http injection things like tha
so now I'm searching what could have an impact in the DB that could stop CommadArray commands working
I need some additional tests to find exactly when it fails
I know this one is not an easy but I'm struggling to find out
thanks again for reading
nothing related to the domoticz version itself, behavior is the same with a stable or beta version
Do you have any idea of what could generate an issue preventing the commandArray command working on domoticz?
could it be linked to the database ?
I'm wondering as I have seen something this morning :
I have a script which works well since months and the aim is to retreive the color code of the french electricity (pricing is based on a color which changes every day)
this script parses an http address with JSON and extracts the color
but I realised that this morning the HTTP address was not reacheable showing an error message (error 403) but the JSON parsed some HTTP code and raised an error in the log
after I also realized that Domoticz was not working again
then I suspect this like an http injection things like tha
so now I'm searching what could have an impact in the DB that could stop CommadArray commands working
I need some additional tests to find exactly when it fails
I know this one is not an easy but I'm struggling to find out
thanks again for reading

Last edited by sebitop on Thursday 14 November 2024 22:29, edited 1 time in total.
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
-
- Posts: 643
- Joined: Thursday 10 November 2016 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: CommandArray command in LUA doesn't work anymore
If you are using RTE Tempo data, server was unavailable this morning until ~8h45:sebitop wrote: ↑Thursday 14 November 2024 10:19 I have a script which works well since months and the aim is to retreive the color code of the french electricity (pricing is based on a color which changes every day)
this script parses an http address with JSON and extracts the color
but I realised that this morning the HTTP address was not reacheable showing an error message (error 403) but the JSON parsed some HTTP code and raised an error in the log
https://easydomoticz.com/forum/viewtopi ... 78#p122778
No issue on my side, as I do a quick check to see if answer starts with '{' as a JSON should, from the function that gets data:
Code: Select all
--
-- Internal fct :
-- Get json answer EDF or RTE http/json API.
--
local function getUrlJson(url)
config = assert(io.popen('curl --retry 1 --connect-timeout 2 -m 4 \"'..url..'\"'))
data = config:read('*all')
config:close()
-- Quick check answer is in JSON format
if data:sub(1, 1) == "{" then
jsonOut = json:decode(data)
else
jsonOut = nil
end
return(jsonOut)
end
Code: Select all
-- Get all data for current tempo season
tempoSeasonURL = 'https://www.services-rte.com/cms/open_data/v1/tempo?season='..tempoSeason
tempoSeasonData = getUrlJson(tempoSeasonURL)
if (tempoSeasonData == nil) then
print("TEMPO : Warning, no data/color received from RTE ; Network issue?")
return tempoDay, tempoCount
end
If you don't validate data & can feed crap to Domoticz, I'm afraid but your code is not "correct".
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: CommandArray command in LUA doesn't work anymore
It's probably the case and maybe this is what is causing the issue and blocking the CommandArray
the only things that changed since a couple of days is the RTE website being down
I will try to check this JSON like you did and restore domoticz from a previous working DB and see if it changes
thanks again for the code really helpful will test it
cheers
seb
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: CommandArray command in LUA doesn't work anymore
Ok so after a couple of hours debugging here is the mystery but I found from where it comes
so first thanks for the JSON check, the issue is not coming from here but now the EDF JSON is perfectly parsed thanks again
now my problem :
I have a script called global from where I launch other scripts function of the time or other conditions, no issue so far
in this file there is a part of the code as following :
the script_chauffageauto.lua code is :
now here is the behavior :
I'm totally lost as some other dofile commands in the rest of the code are correctly executed without any issue
if you have any idea or want me to do some tests feel free to tell me
thanks !
seb
so first thanks for the JSON check, the issue is not coming from here but now the EDF JSON is perfectly parsed thanks again
now my problem :
I have a script called global from where I launch other scripts function of the time or other conditions, no issue so far
in this file there is a part of the code as following :
Code: Select all
if otherdevices[getdevicename(1631)] == 'On' then
dofile('/home/pi/domoticz/scripts/lua/script_chauffageauto.lua')
print('[ MESSAGE ] ► Gestion chauffage automatique ON')
else
print('[ MESSAGE ] ► Gestion chauffage automatique OFF')
end
Code: Select all
commandArray={}
return commandArray
now here is the behavior :
- if the condition is ON and the dofile executed = CommandArray STOP WORKING
- if the condition is OFF the dofile is bypassed = commandarray WORKS
- if I remove the code from the script_chauffageauto.lua (so empty script) = commandarray WORKS
- if I rename script_chauffageauto.lua by script_time_chauffageauto.lua = Commandarray WORKS
- if I comment the dofile line --XXX = commandarray WORKS
I'm totally lost as some other dofile commands in the rest of the code are correctly executed without any issue
if you have any idea or want me to do some tests feel free to tell me
thanks !
seb
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
- jvdz
- Posts: 2208
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: CommandArray command in LUA doesn't work anymore
Ofcourse! The dofile needs to be looked at as putting the code from that file at the line of the dofile statement. This means you are clearing the commandArray variable at that time and end the script execution with the return in the dofile.
So do not use the commandArray = {} and return commandArray lines in the dofile!
So do not use the commandArray = {} and return commandArray lines in the dofile!
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: CommandArray command in LUA doesn't work anymore
Damn yes the position of this dofile was clearing the CommandArray table and this is why no command were executed after in domoticz
a so small thing !
thanks a million you saved my night
a so small thing !
thanks a million you saved my night

domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
-
- Posts: 271
- Joined: Sunday 11 May 2014 11:09
- Target OS: Windows
- Domoticz version: 2023.1+
- Location: NL
- Contact:
Re: CommandArray command in LUA doesn't work anymore
You could use something like :
at the firstrow in your script.
Then in the file functions.lua you could create as many functions as you want :
this way you will be able to directly pass variables and call it as you need it like and ecen get returnvalues :
This way your code and functions get separated and your code is nice and clean.
No need to worry for commandArray in your functions.lua file, as this is handled on the calling script.
Code: Select all
package.path = package.path .. ';' .. 'C:/PROGRA~2/domoticz/scripts/lua/functions.lua;'
local my1 = require ("functions")
Then in the file functions.lua you could create as many functions as you want :
Code: Select all
function chauffage(var1, var 2, var3)
... do something with the var
return "Ok"
end
function anothersomething()
do something else....
end
Code: Select all
x=chauffage("On","1234", "ABCD")
anothersomething()
No need to worry for commandArray in your functions.lua file, as this is handled on the calling script.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
Who is online
Users browsing this forum: No registered users and 1 guest