Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1026868 // Smart Home Demo

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (7201L/37K).

1  
!7
2  
3  
cmodule SmartHomeDemo > DynPrintLogAndEnabled {
4  
  start {
5  
    dm_onUserUtterance(s -> {
6  
      S answer = webBot_answer(s, #1026867);
7  
      LS tok = javaTokWithBrackets(answer);
8  
      for (int i = 1; i < l(tok); i += 2)
9  
        if (eqGet(tok, i, "#") && isCurlyBracketed(get(tok, i+2))) {
10  
          S cmd = uncurly(get(tok, i+2));
11  
          print("Have cmd: " + cmd);
12  
          replaceTokens(tok, i, i+3, unnull(runCmd(cmd));
13  
        }
14  
      dm_say(trimJoin(tok));
15  
    });
16  
  }
17  
  
18  
  // API
19  
  
20  
  S runCmd(S s) null {
21  
    if "shutdown"
22  
      ret null with cleanPowerOff();
23  
    LS tok = javaTok(s);
24  
    if (jmatch2("<id>=<int>", tok))
25  
      ret null with dm_mqtt_send(firstToken(tok), lastToken(tok));
26  
    if "ip address"
27  
      ret replace(myV4IP(), ".", ", ");
28  
    if "time"
29  
      ret localTimeForSpeechOutput();
30  
    if "cpu temperature"
31  
      ret dm_cpuTemperature();
32  
  }
33  
}

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: 265 / 1452
Version history: 13 change(s)
Referenced in: [show references]