Request: Lua script can read settings
Posted: Tuesday 26 June 2018 18:40
I'd like to be able to read the settings using lua. Especially the location settings are of interest to me.
I know I could use json, but since I protected my Domotic, I have to use a userid/password in the script which I don't like for some reason.
Nice to have:
location = settings['location'] (as a line in a lua script)
from https://www.domoticz.com/wiki/Lua_-_json.lua (with change to use wget instead of curl):
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
--json = (loadfile "D:\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows
read = os.execute('wget '..tempfilename..' http://localhost:<port>/json.htm?type=settings')
file = io.open(tempfilename, "r")
settings = file:read('*all')
file.close()
location = json:decode(settings)
lat = jsonLocation.current_observation.display_location.latitude
lon = jsonLocation.current_observation.display_location.longitude
I know I could use json, but since I protected my Domotic, I have to use a userid/password in the script which I don't like for some reason.
Nice to have:
location = settings['location'] (as a line in a lua script)
from https://www.domoticz.com/wiki/Lua_-_json.lua (with change to use wget instead of curl):
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
--json = (loadfile "D:\\Domoticz\\scripts\\lua\\json.lua")() -- For Windows
read = os.execute('wget '..tempfilename..' http://localhost:<port>/json.htm?type=settings')
file = io.open(tempfilename, "r")
settings = file:read('*all')
file.close()
location = json:decode(settings)
lat = jsonLocation.current_observation.display_location.latitude
lon = jsonLocation.current_observation.display_location.longitude