Uses 911K of libraries. Click here for Pure Java version (7201L/37K).
!7 cmodule SmartHomeDemo > DynPrintLogAndEnabled { start { dm_onUserUtterance(s -> { S answer = webBot_answer(s, #1026867); LS tok = javaTokWithBrackets(answer); for (int i = 1; i < l(tok); i += 2) if (eqGet(tok, i, "#") && isCurlyBracketed(get(tok, i+2))) { S cmd = uncurly(get(tok, i+2)); print("Have cmd: " + cmd); replaceTokens(tok, i, i+3, unnull(runCmd(cmd)); } dm_say(trimJoin(tok)); }); } // API S runCmd(S s) null { if "shutdown" ret null with cleanPowerOff(); LS tok = javaTok(s); if (jmatch2("<id>=<int>", tok)) ret null with dm_mqtt_send(firstToken(tok), lastToken(tok)); if "ip address" ret replace(myV4IP(), ".", ", "); if "time" ret localTimeForSpeechOutput(); if "cpu temperature" ret dm_cpuTemperature(); } }
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1026868 |
| Snippet name: | Smart Home Demo |
| Eternal ID of this version: | #1026868/14 |
| Text MD5: | 8e19ddd85c45b4941b74458e0efe9e31 |
| Transpilation MD5: | 2464276ba3889dcfdf215c2bb212cc8b |
| Author: | stefan |
| Category: | javax / smart demo |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-01-30 13:28:58 |
| Source code size: | 906 bytes / 33 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 506 / 1746 |
| Version history: | 13 change(s) |
| Referenced in: | [show references] |