Lua script not working for some reason

Moderator: leecollings

Post Reply
Martin
Posts: 13
Joined: Wednesday 27 January 2016 11:41
Target OS: Raspberry Pi / ODroid
Domoticz version: stable
Contact:

Lua script not working for some reason

Post by Martin »

Code: Select all

-- script_time_lux1.lua
commandArray = {}

time = os.date("*t")

if((time.min % 1)==0)then
	L4 = tonumber(uservariables['Light_A'])
	s = tonumber(otherdevices_svalues['Avg_LUX'])
	
	
	-- The following statement is not working!
	if L4 < 1000 then
		commandArray['Scherm_uit'] = 'Off'
	else
		commandArray['Scherm_uit'] = 'On'
	end
	
	
end

return commandArray
L4 is the average of a lux meter.

The if statement that checks if L4 is lower than 1000 is not working.
Anyone knows why?
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: Lua script not working for some reason

Post by jmleglise »

Did you trace the execution of your script ?

like this :

Code: Select all

-- script_time_lux1.lua
commandArray = {}

time = os.date("*t")

if((time.min % 1)==0)then

   L4 = tonumber(uservariables['Light_A'])
   print("L4="..L4)
   s = tonumber(otherdevices_svalues['Avg_LUX'])
   
   
   -- The following statement is not working!
   if L4 < 1000 then
   	print("true")
      commandArray['Scherm_uit'] = 'Off'
   else
   print("false")
      commandArray['Scherm_uit'] = 'On'
   end
   
   
end

return commandArray
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest