001/*
002 *  $URL: svn://svn.webarts.bc.ca/open/trunk/projects/WebARTS/ca/bc/webarts/tools/isy/ELKRestRequester.java $
003 *  $Author: tgutwin $
004 *  $Revision: 1091 $
005 *  $Date: 2016-05-29 16:26:54 -0700 (Sun, 29 May 2016) $
006 */
007/*
008 *
009 *  Written by Tom Gutwin - WebARTS Design.
010 *  Copyright (C) 2016 WebARTS Design, North Vancouver Canada
011 *  http://www.webarts.ca
012 *
013 *  This program is free software; you can redistribute it and/or modify
014 *  it under the terms of the GNU General Public License as published by
015 *  the Free Software Foundation; version 3 of the License, or
016 *  (at your option) any later version.
017 *
018 *  This program is distributed in the hope that it will be useful,
019 *  but WITHOUT ANY WARRANTY; without_ even the implied warranty of
020 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
021 *  GNU General Public License for more details.
022 *
023 *  You should have received a copy of the GNU General Public License
024 *  along with this program; if not, write to the Free Software
025 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
026 */
027
028package ca.bc.webarts.tools.isy;
029
030import java.io.IOException;
031import java.lang.Integer;
032import java.net.HttpURLConnection;
033import java.net.MalformedURLException;
034import java.net.URL;
035import java.util.Arrays;
036import java.util.Hashtable;
037import java.util.Set;
038
039import ca.bc.webarts.tools.RestRequester;
040import ca.bc.webarts.tools.isy.ISYRestRequester;
041import ca.bc.webarts.widgets.Quick;
042
043import org.apache.commons.codec.binary.Base64;
044
045import nu.xom.Attribute;
046import nu.xom.Builder;
047import nu.xom.Document;
048import nu.xom.Element;
049import nu.xom.Elements;
050import nu.xom.Node;
051import nu.xom.ParsingException;
052import nu.xom.ValidityException;
053import nu.xom.Serializer;
054
055
056/**
057  * This class wraps the communication to the ELK REST interface of a
058  * <a href="http://www.universal-devices.com">UDI ISY-994</a>.
059  * It provides many prebuilt java methods that wrap specific ELK REST call or you can request any one that
060  * is specified in the REST API (ELK section) -
061  * <a href="http://wiki.universal-devices.com/index.php?title=ISY_Developers:API:REST_Interface#ELK_Integration">
062  * http://wiki.universal-devices.com/index.php?title=ISY_Developers:API:REST_Interface</a>.<br />
063  *  Written by Tom Gutwin - WebARTS Design.<br />
064  *  Copyright &copy; 2016 WebARTS Design, North Vancouver Canada<br />
065  *  <a href="http://www.webarts.ca">http://www.webarts.ca</a>
066  *
067  * @author  Tom B. Gutwin
068  **/
069public class ELKRestRequester extends ISYRestRequester
070{
071  protected static final String CLASSNAME = "ca.bc.webarts.tools.isy.ELKRestRequester"; //ca.bc.webarts.widgets.Util.getCurrentClassName();
072  public static final String LOG_TAG = "\n"+CLASSNAME; //+"."+ca.bc.webarts.android.Util.getCurrentClassName();
073
074  /** The start path to use in therest URL. This class over-rides this with DEFAULT_ISY994_REST_URL_PATHSTR + "/elk". **/
075  protected String restUrlPath_ = DEFAULT_ISY994_REST_URL_PATHSTR + "/elk";
076
077  protected static boolean debugOut_ = true;
078
079
080  /**
081    * Default constructor that authenticates the default ISY with the default user password (using the class vars)
082    * UNLESS the tomsIsy_ class var is true to over-ride with TOMS _isy IP, userID, and password.
083    * TOMS settings get 1st priority, and DEFAULTS if {@link  #tomsIsy_ tomsIsy_} class var is false.
084    *
085    * @see #DEFAULT_ISY994_IP
086    * @see #DEFAULT_ISY994_USERNAME
087    * @see #DEFAULT_ISY994_PASSWORD
088    **/
089  public ELKRestRequester()
090  {
091    super();
092    //String restUrlPath = DEFAULT_ISY994_REST_URL_PATHSTR + "/elk";
093    setBaseUrl( getBaseUrl() + "/elk");
094  }
095
096
097  /**
098    * Set Method for class field 'restUrlPath_'.
099    *
100    * @param restUrlPath_ is the value to set this class field to.
101    *
102    **/
103  public  void setRestUrlPath(String restUrlPath)
104  {
105    super.setRestUrlPath(restUrlPath);
106  }  // setRestUrlPath Method
107
108
109  /**
110    * Get Method for class field 'restUrlPath_'.
111    *
112    * @return String - The value the class field 'restUrlPath_'.
113    *
114    **/
115  public String getRestUrlPath()
116  {
117    return super.getRestUrlPath();
118  }  // getRestUrlPath Method
119
120
121  /** Sends a REST call to elk/areas/query to query all areas and changes to states are published through event infrastructure . **/
122  public StringBuilder queryAllAreas()
123  {
124    return this.serviceGet("/areas/query");
125  }
126
127
128  /** Sends a REST call to elk to speak a phrase specified by the pre-defined wordID.
129    * For example 214 = "welcome"   and 458 = "home"
130    **/
131  public StringBuilder speakPhrase(words word)
132  {
133    String restCmd = "/speak/phrase/" + word.wordId();
134    // 1st check if a valid wordID or phaseID
135
136    // if it is a word then use it as is
137
138    // else change it to the phase cmd  /speak/phrase/<wordId>
139
140    return this.serviceGet(restCmd);
141  }
142
143
144  /** Sends a REST call to elk to speak a word specified by the pre-defined wordID.
145    * For example 214 = "welcome"   and 458 = "home"
146    **/
147  public StringBuilder speakWord(words word)
148  {
149    String restCmd = "/speak/word/" + word.wordId();
150    // 1st check if a valid wordID or phaseID
151
152    // if it is a word then use it as is
153
154    // else change it to the phase cmd  /speak/phrase/<wordId>
155
156    return this.serviceGet(restCmd);
157  }
158
159
160  /**
161   * Class main commandLine entry method that has a test command and some convienience commands, as well as a pure rest command.
162   **/
163  public static void main(String [] args)
164  {
165    final String methodName = CLASSNAME + ": main()";
166    ELKRestRequester instance = new ELKRestRequester();
167
168    /* Simple way af parsing the args */
169    if (args ==null || args.length<1)
170      System.out.println(getHelpMsgStr());
171    /* *************************************** */
172    else
173    {
174      if (args[0].equalsIgnoreCase("test"))
175      {
176        instance.testCMD(args);
177      }
178      /* *************************************** */
179      else if (args[0].equalsIgnoreCase("listAreas"))
180      {
181        instance.listAreasCMD(args);
182      }
183      /* *************************************** */
184      else if (args[0].equalsIgnoreCase("sayWelcomeHome"))
185      {
186        instance.sayWelcomeHomeCMD(args);
187      }
188      /* *************************************** */
189      else
190      {
191        instance.restCMD(args);
192      }
193    }
194  } // main
195
196
197  /**
198   * commandLine command executor method for the test Command.
199   * @param args the array of commandLine args that got passed in
200   **/
201  protected void testCMD(String [] args)
202  {
203    final String methodName = CLASSNAME + ": testCMD(String [])";
204    //parseAllNodes(); // fast return if already parsed
205
206
207    System.out.println("Testing ISY ELK Rest Service: "+ "/sys");
208    StringBuilder resp =  serviceGet("/get/status");
209    System.out.println(resp.toString()); System.out.println();
210    //System.out.println("Testing ISY ELK Rest Service: "+ "Turn the Downstairs Kitchen Lights on: "+ isyNodes_.getNodeName(DWNKITCHEN_ADDR) +" ("+DWNKITCHEN_ADDR+")");
211    //resp = deviceAddressOn(DWNKITCHEN_ADDR);
212    //System.out.println(resp.toString());  System.out.println();
213    //System.out.println("Testing ISY Rest Service: "+ "checking status of the "+GAMESROOMLIGHTS_NODENAME);
214    //int devStatus = deviceStatus(GAMESROOMLIGHTS_NODENAME);
215    //System.out.println("GAMESROOMLIGHTS level:"+devStatus); System.out.println();
216
217  }
218
219
220  /**
221   * commandLine command executor method for the listAreas Command.
222   * @param args the array of commandLine args that got passed in
223   **/
224  protected void listAreasCMD(String [] args)
225  {
226    final String methodName = CLASSNAME + ": listAreasCMD(String [])";
227    System.out.println("ISY ELK Rest Services: "+ "listAreas");
228    //parseAllNodes(); // fast return if already parsed
229    StringBuilder resp =  queryAllAreas(); // true means sorted
230    System.out.println(resp.toString());
231  }
232
233
234  protected void speakCurrentTime()
235  {
236    String isyUrl = "http://"+(getTomsIsy()?TOMS_ISY994_IP:DEFAULT_ISY994_IP) + super.getRestUrlPath();
237    this.callService(isyUrl ,"/time" , true);
238  }
239
240
241  /**
242   * commandLine command executor method for the listAreas Command.
243   * @param args the array of commandLine args that got passed in
244   **/
245  protected void sayWelcomeHomeCMD(String [] args)
246  {
247    final String methodName = CLASSNAME + ": sayWelcomeHomeCMD(String [])";
248    System.out.println("ISY ELK Rest Services: "+ "sayWelcomeHomeCMD");
249
250    speakWord(words.welcome);
251    speakWord(words.home);
252    speakWord(words.blank);
253    speakWord(words.the);
254    speakWord(words.time);
255    speakWord(words.is);
256    speakPhrase(words.sayCurrentTime);
257
258  }
259
260
261    /**
262   * Template method for future commandLine command executor methods.
263   * @param args the array of commandLine args that got passed in
264   **/
265  protected void templateCMD(String [] args)
266  {
267    final String methodName = CLASSNAME + ": testCMD(String [])";
268    System.out.println("ISY ELK Rest Services: "+ "listAreas");
269
270  }
271
272
273  /** gets the help as a String.
274   * @return the helpMsg in String form
275   **/
276  protected static String getHelpMsgStr() {return getHelpMsg().toString();}
277
278
279  /** initializes and gets the helpMsg_
280  class var.
281   * @return the class var helpMsg_
282   **/
283  protected static StringBuilder getHelpMsg()
284  {
285    helpMsg_ = new StringBuilder(SYSTEM_LINE_SEPERATOR);
286    helpMsg_.append("---  WebARTS "+CLASSNAME+" Class  -----------------------------------------------------");
287    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
288    helpMsg_.append("--- + $Revision: 1091 $ $Date: 2016-05-29 16:26:54 -0700 (Sun, 29 May 2016) $ ---");
289    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
290    helpMsg_.append("-------------------------------------------------------------------------------");
291    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
292    helpMsg_.append("WebARTS ca.bc.webarts.tools.isy."+CLASSNAME+" Class");
293    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
294    helpMsg_.append("SYNTAX:");
295    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
296    helpMsg_.append("   java ");
297    helpMsg_.append(CLASSNAME);
298    helpMsg_.append(" command or {restCommand}");
299    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
300    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
301    helpMsg_.append("Available commands:");
302    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
303    helpMsg_.append("    test");
304    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
305    helpMsg_.append("    listAreas ");
306    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
307    helpMsg_.append("    sayWelcomeHome ");
308    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
309    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
310    helpMsg_.append("Available restCommands:");
311    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
312    helpMsg_.append("    see: http://wiki.universal-devices.com/index.php?title=ISY_Developers:API:REST_Interface");
313    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
314    helpMsg_.append("  Example: java ca.bc.webarts.android.ISYRestRequester /sys ");
315    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
316    helpMsg_.append("---------------------------------------------------------");
317    helpMsg_.append("----------------------");
318    helpMsg_.append(SYSTEM_LINE_SEPERATOR);
319
320    return helpMsg_;
321  }
322
323
324  public enum words
325  {
326    blank                  (" ", 0),
327    zero                   ("0", 21),
328    one                    ("1", 22),
329    two                    ("two", 23),
330    three                  ("three", 24),
331    four                   ("four", 25),
332    five                   ("five", 26),
333    six                    ("six", 27),
334    seven                  ("seven", 28),
335    eight                  ("eight", 29),
336    nine                   ("nine", 30),
337    ten                    ("ten", 31),
338    eleven                 ("eleven", 32),
339    twelve                 ("twelve", 33),
340    thirteen               ("thirteen", 34),
341    fourteen               ("fourteen", 35),
342    fifteen                ("fifteen", 36),
343    sixteen                ("sixteen", 37),
344    seventeen              ("seventeen", 38),
345    eighteen               ("eighteen", 39),
346    nineteen               ("nineteen", 40),
347    twenty                 ("twenty", 41),
348    thirty                 ("thirty", 42),
349    forty                  ("forty", 43),
350    fifty                  ("fifty", 44),
351    sixty                  ("sixty", 45),
352    seventy                ("seventy", 46),
353    eighty                 ("eighty", 47),
354    ninety                 ("ninety", 48),
355    hundred                ("hundred", 49),
356    thousand               ("thousand", 50),
357    silence200ms           ("silence200ms", 51),
358    silence500ms           ("silence500ms", 52),
359    tone800hz              ("tone800hz", 53),
360    a                      ("a", 54),
361    access                 ("access", 55),
362    acknowledged           ("acknowledged", 56),
363    acPower                ("ac power", 57),
364    activate               ("activate", 58),
365    activated              ("activated", 59),
366    active                 ("active", 60),
367    adjust                 ("adjust", 61),
368    air                    ("air", 62),
369    alarm                  ("alarm", 63),
370    alert                  ("alert", 64),
371    all                    ("all", 65),
372    am                     ("am", 66),
373    an                     ("an", 67),
374    and                    ("and", 68),
375    answer                 ("answer", 69),
376    any                    ("any", 70),
377    are                    ("are", 71),
378    area                   ("area", 72),
379    arm                    ("arm", 73),
380    armed                  ("armed", 74),
381    at                     ("at", 75),
382    attic                  ("attic", 76),
383    audio                  ("audio", 77),
384    auto                   ("auto", 78),
385    authorized             ("authorized", 79),
386    automatic              ("automatic", 80),
387    automation             ("automation", 81),
388    auxiliary              ("auxiliary", 82),
389    away                   ("away", 83),
390    b                      ("b", 84),
391    back                   ("back", 85),
392    barn                   ("barn", 86),
393    basement               ("basement", 87),
394    bathroom               ("bathroom", 88),
395    battery                ("battery", 89),
396    bedroom                ("bedroom", 90),
397    been                   ("been", 91),
398    bell                   ("bell", 92),
399    bottom                 ("bottom", 93),
400    break_                 ("break", 94),
401    breakfast              ("breakfast", 95),
402    bright                 ("bright", 96),
403    building               ("building", 97),
404    burglar                ("burglar", 98),
405    button                 ("button", 99),
406    by                     ("by", 100),
407    bypassed               ("bypassed", 101),
408    cabinet                ("cabinet", 102),
409    call                   ("call", 103),
410    camera                 ("camera", 104),
411    cancel                 ("cancel", 105),
412    carbonMonoxide         ("carbon monoxide", 106),
413    card                   ("card", 107),
414    center                 ("center", 108),
415    central                ("central", 109),
416    change                 ("change", 110),
417    check                  ("check", 111),
418    chime                  ("chime", 112),
419    circuit                ("circuit", 113),
420    clear                  ("clear", 114),
421    closed                 ("closed", 115),
422    closet                 ("closet", 116),
423    code                   ("code", 117),
424    cold                   ("cold", 118),
425    condition              ("condition", 119),
426    connect                ("connect", 120),
427    control                ("control", 121),
428    cool                   ("cool", 122),
429    cooling                ("cooling", 123),
430    corner                 ("corner", 124),
431    crawlspace             ("crawlspace", 125),
432    danger                 ("danger", 126),
433    day                    ("day", 127),
434    deck                   ("deck", 128),
435    decrease               ("decrease", 129),
436    defective              ("defective", 130),
437    degrees                ("degrees", 131),
438    delay                  ("delay", 132),
439    den                    ("den", 133),
440    denied                 ("denied", 134),
441    detected               ("detected", 135),
442    detector               ("detector", 136),
443    device                 ("device", 137),
444    dial                   ("dial", 138),
445    dialing                ("dialing", 139),
446    dim                    ("dim", 140),
447    diningRoom             ("dining room", 141),
448    disable                ("disable", 142),
449    disarm                 ("disarm", 143),
450    disarmed               ("disarmed", 144),
451    dock                   ("dock", 145),
452    door                   ("door", 146),
453    doors                  ("doors", 147),
454    down                   ("down", 148),
455    driveway               ("driveway", 149),
456    east                   ("east", 150),
457    emergency              ("emergency", 151),
458    enable                 ("enable", 152),
459    end                    ("end", 153),
460    energy                 ("energy", 154),
461    enrollment             ("enrollment", 155),
462    enter                  ("enter", 156),
463    entering               ("entering", 157),
464    entertainment          ("entertainment", 158),
465    enterThe               ("enter the", 159),
466    entry                  ("entry", 160),
467    environment            ("environment", 161),
468    equipment              ("equipment", 162),
469    error                  ("error", 163),
470    evacuate               ("evacuate", 164),
471    event                  ("event", 165),
472    exercise               ("exercise", 166),
473    expander               ("expander", 167),
474    exit                   ("exit", 168),
475    exterior               ("exterior", 169),
476    f                      ("f", 170),
477    fail                   ("fail", 171),
478    failure                ("failure", 172),
479    familyRoom             ("family room", 173),
480    fan                    ("fan", 174),
481    feed                   ("feed", 175),
482    fence                  ("fence", 176),
483    fire                   ("fire", 177),
484    first                  ("first", 178),
485    flood                  ("flood", 179),
486    floor                  ("floor", 180),
487    followed               ("followed", 181),
488    force                  ("force", 182),
489    fountain               ("fountain", 183),
490    foyer                  ("foyer", 184),
491    freeze                 ("freeze", 185),
492    front                  ("front", 186),
493    full                   ("full", 187),
494    furnace                ("furnace", 188),
495    fuse                   ("fuse", 189),
496    game                   ("game", 190),
497    garage                 ("garage", 191),
498    gas                    ("gas", 192),
499    gate                   ("gate", 193),
500    glass                  ("glass", 194),
501    go                     ("go", 195),
502    good                   ("good", 196),
503    goodbye                ("good-bye", 197),
504    great                  ("great", 198),
505    group                  ("group", 199),
506    guest                  ("guest", 200),
507    gun                    ("gun", 201),
508    hall                   ("hall", 202),
509    hallway                ("hallway", 203),
510    hangingUp              ("hanging up", 204),
511    hangUp                 ("hang up", 205),
512    has                    ("has", 206),
513    hasExpired             ("has expired", 207),
514    have                   ("have", 208),
515    hearMenuOptions        ("hear menu options", 209),
516    heat                   ("heat", 210),
517    help                   ("help", 211),
518    high                   ("high", 212),
519    hold                   ("hold", 213),
520    home                   ("home", 214),
521    hot                    ("hot", 215),
522    hotTub                 ("hot tub", 216),
523    house                  ("house", 217),
524    humidity               ("humidity", 218),
525    hvac                   ("hvac", 219),
526    if_                    ("if", 220),
527    immediately            ("immediately", 221),
528    in                     ("in", 222),
529    inches                 ("inches", 223),
530    increase               ("increase", 224),
531    inner                  ("inner", 225),
532    input                  ("input", 226),
533    inside                 ("inside", 227),
534    instant                ("instant", 228),
535    interior               ("interior", 229),
536    inThe                  ("in the", 230),
537    intruder               ("intruder", 231),
538    intrusion              ("intrusion", 232),
539    invalid                ("invalid", 233),
540    is                     ("is", 234),
541    isAboutToExpire        ("is about to expire", 235),
542    isActive               ("is active", 236),
543    isArmed                ("is armed", 237),
544    isCanceled             ("is canceled", 238),
545    isClosed               ("is closed", 239),
546    isDisarmed             ("is disarmed", 240),
547    isLow                  ("is low", 241),
548    isOff                  ("is off", 242),
549    isOk                   ("is ok", 243),
550    isOn                   ("is on", 244),
551    isOpen                 ("is open", 245),
552    jacuzzi                ("jacuzzi", 246),
553    jewelry                ("jewelry", 247),
554    keep                   ("keep", 248),
555    key                    ("key", 249),
556    keypad                 ("keypad", 250),
557    kitchen                ("kitchen", 251),
558    lamp                   ("lamp", 252),
559    laundry                ("laundry", 253),
560    lawn                   ("lawn", 254),
561    leak                   ("leak", 255),
562    leave                  ("leave", 256),
563    left                   ("left", 257),
564    less                   ("less", 258),
565    level                  ("level", 259),
566    library                ("library", 260),
567    light                  ("light", 261),
568    lights                 ("lights", 262),
569    line                   ("line", 263),
570    livingRoom             ("living room", 264),
571    loading                ("loading", 265),
572    lobby                  ("lobby", 266),
573    location               ("location" , 267),
574    lock                   ("lock" , 268),
575    low                    ("low" , 269),
576    lower                  ("lower" , 270),
577    m                      ("m" , 271),
578    machine                ("machine" , 272),
579    mail                   ("mail" , 273),
580    main                   ("main" , 274),
581    mains                  ("mains" , 275),
582    manual                 ("manual" , 276),
583    master                 ("master" , 277),
584    max                    ("max" , 278),
585    media                  ("media" , 279),
586    medical                ("medical" , 280),
587    medicine               ("medicine" , 281),
588    memory                 ("memory" , 282),
589    menu                   ("menu" , 283),
590    message                ("message" , 284),
591    middle                 ("middle" , 285),
592    minute                 ("minute" , 286),
593    missing                ("missing" , 287),
594    mode                   ("mode" , 288),
595    module                 ("module" , 289),
596    monitor                ("monitor" , 290),
597    more                   ("more" , 291),
598    motion                 ("motion" , 292),
599    motor                  ("motor" , 293),
600    next                   ("next" , 294),
601    night                  ("night" , 295),
602    no                     ("no" , 296),
603    normal                 ("normal" , 297),
604    north                  ("north" , 298),
605    not                    ("not" , 299),
606    notified               ("notified" , 300),
607    now                    ("now" , 301),
608    number                 ("number" , 302),
609    nursery                ("nursery" , 303),
610    of                     ("of" , 304),
611    off                    ("off" , 305),
612    office                 ("office" , 306),
613    oh                     ("oh" , 307),
614    ok                     ("ok" , 308),
615    on                     ("on" , 309),
616    online                 ("on-line" , 310),
617    only                   ("only" , 311),
618    open                   ("open" , 312),
619    operating              ("operating" , 313),
620    option                 ("option" , 314),
621    or                     ("or" , 315),
622    other                  ("other" , 316),
623    out                    ("out" , 317),
624    outlet                 ("outlet" , 318),
625    output                 ("output" , 319),
626    outside                ("outside" , 320),
627    over                   ("over" , 321),
628    overhead               ("overhead" , 322),
629    panel                  ("panel" , 323),
630    panic                  ("panic" , 324),
631    parking                ("parking" , 325),
632    partition              ("partition" , 326),
633    patio                  ("patio" , 327),
634    pause                  ("pause" , 328),
635    perimeter              ("perimeter" , 329),
636    personal               ("personal" , 330),
637    phone                  ("phone" , 331),
638    place                  ("place" , 332),
639    play                   ("play" , 333),
640    please                 ("please" , 334),
641    plus                   ("plus" , 335),
642    pm                     ("pm" , 336),
643    police                 ("police" , 337),
644    pool                   ("pool" , 338),
645    porch                  ("porch" , 339),
646    port                   ("port" , 340),
647    pound                  ("pound" , 341),
648    pounds                 ("pounds" , 342),
649    power                  ("power" , 343),
650    press                  ("press" , 344),
651    pressure               ("pressure" , 345),
652    problem                ("problem" , 346),
653    program                ("program" , 347),
654    protected_             ("protected" , 348),
655    pump                   ("pump" , 349),
656    radio                  ("radio" , 350),
657    raise                  ("raise" , 351),
658    ready                  ("ready" , 352),
659    rear                   ("rear" , 353),
660    receiver               ("receiver" , 354),
661    record                 ("record" , 355),
662    recreation             ("recreation" , 356),
663    relay                  ("relay" , 357),
664    remainCalm             ("remain calm" , 358),
665    remote                 ("remote" , 359),
666    repeat                 ("repeat" , 360),
667    report                 ("report" , 361),
668    reporting              ("reporting" , 362),
669    reset                  ("reset" , 363),
670    restored               ("restored" , 364),
671    return_                ("return" , 365),
672    right                  ("right" , 366),
673    roof                   ("roof" , 367),
674    room                   ("room" , 368),
675    running                ("running" , 369),
676    safe                   ("safe" , 370),
677    save                   ("save" , 371),
678    screen                 ("screen" , 372),
679    second                 ("second" , 373),
680    secure                 ("secure" , 374),
681    security               ("security" , 375),
682    select                 ("select" , 376),
683    sensor                 ("sensor" , 377),
684    serial                 ("serial" , 378),
685    service                ("service" , 379),
686    set                    ("set" , 380),
687    setback                ("setback" , 381),
688    setPoint               ("set point" , 382),
689    setting                ("setting" , 383),
690    shed                   ("shed" , 384),
691    shipping               ("shipping" , 385),
692    shock                  ("shock" , 386),
693    shop                   ("shop" , 387),
694    shorted                ("shorted" , 388),
695    shunted                ("shunted" , 389),
696    side                   ("side" , 390),
697    silence                ("silence" , 391),
698    siren                  ("siren" , 392),
699    sliding                ("sliding" , 393),
700    smoke                  ("smoke" , 394),
701    someone                ("someone" , 395),
702    south                  ("south" , 396),
703    spare                  ("spare" , 397),
704    speaker                ("speaker" , 398),
705    sprinkler              ("sprinkler" , 399),
706    stairs                 ("stairs" , 400),
707    stairway               ("stairway" , 401),
708    star                   ("star" , 402),
709    start                  ("start" , 403),
710    status                 ("status" , 404),
711    stay                   ("stay" , 405),
712    stock                  ("stock" , 406),
713    stop                   ("stop" , 407),
714    storage                ("storage" , 408),
715    storm                  ("storm" , 409),
716    studio                 ("studio" , 410),
717    study                  ("study" , 411),
718    sump                   ("sump" , 412),
719    sun                    ("sun" , 413),
720    switch_                ("switch" , 414),
721    system                 ("system" , 415),
722    tamper                 ("tamper" , 416),
723    tank                   ("tank" , 417),
724    task                   ("task" , 418),
725    telephone              ("telephone" , 419),
726    television             ("television" , 420),
727    temperature            ("temperature" , 421),
728    test                   ("test" , 422),
729    thankYou               ("thank you" , 423),
730    that                   ("that" , 424),
731    the                    ("the" , 425),
732    theater                ("theater" , 426),
733    thermostat             ("thermostat" , 427),
734    third                  ("third" , 428),
735    time                   ("time" , 429),
736    toggle                 ("toggle" , 430),
737    top                    ("top" , 431),
738    transformer            ("transformer" , 432),
739    transmitter            ("transmitter" , 433),
740    trespassing            ("trespassing" , 434),
741    trouble                ("trouble" , 435),
742    turn                   ("turn" , 436),
743    twice                  ("twice" , 437),
744    type                   ("type" , 438),
745    under                  ("under" , 439),
746    unit                   ("unit" , 440),
747    unlocked               ("unlocked" , 441),
748    unoccupied             ("unoccupied" , 442),
749    up                     ("up" , 443),
750    user                   ("user" , 444),
751    utility                ("utility" , 445),
752    vacation               ("vacation" , 446),
753    valve                  ("valve" , 447),
754    video                  ("video" , 448),
755    violated               ("violated" , 449),
756    visitor                ("visitor" , 450),
757    wakeUp                 ("wake up" , 451),
758    walk                   ("walk" , 452),
759    wall                   ("wall" , 453),
760    warehouse              ("warehouse" , 454),
761    warning                ("warning" , 455),
762    water                  ("water" , 456),
763    way                    ("way" , 457),
764    welcome                ("welcome" , 458),
765    west                   ("west" , 459),
766    what                   ("what" , 460),
767    when                   ("when" , 461),
768    where                  ("where" , 462),
769    will                   ("will" , 463),
770    window                 ("window" , 464),
771    windows                ("windows" , 465),
772    with                   ("with" , 466),
773    work                   ("work" , 467),
774    yard                   ("yard" , 468),
775    year                   ("year" , 469),
776    you                    ("you" , 470),
777    zone                   ("zone" , 471),
778    zones                  ("zones" , 472),
779
780    /*  Special Phrases */
781    sayCondition           ("sayCondition" , 2),
782    sayCurrentTime         ("sayCurrentTime" , 3),
783    intruderMessage        ("intruder message" , 473),
784    invertedCondition      ("inverted condition" , 4),
785    sayClosedOpen          ("say closed/open" , 509),
786    sayDownUp              ("say down/up" , 507),
787    sayLockedUnlocked      ("say locked/unlocked" , 496),
788    sayNotSecureSecure     ("say not secure/secure" , 505),
789    sayOffOn               ("say off/on" , 511),
790    sayOnOff               ("say on/off" , 512),
791    sayOpenClosed          ("say open/closed" , 510),
792    saySecureNotSecure     ("say secure/not secure" , 506),
793    sayUnlockedLocked      ("say unlocked/locked" , 495),
794    sayUpDown              ("say up/down" , 508)
795    ;
796
797    private final String word;
798    private final int wordId;
799    words(String word, int wordId) {   this.word = word;  this.wordId = wordId; }
800    private String word() { return word; }
801    private int wordId() { return wordId; }
802  }
803}