Пример #1
0
    /**
     * Populates all know audio sources which are used by known zones
     *
     * @throws IOException
     * @throws OmniNotConnectedException
     * @throws OmniInvalidResponseException
     * @throws OmniUnknownMessageTypeException
     */
    private void readAllAudioSources()
        throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
            OmniUnknownMessageTypeException {
      int objnum = 0;
      Message m;
      while ((m =
                  c.reqObjectProperties(
                      Message.OBJ_TYPE_AUDIO_SOURCE,
                      objnum,
                      1,
                      ObjectProperties.FILTER_1_NAMED,
                      ObjectProperties.FILTER_2_NONE,
                      ObjectProperties.FILTER_3_NONE))
              .getMessageType()
          == Message.MESG_TYPE_OBJ_PROP) {
        // logger.info(m.toString());
        AudioSourceProperties o = ((AudioSourceProperties) m);
        objnum = ((ObjectProperties) m).getNumber();

        Integer number = new Integer(o.getNumber());
        AudioSource as = audioSourceMap.get(number);
        if (as == null) {
          as = new AudioSource(o);
          audioSourceMap.put(number, as);
        }
        audioSourceMap.put(new Integer(o.getNumber()), as);
      }
    }
Пример #2
0
 /**
  * Iterate through the system units (lights)
  *
  * @param number of the unti
  * @return UnitProperties of unit, null if not found
  * @throws IOException
  * @throws OmniNotConnectedException
  * @throws OmniInvalidResponseException
  * @throws OmniUnknownMessageTypeException
  */
 private UnitProperties readUnitProperties(int number)
     throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
         OmniUnknownMessageTypeException {
   Message m =
       c.reqObjectProperties(
           Message.OBJ_TYPE_UNIT,
           number,
           0,
           ObjectProperties.FILTER_1_NAMED,
           ObjectProperties.FILTER_2_AREA_ALL,
           ObjectProperties.FILTER_3_ANY_LOAD);
   if (m.getMessageType() == Message.MESG_TYPE_OBJ_PROP) {
     return ((UnitProperties) m);
   }
   return null;
 }
Пример #3
0
    /**
     * Read the properties of a button
     *
     * @param number of button
     * @return ButtonProperties of button, or null if not found
     * @throws IOException
     * @throws OmniNotConnectedException
     * @throws OmniInvalidResponseException
     * @throws OmniUnknownMessageTypeException
     */
    private ButtonProperties readButtonProperties(int number)
        throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
            OmniUnknownMessageTypeException {

      Message m =
          c.reqObjectProperties(
              Message.OBJ_TYPE_BUTTON,
              number,
              0,
              ObjectProperties.FILTER_1_NAMED,
              ObjectProperties.FILTER_2_NONE,
              ObjectProperties.FILTER_3_NONE);
      if (m.getMessageType() == Message.MESG_TYPE_OBJ_PROP) {
        return ((ButtonProperties) m);
      }
      return null;
    }
Пример #4
0
  /**
   * Generates button items
   *
   * @throws IOException
   * @throws OmniNotConnectedException
   * @throws OmniInvalidResponseException
   * @throws OmniUnknownMessageTypeException
   */
  private void generateButtons()
      throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
          OmniUnknownMessageTypeException {

    String groupString = "Group\t%s\t\"%s\"\t(%s)\n";
    String itemString = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"%s:%d\",autoupdate=\"false\"}\n";
    String groupName = "Buttons";
    groups.append(String.format(groupString, groupName, "Buttons", "All"));

    int objnum = 0;
    Message m;

    while ((m =
                c.reqObjectProperties(
                    Message.OBJ_TYPE_BUTTON,
                    objnum,
                    1,
                    ObjectProperties.FILTER_1_NAMED,
                    ObjectProperties.FILTER_2_AREA_ALL,
                    ObjectProperties.FILTER_3_NONE))
            .getMessageType()
        == Message.MESG_TYPE_OBJ_PROP) {
      ButtonProperties o = ((ButtonProperties) m);
      objnum = o.getNumber();

      // String group = addUniqueGroup(groupName + "_" + cleanString(o.getName()));

      // groups.append(String.format(groupString,group,o.getName(),groupName));
      String name = groupName + "_" + cleanString(o.getName());

      buttons.add(new SiteItem(name, o.getName(), o.getName()));

      items.append(
          String.format(itemString, "String", name, o.getName(), groupName, "button", objnum));
    }
  }
Пример #5
0
  /**
   * Generates are items
   *
   * @throws IOException
   * @throws OmniNotConnectedException
   * @throws OmniInvalidResponseException
   * @throws OmniUnknownMessageTypeException
   */
  private void generateAreas()
      throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
          OmniUnknownMessageTypeException {

    String groupString = "Group\t%s\t\"%s\"\t(%s)\n";
    String itemString = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"%s:%d\"}\n";
    String groupName = "Areas";
    groups.append(String.format(groupString, groupName, "Areas", "All"));

    int objnum = 0;
    Message m;

    while ((m =
                c.reqObjectProperties(
                    Message.OBJ_TYPE_AREA,
                    objnum,
                    1,
                    ObjectProperties.FILTER_1_NAMED,
                    ObjectProperties.FILTER_2_NONE,
                    ObjectProperties.FILTER_3_NONE))
            .getMessageType()
        == Message.MESG_TYPE_OBJ_PROP) {
      AreaProperties o = ((AreaProperties) m);
      objnum = o.getNumber();

      String group = addUniqueGroup(groupName + "_" + cleanString(o.getName()));

      groups.append(String.format(groupString, group, o.getName(), groupName));
      // String name = group + "_" + cleanString(o.getName());

      areas.add(new SiteItem(group, o.getName(), o.getName()));

      items.append(
          String.format(
              itemString,
              "Number",
              group + "_ExitDelay",
              "Exit Delay: [%d]",
              group,
              "area_status_exit_delay",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_EntryDelay",
              "Entry Delay: [%d]",
              group,
              "area_status_entry_delay",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_ExitTimer",
              "Exit Timer: [%d]",
              group,
              "area_status_exit_timer",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_EntryTimer",
              "Entry Timer: [%d]",
              group,
              "area_status_entry_timer",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Mode",
              "Mode: [%s]",
              group,
              "area_status_mode",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Alarm",
              "Alarm: [%s]",
              group,
              "area_status_alarm",
              objnum));
    }
  }
Пример #6
0
  /**
   * Generates zone items
   *
   * @throws IOException
   * @throws OmniNotConnectedException
   * @throws OmniInvalidResponseException
   * @throws OmniUnknownMessageTypeException
   */
  private void generateZones()
      throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
          OmniUnknownMessageTypeException {

    String groupString = "Group\t%s\t\"%s\"\t(%s)\n";
    String itemString = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"%s:%d\"}\n";
    String groupName = "Zones";
    groups.append(String.format(groupString, groupName, "Zones", "All"));

    int objnum = 0;
    Message m;

    while ((m =
                c.reqObjectProperties(
                    Message.OBJ_TYPE_ZONE,
                    objnum,
                    1,
                    ObjectProperties.FILTER_1_NAMED,
                    ObjectProperties.FILTER_2_AREA_ALL,
                    ObjectProperties.FILTER_3_ANY_LOAD))
            .getMessageType()
        == Message.MESG_TYPE_OBJ_PROP) {
      ZoneProperties o = ((ZoneProperties) m);
      objnum = o.getNumber();

      String group = addUniqueGroup(groupName + "_" + cleanString(o.getName()));

      groups.append(String.format(groupString, group, o.getName(), groupName));
      // String name = group + "_" + cleanString(o.getName());

      zones.add(new SiteItem(group, o.getName(), o.getName()));

      items.append(
          String.format(
              itemString,
              "Contact",
              group + "_Current",
              "Current: [%s]",
              group,
              "zone_status_current",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Latched",
              "Latched [%s]",
              group,
              "zone_status_latched",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Arming",
              "Arming [%s]",
              group,
              "zone_status_arming",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_All",
              "Status  [%s]",
              group,
              "zone_status_all",
              objnum));
    }
  }
Пример #7
0
  /**
   * Generates audio source items
   *
   * @throws IOException
   * @throws OmniNotConnectedException
   * @throws OmniInvalidResponseException
   * @throws OmniUnknownMessageTypeException
   */
  private void generateAudioSource()
      throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
          OmniUnknownMessageTypeException {

    String groupString = "Group\t%s\t\"%s\"\t(%s)\n";
    String itemString = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"%s:%d\"}\n";
    String groupName = "AudioSources";
    groups.append(String.format(groupString, groupName, "Audio Sources", "All"));
    int objnum = 0;
    Message m;

    while ((m =
                c.reqObjectProperties(
                    Message.OBJ_TYPE_AUDIO_SOURCE,
                    objnum,
                    1,
                    ObjectProperties.FILTER_1_NAMED,
                    ObjectProperties.FILTER_2_NONE,
                    ObjectProperties.FILTER_3_NONE))
            .getMessageType()
        == Message.MESG_TYPE_OBJ_PROP) {
      AudioSourceProperties o = ((AudioSourceProperties) m);
      objnum = o.getNumber();

      String group = addUniqueGroup(groupName + "_" + cleanString(o.getName()));

      groups.append(String.format(groupString, group, o.getName(), "OmniAudioSources"));
      // String name = group + "_" + cleanString(o.getName());

      audioSources.add(new SiteItem(group, o.getName(), o.getName()));

      items.append(
          String.format(
              itemString,
              "String",
              group + "_Text",
              "Now Playeing: [%s]",
              group,
              "audiosource_text",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Field1",
              "Field 1 [%s]",
              group,
              "audiosource_field1",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Field2",
              "Field 2 [%s]",
              group,
              "audiosource_field2",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Field3",
              "Field 3 [%s]",
              group,
              "audiosource_field3",
              objnum));
    }
  }
Пример #8
0
  /**
   * Generates audio zone items
   *
   * @throws IOException
   * @throws OmniNotConnectedException
   * @throws OmniInvalidResponseException
   * @throws OmniUnknownMessageTypeException
   */
  private void generateAudioZones()
      throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
          OmniUnknownMessageTypeException {

    String groupString = "Group\t%s\t\"%s\"\t(%s)\n";
    String itemString = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"%s:%d\"}\n";
    String itemStringKey = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"%s:%d\",autoupdate=\"false\"}\n";
    String groupName = "AudioZones";
    groups.append(String.format(groupString, groupName, "Audio Zones", "All"));
    int objnum = 0;
    Message m;

    while ((m =
                c.reqObjectProperties(
                    Message.OBJ_TYPE_AUDIO_ZONE,
                    objnum,
                    1,
                    ObjectProperties.FILTER_1_NAMED,
                    ObjectProperties.FILTER_2_NONE,
                    ObjectProperties.FILTER_3_NONE))
            .getMessageType()
        == Message.MESG_TYPE_OBJ_PROP) {
      AudioZoneProperties o = ((AudioZoneProperties) m);
      objnum = o.getNumber();

      String group = addUniqueGroup(groupName + "_" + cleanString(o.getName()));

      groups.append(String.format(groupString, group, o.getName(), groupName));
      // String name = group + "_" + cleanString(o.getName());

      audioZones.add(new SiteItem(group, o.getName(), o.getName()));

      items.append(
          String.format(
              itemString, "Switch", group + "_Power", "Power", group, "audiozone_power", objnum));
      items.append(
          String.format(
              itemString, "Switch", group + "_Mute", "Mute", group, "audiozone_mute", objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_Source",
              "Source: [%d]",
              group,
              "audiozone_source",
              objnum));
      items.append(
          String.format(
              itemString,
              "Dimmer",
              group + "_Volume",
              "Voulme: [%d %%]",
              group,
              "audiozone_volume",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Text",
              "Now Playing: [%s]",
              group,
              "audiozone_text",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Field1",
              "Field 1 [%s]",
              group,
              "audiozone_field1",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Field2",
              "Field 2 [%s]",
              group,
              "audiozone_field2",
              objnum));
      items.append(
          String.format(
              itemString,
              "String",
              group + "_Field3",
              "Field 3 [%s]",
              group,
              "audiozone_field3",
              objnum));
      items.append(
          String.format(
              itemStringKey, "Number", group + "_Key", "Key [%d]", group, "audiozone_key", objnum));
    }
  }
Пример #9
0
  /**
   * Generates thermostat items
   *
   * @throws IOException
   * @throws OmniNotConnectedException
   * @throws OmniInvalidResponseException
   * @throws OmniUnknownMessageTypeException
   */
  private void generateThermos()
      throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
          OmniUnknownMessageTypeException {

    String groupString = "Group\t%s\t\"%s\"\t(%s)\n";
    String itemString = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"%s:%d\"}\n";
    String groupName = "Thermostats";
    groups.append(String.format(groupString, groupName, "Thermostats", "All"));
    int objnum = 0;
    Message m;

    while ((m =
                c.reqObjectProperties(
                    Message.OBJ_TYPE_THERMO,
                    objnum,
                    1,
                    ObjectProperties.FILTER_1_NAMED,
                    ObjectProperties.FILTER_2_AREA_ALL,
                    ObjectProperties.FILTER_3_ANY_LOAD))
            .getMessageType()
        == Message.MESG_TYPE_OBJ_PROP) {
      ThermostatProperties o = ((ThermostatProperties) m);
      objnum = o.getNumber();
      String objName = cleanString(o.getName());
      String group = addUniqueGroup(groupName + "_" + objName);

      groups.append(String.format(groupString, group, o.getName(), "OmniThermostat"));

      thermos.add(new SiteItem(group, o.getName(), o.getName()));

      items.append(
          String.format(
              itemString,
              "Number",
              group + "_Temp",
              "Temperature [%d °F]",
              group,
              "thermo_temp",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_CoolPoint",
              "Cool Point [%d°F]",
              group,
              "thermo_cool_point",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_HeatPoint",
              "Heat Point [%d°F]",
              group,
              "thermo_heat_point",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_System",
              "System Mode [%d]",
              group,
              "thermo_system_mode",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_Fan",
              "System Fan [%d]",
              group,
              "thermo_fan_mode",
              objnum));
      items.append(
          String.format(
              itemString,
              "Number",
              group + "_Hold",
              "System Hold [%d]",
              group,
              "thermo_hold_mode",
              objnum));
    }
  }
Пример #10
0
  /**
   * This is by far the most complex method as units have the ability to be sub-grouped into rooms.
   * If units are in a room then they will be added to their own group which is a member of the
   * Lights group.
   *
   * @throws IOException
   * @throws OmniNotConnectedException
   * @throws OmniInvalidResponseException
   * @throws OmniUnknownMessageTypeException
   */
  private void generateUnits()
      throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
          OmniUnknownMessageTypeException {

    // Group	Lights_GreatRoom	"Great Room"	(Lights)
    String groupString = "Group\t%s\t\"%s\"\t(%s)\n";

    // Dimmer	Lights_GreatRoom_MainLights_Switch	"Main Lights [%d%%]"	(Lights_GreatRoom)
    //	{omnilink="unit:10"}
    String itemString = "%s\t%s\t\"%s\"\t(%s)\t{omnilink=\"unit:%d\"}\n";

    String groupName = "Lights";

    // Group	Lights	"Lights"	(All)
    groups.append(String.format(groupString, groupName, "Lights", "All"));

    int objnum = 0;
    Message m;
    int currentRoom = 0;
    String currentRoomName = null;

    while ((m =
                c.reqObjectProperties(
                    Message.OBJ_TYPE_UNIT,
                    objnum,
                    1,
                    ObjectProperties.FILTER_1_NAMED,
                    ObjectProperties.FILTER_2_AREA_ALL,
                    ObjectProperties.FILTER_3_ANY_LOAD))
            .getMessageType()
        == Message.MESG_TYPE_OBJ_PROP) {
      UnitProperties o = ((UnitProperties) m);
      objnum = o.getNumber();

      boolean isInRoom = false;
      boolean isRoomController = false;
      if (o.getUnitType() == UnitProperties.UNIT_TYPE_HLC_ROOM
          || o.getObjectType() == UnitProperties.UNIT_TYPE_VIZIARF_ROOM) {
        currentRoom = objnum;

        // Lights_LivingRoom
        currentRoomName = cleanString(groupName + "_" + o.getName());

        // Make Sure we don't already have a group called this
        currentRoomName = addUniqueGroup(currentRoomName);

        groups.append(String.format(groupString, currentRoomName, o.getName(), groupName));
        rooms.put(currentRoomName, new LinkedList<SiteItem>());
        isInRoom = true;
        isRoomController = true;
      } else if (objnum < currentRoom + 8) {
        isInRoom = true;
      }

      // clean the name to remove things like spaces
      String objName = cleanString(o.getName());

      String group = isInRoom ? currentRoomName : groupName;

      // name will be the room name for the first device and roomName_deviceName for sub devices
      String name = isRoomController ? objName : group + "_" + objName;

      // the label does not have to be cleaned, so set it from the object
      String label = o.getName() + " [%d%%]";

      SiteItem light = new SiteItem(name, o.getName(), label);

      items.append(String.format(itemString, "Dimmer", name + "_Switch", label, group, objnum));

      if (isRoomController)
        items.append(
            String.format(
                itemString, "String", name + "_String", o.getName() + " [%s]", group, objnum));

      if (isInRoom) rooms.get(currentRoomName).add(light);
      else lights.add(light);
    }
  }