Like Derik, I am struggling to put all files in the right place :
What i did : copied broadband.sh to /domoticz/scripts
in crontab added lines like
*/10 * * * * sudo ~/domoticz/scripts/broadband.sh
*/10 * * * * /usr/local/bin/speed-test --json >/home/pi/domoticz/speed-test.json 2>&1
in the lua scripts directory I have this file named: script_device_internetspeed.lua
with this code
Code: Select all
JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
date = os.date("*t")
if (date.min == 1) then
file = io.open("speed-test.json", "r")
json_text = file:read()
speeds = JSON:decode(json_text)
print("-- Ping="..speeds.ping.." Upload=".. speeds.download)
end
commandArray = {}
JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
date = os.date("*t")
if (date.min == 50) then
file = io.open("speed-test.json", "r")
json_text = file:read()
speeds = JSON:decode(json_text)
print("Ping="..speeds.ping.." Download=".. speeds.download.." Upload=".. speeds.upload)
commandArray[1]={['UpdateDevice']='131|0|'..speeds.download}
commandArray[2]={['UpdateDevice']='132|0|'..speeds.upload}
commandArray[3]={['UpdateDevice']='133|0|'..speeds.ping}
end
return commandArray
However : shouldn't there be a file called JSON.LUA ?
Is there a package I shpould install ?
Thnx for your help