{"id":1870,"date":"2018-02-10T15:50:05","date_gmt":"2018-02-10T13:50:05","guid":{"rendered":"https:\/\/einstein.amsterdam\/?page_id=1870"},"modified":"2018-02-15T19:24:33","modified_gmt":"2018-02-15T18:24:33","slug":"toon-spacestate-app","status":"publish","type":"page","link":"https:\/\/einstein.amsterdam\/?page_id=1870","title":{"rendered":"Toon spaceState App"},"content":{"rendered":"<p><strong>Toon from Eneco (Quby) \ud83d\ude42<\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/einstein.amsterdam\/wp-content\/uploads\/loadscreen_1.png\" alt=\"\" width=\"800\" height=\"480\" class=\"alignnone size-full wp-image-1899\" \/><br \/>\n&nbsp;<\/p>\n<p><strong>Domoticz virtual switch and text result device<\/strong><\/p>\n<p>&#8230;..<\/p>\n<p><strong>Domoticz lua code<\/strong><\/p>\n<p>-get spacestate from hackerspace (json or text result)<br \/>\n-write result to text device in domoticz<br \/>\n-write new json file in www root of domoticz server<br \/>\n&#8211;i cant figured out nested json reading so i rewrite the data in a non nested json<br \/>\n-change virtual switch according to spacestate<\/p>\n<p>use our timer script \ud83d\ude42 from <a href=\"https:\/\/einstein.amsterdam\/?page_id=1890\">here<\/a> and add the code to 5 min&#8217;s entry<\/p>\n<blockquote><p>&#8212;<br \/>\n&#8212; Start Spacestate Script<br \/>\n&#8212;<br \/>\n&#8212; Spacestate Script by Einstein<br \/>\n&#8212;<br \/>\nprint(&#8220;Spacescript Started &#8220;)<\/p>\n<p>local f = assert(io.popen(&#8220;curl https:\/\/techinc.nl\/space\/spacestate&#8221;))<br \/>\nlocal s = assert(f:read(&#8216;*a&#8217;))<br \/>\n&#8212; local threeZero, status, temp = s:match(&#8220;|([^|]*)|([^|]*)|([^|]*)|&#8221;)<br \/>\n&#8212; if status == &#8220;OK&#8221; then<br \/>\n&#8212; you can see prints in Setup\/Log<br \/>\n&#8212; print(&#8220;Space State: &#8220;..s)<br \/>\ncommandArray[&#8220;UpdateDevice&#8221;] = &#8216;110|0|&#8217;..s<\/p>\n<p>if s == &#8220;open&#8221; then<br \/>\nfile = io.open(&#8216;\/var\/opt\/domoticz\/www\/space.json&#8217;, &#8220;w&#8221;)<br \/>\nfile:write(&#8216;{&#8220;state&#8221;:&#8221;open&#8221;, &#8220;color&#8221;:&#8221;#00FF00&#8243;, &#8220;icon&#8221;:&#8221;drawables\/open-sign.png&#8221;, &#8220;test1&#8243;:&#8221;bla123&#8243;,&#8221;result&#8221; : [{&#8220;test&#8221; : &#8220;On&#8221;}]}&#8217;)<br \/>\n&#8211;file:write(&#8220;hello&#8221;, &#8220;\\n&#8221;)<br \/>\nfile:close()<br \/>\ncommandArray[&#8216;Techinc State&#8217;]=&#8217;On&#8217;<br \/>\n&#8211;commandArray[&#8216;Doorbel&#8217;]=&#8217;On&#8217;<br \/>\nend<br \/>\nif s==&#8221;closed&#8221; then<br \/>\nfile = io.open(&#8216;\/var\/opt\/domoticz\/www\/space.json&#8217;, &#8220;w&#8221;)<br \/>\nfile:write(&#8216;{&#8220;state&#8221;:&#8221;closed&#8221;,&#8221;color&#8221;:&#8221;#FF0000&#8243;, &#8220;icon&#8221;:&#8221;drawables\/closed-sign.png&#8221;, &#8220;test2&#8243;:&#8221;bla2&#8221;}&#8217;, &#8220;\\n&#8221;)<br \/>\n&#8211;file:write(&#8220;hello&#8221;, &#8220;\\n&#8221;)<br \/>\nfile:close()<br \/>\ncommandArray[&#8216;Techinc State&#8217;]=&#8217;Off&#8217;<br \/>\nend<br \/>\nprint(&#8220;The space is &#8220;..s)<\/p>\n<p>&#8212;<br \/>\n&#8212; End Spacestate Script<br \/>\n&#8212;<br \/>\n&#8212; Spacestate Script by Einstein<br \/>\n&#8212;<\/p><\/blockquote>\n<p><strong>spaceState App for Toon(qt)<\/strong><br \/>\nGet the Icon version of spaceState <a href=\"https:\/\/einstein.amsterdam\/wp-content\/uploads\/spaceState.zip\">here.<\/a><br \/>\nGet the Text version of spaceState <a href=\"\">here.<\/a> (soon)<\/p>\n<p>Screenshots <a href=\"https:\/\/einstein.amsterdam\/?page_id=1923\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Toon from Eneco (Quby) \ud83d\ude42 &nbsp; Domoticz virtual switch and text result device &#8230;.. Domoticz lua code -get spacestate from hackerspace (json or text result) <a class=\"mh-excerpt-more\" href=\"https:\/\/einstein.amsterdam\/?page_id=1870\" title=\"Toon spaceState App\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages\/1870"}],"collection":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1870"}],"version-history":[{"count":20,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages\/1870\/revisions"}],"predecessor-version":[{"id":1945,"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=\/wp\/v2\/pages\/1870\/revisions\/1945"}],"wp:attachment":[{"href":"https:\/\/einstein.amsterdam\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}