/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Administration/SmartHouse/OpenHAB/snippets/telegram_process.gui_rule

  • Committer: Suren A. Chilingaryan
  • Date: 2022-06-20 03:20:18 UTC
  • Revision ID: csa@suren.me-20220620032018-xquk369l0ukymgaa
Home Assistant

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
var String text = ""
2
 
var String from = ""
3
 
var String commands = "/office_light"
4
 
 
5
 
   // See UID of Telegram Thing
6
 
val telegramAction = getActions("telegram","telegram:telegramBot:df22be725f")
7
 
  
8
 
if (receivedEvent != null) {
9
 
  text = transform("JSONPATH", "$.text", receivedEvent.toString)
10
 
//  from = transform("JSONPATH", "$.from", receivedEvent.toString)
11
 
}
12
 
 
13
 
switch (text.toLowerCase) {
14
 
  case "/office_light": { 
15
 
    var status=callScript ("switch_office_light");
16
 
    try {
17
 
        // Replying to other bot is impossible
18
 
      telegramAction.sendTelegram("OK. Switching " + status);
19
 
    } catch (Exception e) {
20
 
      logInfo("telegram_parser", "Executed command: " + text);
21
 
    }
22
 
  }
23
 
  default: {
24
 
    try {
25
 
        // Replying to other bot is impossible
26
 
      telegramAction.sendTelegram("Unknown command: " + text + ", try: " + commands);
27
 
    } catch (Exception e) {
28
 
      logInfo("telegram_parser", "Unknown command: " + text);
29
 
    }
30
 
  }
31
 
}