Page 1 of 1
Enable lua (time) script by switch (possible?)
Posted: Wednesday 31 May 2017 20:16
by Jan Jansen
I would like to use the moon phase script (
viewtopic.php?f=67&t=16526&p=130249#p130249 )
only if a particular switch is on. Is that possible??
Thanks in advance.
Re: Enable lua (time) script by switch (possible?)
Posted: Friday 02 June 2017 21:22
by SweetPants
If you can somehow set 'Status' in the Domoticz database table 'Eventmaster', you can enable (1) or disable (0) a LUA script.
Re: Enable lua (time) script by switch (possible?)
Posted: Saturday 03 June 2017 14:59
by Jan Jansen
SweetPants wrote:If you can somehow set 'Status' in the Domoticz database table 'Eventmaster', you can enable (1) or disable (0) a LUA script.
Thanks for your answer.
My conclusion based on your answer: It is not possible to add the function of a switch (if on >> script runs on time, if off >> script don’t run) to the script itself. Am I right?
Re: Enable lua (time) script by switch (possible?)
Posted: Saturday 03 June 2017 15:32
by SweetPants
I'm not sure if i understand you correctly, but you can have an 'On/Off action' coupled on a switch.
This action can fire an http:// request or run a script://. In your case you should have a script that modfies the database eventmaster table column 'Status' of the script. You should either have the 'ID' or 'Name' of the script to select it in your SQL select statement.
I guess the buienradar script is a 'time' based script, so if 'Status' enabled it will run by itself every minute.
Re: Enable lua (time) script by switch (possible?)
Posted: Saturday 03 June 2017 16:48
by Jan Jansen
@ SweetPants
I now have the impression that it is possible but I do not quite know how to do it.
It concerns the following code (saved as domoticz/scripts/lua/script_time_maanfase.lua). The script itself works as desired.
Code: Select all
-- Variables to customize ------------------------------------------------
local moonpicture = "MoonPicture" -- name of the uservar to write the name of the moonphase picture to
local checkvar = "MoonphaseCheck" -- name of the uservar to check if update is allowed
local checktime = 3600 -- check allowed every x seconds 3600 = 60 min. Check the wundergroud API limitation before changing this
local city = "<your town>" -- Your city for Wunderground API
local countryCode = "<YOUR COUNTRY CODE>" -- Your country code for Wunderground API
local idxmoonpercentage ='125' -- Your virtual moon percentage illuminated Device ID
local idxmoonage ='131' -- Your virtual moon age Device ID
local idxmoonphase ='132' -- Your virtual moon phase Device ID
local idxmoonrise='124' -- Your virtual moon rise variable ID
local idxmoonset='127' -- Your virtual moon set variable ID
local wuAPIkey = "<your key>" -- Your Weather Underground API Key
local DOMO_IP = "<your domo ip>" -- Domoticz ip address
local DOMO_PORT = "<your domo port>" -- Domoticz port
local tempfilename = '/var/tmp/phase.tmp' -- can be anywhere writeable
local debug=false -- false, true for domoticz log
-------------------------------------------------------------------------
function file_exists(path)
-- function to check if a file exists
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
function timedifference(s)
-- function to determine the difference in seconds between the current time and a given one
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
function may_update(device, timeelapsed)
-- function to check whether an update is allowed
return uservariables_lastupdate[device] == nil or timedifference(uservariables_lastupdate[device]) >= timeelapsed
end
commandArray = {}
time = os.date("*t")
url='http://api.wunderground.com/api/'..wuAPIkey..'/astronomy/q/'..countryCode..'/'..city..'.json'
if (may_update(checkvar,checktime)==true) or (file_exists(tempfilename)==false) then
-- read API Wunderground
if debug then print("Moonphase - Collecting data from: "..url) end
os.execute('curl -s '..url..' > '..tempfilename)
-- NOTE: if the command above doens't work in your situation try
-- read = os.execute('curl -s -o '..tempfilename..' "'..url..'"')
-- instead! Thanks to EdKo66
file = io.open(tempfilename, "r")
s= file:read("*a")
s = (string.gsub(s, "%c+", ""))
file:close()
-- moonrise
moonriseHour, moonriseMinute = string.match(s, [["moonrise": {"hour":"(%d+)","minute":"(%d+)"]])
if debug then print("Moonrise:\t"..moonriseHour..":"..moonriseMinute) end
-- moonset
moonsetHour, moonsetMinute = string.match(s, [["moonset": {"hour":"(%d+)","minute":"(%d+)"]])
if debug then print("Moonset:\t"..moonsetHour..":"..moonsetMinute) end
-- percentage of moon illuminated
percentIlluminated = string.match(s, [["percentIlluminated":"(%d+)"]])
if debug then print("Percent:\t"..percentIlluminated.."%") end
-- age of moon since last new moon
age = string.match(s, [["ageOfMoon":"(%d+)"]])
if debug then print("Age:\t\t"..age) end
-- Phase of the moon
-- set the moonPhaseIcon to your appropriate icon number (8 x)
moonPhase = string.match(s, [["phaseofMoon":"(.-)"]])
if moonPhase=="New Moon" then
moonPhase = "Nieuwe maan"
is_waxing = true
end
if moonPhase=="Waxing Crescent" then
moonPhase = "Wassende halve maan"
is_waxing = true
end
if moonPhase=="First Quarter" then
moonPhase = "Eerste kwartier"
is_waxing = true
end
if moonPhase=="Waxing Gibbous" then
moonPhase = "Wassende maan"
is_waxing = true
end
if moonPhase=="Full" then
moonPhase = "Volle maan"
is_waxing = false
end
if moonPhase=="Waning Gibbous" then
moonPhase = "Afnemende maan"
is_waxing = false
end
if moonPhase=="Last Quarter" then
moonPhase = "Laatste kwartier"
is_waxing = false
end
if moonPhase=="Waning Crescent" then
moonPhase = "Afnemende halve maan"
is_waxing = false
end
-- calculate moonphase picture
if percentIlluminated == '0' then
n='50'
else
if waardecheck==false then
picnumber=math.floor(math.abs(percentIlluminated-100)/2)
else
picnumber=math.floor(50+(percentIlluminated/2))
if picnumber == 100 then
picnumber=99
end
end
n=tostring(picnumber)
if string.len(n)==1 then
n='0'..n
end
end
picture='moon.'..n..'.png'
if debug then print('Picture number: '..n..' '..'Picture name: '..picture) end
commandArray['Variable:'..checkvar]=moonPhase
commandArray['Variable:'..moonpicture]=picture
commandArray[1] = {['UpdateDevice'] = idxmoonphase.."|0|"..moonPhase}
commandArray[2] = {['UpdateDevice'] = idxmoonrise.."|0|"..moonriseHour..":"..moonriseMinute}
commandArray[3] = {['UpdateDevice'] = idxmoonset.."|0|"..moonsetHour..":"..moonsetMinute}
commandArray[4] = {['UpdateDevice'] = idxmoonage.."|0|"..age}
commandArray[5] = {['UpdateDevice'] = idxmoonpercentage.."|0|"..percentIlluminated}
else
if debug then print("MoonPhase - Update not allowed: Difference is "..timedifference(uservariables_lastupdate[checkvar]).." seconds") end
end
return commandArray
I can create a virtual switch. I know a switch has an On and Off Action field, I now think I have to use this fields to achieve my goal.
I know now that Domoticz uses a SQL database. That's where my knowledge stops. So, I need help in compiling the http request that modifies the database. I hope you can help.
Thanks in advance.
Re: Enable lua (time) script by switch (possible?)
Posted: Saturday 03 June 2017 17:42
by berny
Maybe you can create a dummy switch.
If you switch the dummy on, run an bash script that copy your time script from a temp directory to the lua directory.
If you switch the dummy switch off, run a bash script to delete the time script in the lua directory.
Re: Enable lua (time) script by switch (possible?)
Posted: Saturday 03 June 2017 18:42
by matteos1
is it possible add more Selector actions in a cell??
Re: Enable lua (time) script by switch (possible?)
Posted: Sunday 04 June 2017 13:29
by SweetPants
matteos1 wrote:is it possible add more Selector actions in a cell??
If you want to ask a non-related question, please open a new topic. This gets confusing and you may not get an answer
Re: Enable lua (time) script by switch (possible?)
Posted: Sunday 04 June 2017 14:52
by Jan Jansen
berny wrote:Maybe you can create a dummy switch.
If you switch the dummy on, run an bash script that copy your time script from a temp directory to the lua directory.
If you switch the dummy switch off, run a bash script to delete the time script in the lua directory.
Based on my limited knowledge, I first try this option. So far, I could copy and paste the necessary codes. But in this case, I could not find the suggested code. I made one myself but I failed.
Steps I made:
- Created a virtual switch 'Test' idx=12;
- In the /domoticz/ directory, I created a new directory "program_storage" in which I installed the "script_time_maanfase.lua" code;
- The following code was placed in the /domoticz/scripts/ directory.

- Knipsel.PNG (27.32 KiB) Viewed 4352 times
- execute sudo chmod+ program_switch.sh
When I turn the switch 'on' nothing happens > also no errors in domoticz and syslog. Conclusion: I need help in making the next step.
Thanks in advance.
Re: Enable lua (time) script by switch (possible?)
Posted: Monday 05 June 2017 10:54
by zicht
Why making it so complicated ?
Just add the switch to the lua script in an "if then" statement
Code: Select all
If otherdevices["ÿour switch"]=="on" then
moon script
end
Or even better put it in function that you can call on the switch (or any other) condition.
The "if then" of "function" consumes no time at al if the condition is not true . (<2 ms)
Re: Enable lua (time) script by switch (possible?)
Posted: Tuesday 06 June 2017 15:16
by Jan Jansen
Let me start with the goal first. This setup is for mobile use. An internet connection is therefore not always available. No internet means many error messages in the Domoticz log. I want to avoid those errors, which is the reason for my question.
zicht wrote:Why making it so complicated ?
Just add the switch to the lua script in an "if then" statement
Code: Select all
If otherdevices["ÿour switch"]=="on" then
moon script
end
@zicht, thank you for your attention. I tried your suggestion, but it does not work as desired.
edited code (original see
https://www.domoticz.com/forum/viewtopi ... 49#p130249 )
Code: Select all
-- Variables to customize ------------------------------------------------
local moonpicture = "MoonPicture" -- name of the uservar to write the name of the moonphase picture to
local checkvar = "MoonphaseCheck" -- name of the uservar to check if update is allowed
local checktime = 3600 -- check allowed every x seconds 3600 = 60 min. Check the wundergroud API limitation before changing this
local city = "<your town>" -- Your city for Wunderground API
local countryCode = "<YOUR COUNTRY CODE>" -- Your country code for Wunderground API
local idxmoonpercentage ='125' -- Your virtual moon percentage illuminated Device ID
local idxmoonage ='131' -- Your virtual moon age Device ID
local idxmoonphase ='132' -- Your virtual moon phase Device ID
local idxmoonrise='124' -- Your virtual moon rise variable ID
local idxmoonset='127' -- Your virtual moon set variable ID
local wuAPIkey = "<your key>" -- Your Weather Underground API Key
local DOMO_IP = "<your domo ip>" -- Domoticz ip address
local DOMO_PORT = "<your domo port>" -- Domoticz port
local tempfilename = '/var/tmp/phase.tmp' -- can be anywhere writeable
local debug=false -- false, true for domoticz log
-------------------------------------------------------------------------
if otherdevices["Test"]=="on" then
function file_exists(path)
-- function to check if a file exists
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
function timedifference(s)
-- function to determine the difference in seconds between the current time and a given one
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
function may_update(device, timeelapsed)
-- function to check whether an update is allowed
return uservariables_lastupdate[device] == nil or timedifference(uservariables_lastupdate[device]) >= timeelapsed
end
commandArray = {}
time = os.date("*t")
url='http://api.wunderground.com/api/'..wuAPIkey..'/astronomy/q/'..countryCode..'/'..city..'.json'
if (may_update(checkvar,checktime)==true) or (file_exists(tempfilename)==false) then
-- read API Wunderground
if debug then print("Moonphase - Collecting data from: "..url) end
os.execute('curl -s '..url..' > '..tempfilename)
-- NOTE: if the command above doens't work in your situation try
-- read = os.execute('curl -s -o '..tempfilename..' "'..url..'"')
-- instead! Thanks to EdKo66
file = io.open(tempfilename, "r")
s= file:read("*a")
s = (string.gsub(s, "%c+", ""))
file:close()
-- moonrise
moonriseHour, moonriseMinute = string.match(s, [["moonrise": {"hour":"(%d+)","minute":"(%d+)"]])
if debug then print("Moonrise:\t"..moonriseHour..":"..moonriseMinute) end
-- moonset
moonsetHour, moonsetMinute = string.match(s, [["moonset": {"hour":"(%d+)","minute":"(%d+)"]])
if debug then print("Moonset:\t"..moonsetHour..":"..moonsetMinute) end
-- percentage of moon illuminated
percentIlluminated = string.match(s, [["percentIlluminated":"(%d+)"]])
if debug then print("Percent:\t"..percentIlluminated.."%") end
-- age of moon since last new moon
age = string.match(s, [["ageOfMoon":"(%d+)"]])
if debug then print("Age:\t\t"..age) end
-- Phase of the moon
-- set the moonPhaseIcon to your appropriate icon number (8 x)
moonPhase = string.match(s, [["phaseofMoon":"(.-)"]])
if moonPhase=="New Moon" then
moonPhase = "Nieuwe maan"
is_waxing = true
end
if moonPhase=="Waxing Crescent" then
moonPhase = "Wassende halve maan"
is_waxing = true
end
if moonPhase=="First Quarter" then
moonPhase = "Eerste kwartier"
is_waxing = true
end
if moonPhase=="Waxing Gibbous" then
moonPhase = "Wassende maan"
is_waxing = true
end
if moonPhase=="Full" then
moonPhase = "Volle maan"
is_waxing = false
end
if moonPhase=="Waning Gibbous" then
moonPhase = "Afnemende maan"
is_waxing = false
end
if moonPhase=="Last Quarter" then
moonPhase = "Laatste kwartier"
is_waxing = false
end
if moonPhase=="Waning Crescent" then
moonPhase = "Afnemende halve maan"
is_waxing = false
end
-- calculate moonphase picture
if percentIlluminated == '0' then
n='50'
else
if waardecheck==false then
picnumber=math.floor(math.abs(percentIlluminated-100)/2)
else
picnumber=math.floor(50+(percentIlluminated/2))
if picnumber == 100 then
picnumber=99
end
end
n=tostring(picnumber)
if string.len(n)==1 then
n='0'..n
end
end
picture='moon.'..n..'.png'
if debug then print('Picture number: '..n..' '..'Picture name: '..picture) end
commandArray['Variable:'..checkvar]=moonPhase
commandArray['Variable:'..moonpicture]=picture
commandArray[1] = {['UpdateDevice'] = idxmoonphase.."|0|"..moonPhase}
commandArray[2] = {['UpdateDevice'] = idxmoonrise.."|0|"..moonriseHour..":"..moonriseMinute}
commandArray[3] = {['UpdateDevice'] = idxmoonset.."|0|"..moonsetHour..":"..moonsetMinute}
commandArray[4] = {['UpdateDevice'] = idxmoonage.."|0|"..age}
commandArray[5] = {['UpdateDevice'] = idxmoonpercentage.."|0|"..percentIlluminated}
else
if debug then print("MoonPhase - Update not allowed: Difference is "..timedifference(uservariables_lastupdate[checkvar]).." seconds") end
end
end
return commandArray
domoticz log shows
Code: Select all
2017-06-06 14:56:00.077 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
2017-06-06 14:56:25.918 Hardware Monitor: Fetching data (System sensors)
2017-06-06 14:56:56.021 Hardware Monitor: Fetching data (System sensors)
2017-06-06 14:57:00.127 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
2017-06-06 14:57:26.123 Hardware Monitor: Fetching data (System sensors)
2017-06-06 14:57:56.225 Hardware Monitor: Fetching data (System sensors)
2017-06-06 14:58:00.177 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
2017-06-06 14:58:26.376 Hardware Monitor: Fetching data (System sensors)
2017-06-06 14:58:36.959 User: Admin initiated a switch command (12/Test/On)
2017-06-06 14:58:36.971 (Test) Lighting 1 (Test)
2017-06-06 14:58:56.478 Hardware Monitor: Fetching data (System sensors)
2017-06-06 14:59:00.226 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
2017-06-06 14:59:26.582 Hardware Monitor: Fetching data (System sensors)
2017-06-06 14:59:56.684 Hardware Monitor: Fetching data (System sensors)
2017-06-06 15:00:00.414 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
2017-06-06 15:00:00.434 LUA: Seizoen aangepast naar Lente
2017-06-06 15:00:00.491 (Seizoen) Light/Switch (Seizoen)
2017-06-06 15:00:26.787 Hardware Monitor: Fetching data (System sensors)
2017-06-06 15:00:56.889 Hardware Monitor: Fetching data (System sensors)
2017-06-06 15:01:00.481 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
2017-06-06 15:01:26.992 Hardware Monitor: Fetching data (System sensors)
2017-06-06 15:01:57.095 Hardware Monitor: Fetching data (System sensors)
2017-06-06 15:02:00.031 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
2017-06-06 15:02:27.198 Hardware Monitor: Fetching data (System sensors)
2017-06-06 15:02:57.301 Hardware Monitor: Fetching data (System sensors)
2017-06-06 15:03:00.081 Error: EventSystem: Lua script /home/pi/domoticz/scripts/lua/script_time_maanfasetest.lua did not return a commandArray
As the log indicates, it does not matter whether the switch is on or off. Even when I use script_device instead of script_time, I get the same errors in domoticz log. I got stuck! Thanks in advance for someone's precious time.
Re: Enable lua (time) script by switch (possible?)
Posted: Tuesday 06 June 2017 22:24
by zicht
Hi
The functions can be out of the if then as they are called as a subroutine code.
The if then should be a couple of lines later, i am pretty sture thats what is causing the errors in your log.
Now the start of Commandarray is skipped when your switch is off.
have a Try with the below place of the " if then "
Code: Select all
-- Variables to customize ------------------------------------------------
local moonpicture = "MoonPicture" -- name of the uservar to write the name of the moonphase picture to
local checkvar = "MoonphaseCheck" -- name of the uservar to check if update is allowed
local checktime = 3600 -- check allowed every x seconds 3600 = 60 min. Check the wundergroud API limitation before changing this
local city = "<your town>" -- Your city for Wunderground API
local countryCode = "<YOUR COUNTRY CODE>" -- Your country code for Wunderground API
local idxmoonpercentage ='125' -- Your virtual moon percentage illuminated Device ID
local idxmoonage ='131' -- Your virtual moon age Device ID
local idxmoonphase ='132' -- Your virtual moon phase Device ID
local idxmoonrise='124' -- Your virtual moon rise variable ID
local idxmoonset='127' -- Your virtual moon set variable ID
local wuAPIkey = "<your key>" -- Your Weather Underground API Key
local DOMO_IP = "<your domo ip>" -- Domoticz ip address
local DOMO_PORT = "<your domo port>" -- Domoticz port
local tempfilename = '/var/tmp/phase.tmp' -- can be anywhere writeable
local debug=false -- false, true for domoticz log
-------------------------------------------------------------------------
function file_exists(path)
-- function to check if a file exists
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
function timedifference(s)
-- function to determine the difference in seconds between the current time and a given one
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
function may_update(device, timeelapsed)
-- function to check whether an update is allowed
return uservariables_lastupdate[device] == nil or timedifference(uservariables_lastupdate[device]) >= timeelapsed
end
commandArray = {}
if otherdevices["Test"]=="on" then
time = os.date("*t")
url='http://api.wunderground.com/api/'..wuAPIkey..'/astronomy/q/'..countryCode..'/'..city..'.json'
if (may_update(checkvar,checktime)==true) or (file_exists(tempfilename)==false) then
-- read API Wunderground
if debug then print("Moonphase - Collecting data from: "..url) end
os.execute('curl -s '..url..' > '..tempfilename)
-- NOTE: if the command above doens't work in your situation try
-- read = os.execute('curl -s -o '..tempfilename..' "'..url..'"')
-- instead! Thanks to EdKo66
file = io.open(tempfilename, "r")
s= file:read("*a")
s = (string.gsub(s, "%c+", ""))
file:close()
-- moonrise
moonriseHour, moonriseMinute = string.match(s, [["moonrise": {"hour":"(%d+)","minute":"(%d+)"]])
if debug then print("Moonrise:\t"..moonriseHour..":"..moonriseMinute) end
-- moonset
moonsetHour, moonsetMinute = string.match(s, [["moonset": {"hour":"(%d+)","minute":"(%d+)"]])
if debug then print("Moonset:\t"..moonsetHour..":"..moonsetMinute) end
-- percentage of moon illuminated
percentIlluminated = string.match(s, [["percentIlluminated":"(%d+)"]])
if debug then print("Percent:\t"..percentIlluminated.."%") end
-- age of moon since last new moon
age = string.match(s, [["ageOfMoon":"(%d+)"]])
if debug then print("Age:\t\t"..age) end
-- Phase of the moon
-- set the moonPhaseIcon to your appropriate icon number (8 x)
moonPhase = string.match(s, [["phaseofMoon":"(.-)"]])
if moonPhase=="New Moon" then
moonPhase = "Nieuwe maan"
is_waxing = true
end
if moonPhase=="Waxing Crescent" then
moonPhase = "Wassende halve maan"
is_waxing = true
end
if moonPhase=="First Quarter" then
moonPhase = "Eerste kwartier"
is_waxing = true
end
if moonPhase=="Waxing Gibbous" then
moonPhase = "Wassende maan"
is_waxing = true
end
if moonPhase=="Full" then
moonPhase = "Volle maan"
is_waxing = false
end
if moonPhase=="Waning Gibbous" then
moonPhase = "Afnemende maan"
is_waxing = false
end
if moonPhase=="Last Quarter" then
moonPhase = "Laatste kwartier"
is_waxing = false
end
if moonPhase=="Waning Crescent" then
moonPhase = "Afnemende halve maan"
is_waxing = false
end
-- calculate moonphase picture
if percentIlluminated == '0' then
n='50'
else
if waardecheck==false then
picnumber=math.floor(math.abs(percentIlluminated-100)/2)
else
picnumber=math.floor(50+(percentIlluminated/2))
if picnumber == 100 then
picnumber=99
end
end
n=tostring(picnumber)
if string.len(n)==1 then
n='0'..n
end
end
picture='moon.'..n..'.png'
if debug then print('Picture number: '..n..' '..'Picture name: '..picture) end
commandArray['Variable:'..checkvar]=moonPhase
commandArray['Variable:'..moonpicture]=picture
commandArray[1] = {['UpdateDevice'] = idxmoonphase.."|0|"..moonPhase}
commandArray[2] = {['UpdateDevice'] = idxmoonrise.."|0|"..moonriseHour..":"..moonriseMinute}
commandArray[3] = {['UpdateDevice'] = idxmoonset.."|0|"..moonsetHour..":"..moonsetMinute}
commandArray[4] = {['UpdateDevice'] = idxmoonage.."|0|"..age}
commandArray[5] = {['UpdateDevice'] = idxmoonpercentage.."|0|"..percentIlluminated}
else
if debug then print("MoonPhase - Update not allowed: Difference is "..timedifference(uservariables_lastupdate[checkvar]).." seconds") end
end
end
return commandArray
Re: Enable lua (time) script by switch (possible?)
Posted: Sunday 07 April 2019 10:41
by Derik
dear...
Someone have this working, after weather underground is stopped working?
Re: Enable lua (time) script by switch (possible?)
Posted: Sunday 12 May 2019 14:23
by alexsh1
Derik wrote: ↑Sunday 07 April 2019 10:41
dear...
Someone have this working, after weather underground is stopped working?
No. wundersround API is down and now I am searching too for another astronomy API.
The script will have to be adopted for a new API.