Toon spaceState App

Toon from Eneco (Quby) 🙂


Domoticz virtual switch and text result device


Domoticz lua code

-get spacestate from hackerspace (json or text result)
-write result to text device in domoticz
-write new json file in www root of domoticz server
–i cant figured out nested json reading so i rewrite the data in a non nested json
-change virtual switch according to spacestate

use our timer script 🙂 from here and add the code to 5 min’s entry

— Start Spacestate Script

— Spacestate Script by Einstein

print(“Spacescript Started “)

local f = assert(io.popen(“curl”))
local s = assert(f:read(‘*a’))
— local threeZero, status, temp = s:match(“|([^|]*)|([^|]*)|([^|]*)|”)
— if status == “OK” then
— you can see prints in Setup/Log
— print(“Space State: “..s)
commandArray[“UpdateDevice”] = ‘110|0|’..s

if s == “open” then
file =‘/var/opt/domoticz/www/space.json’, “w”)
file:write(‘{“state”:”open”, “color”:”#00FF00″, “icon”:”drawables/open-sign.png”, “test1″:”bla123″,”result” : [{“test” : “On”}]}’)
–file:write(“hello”, “\n”)
commandArray[‘Techinc State’]=’On’
if s==”closed” then
file =‘/var/opt/domoticz/www/space.json’, “w”)
file:write(‘{“state”:”closed”,”color”:”#FF0000″, “icon”:”drawables/closed-sign.png”, “test2″:”bla2”}’, “\n”)
–file:write(“hello”, “\n”)
commandArray[‘Techinc State’]=’Off’
print(“The space is “..s)

— End Spacestate Script

— Spacestate Script by Einstein

spaceState App for Toon(qt)
Get the Icon version of spaceState here.
Get the Text version of spaceState here. (soon)

Screenshots here.