Пример #1
0
  /** {@inheritDoc} */
  @Override
  public void handleCommand(ChannelUID channelUID, Command command) {
    MaxCubeBridgeHandler maxCubeBridge = getMaxCubeBridgeHandler();
    if (maxCubeBridge == null) {
      logger.warn(
          "MAX! Cube LAN gateway bridge handler not found. Cannot handle command without bridge.");
      return;
    }
    if (command instanceof RefreshType) {
      forceRefresh = true;
      maxCubeBridge.handleCommand(channelUID, command);
      return;
    }
    if (maxDeviceSerial == null) {
      logger.warn("Serial number missing. Can't send command to device '{}'", getThing());
      return;
    }

    if (channelUID.getId().equals(CHANNEL_SETTEMP) || channelUID.getId().equals(CHANNEL_MODE)) {
      if (refreshingActuals) {
        refreshActualsRestore();
      }
      SendCommand sendCommand = new SendCommand(maxDeviceSerial, channelUID, command);
      maxCubeBridge.queueCommand(sendCommand);
    } else {
      logger.warn("Setting of channel {} not possible. Read-only", channelUID);
    }
  }
Пример #2
0
  @Override
  public void handleCommand(ChannelUID channelUID, Command command) {

    super.handleCommand(channelUID, command);

    String channelID = channelUID.getId();
    String uid = (String) getThing().getConfiguration().getProperties().get(APPLIANCE_ID);

    FridgeChannelSelector selector =
        (FridgeChannelSelector) getValueSelectorFromChannelID(channelID);
    JsonElement result = null;

    try {
      if (selector != null) {
        switch (selector) {
          case SUPERCOOL:
            {
              if (command.equals(OnOffType.ON)) {
                result = bridgeHandler.invokeOperation(uid, modelID, "startSuperCooling");
              } else if (command.equals(OnOffType.OFF)) {
                result = bridgeHandler.invokeOperation(uid, modelID, "stopSuperCooling");
              }
              break;
            }
          case START:
            {
              if (command.equals(OnOffType.ON)) {
                result = bridgeHandler.invokeOperation(uid, modelID, "start");
              }
              break;
            }
          default:
            {
              if (!(command instanceof RefreshType)) {
                logger.debug(
                    "{} is a read-only channel that does not accept commands",
                    selector.getChannelID());
              }
            }
        }
      }
      // process result
      if (result != null) {
        logger.debug("Result of operation is {}", result.getAsString());
      }
    } catch (IllegalArgumentException e) {
      logger.warn(
          "An error occurred while trying to set the read-only variable associated with channel '{}' to '{}'",
          channelID,
          command.toString());
    }
  }
  /** {@inheritDoc} */
  @Override
  public void updateChannel(ChannelUID channelUID) {
    logger.debug("updateChannel(): Keypad Channel UID: {}", channelUID);

    int state;

    if (channelUID != null) {
      switch (channelUID.getId()) {
        case KEYPAD_READY_LED:
          state = properties.getLEDState(LEDStateType.READY_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_ARMED_LED:
          state = properties.getLEDState(LEDStateType.ARMED_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_MEMORY_LED:
          state = properties.getLEDState(LEDStateType.MEMORY_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_BYPASS_LED:
          state = properties.getLEDState(LEDStateType.BYPASS_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_TROUBLE_LED:
          state = properties.getLEDState(LEDStateType.TROUBLE_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_PROGRAM_LED:
          state = properties.getLEDState(LEDStateType.PROGRAM_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_FIRE_LED:
          state = properties.getLEDState(LEDStateType.FIRE_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_BACKLIGHT_LED:
          state = properties.getLEDState(LEDStateType.BACKLIGHT_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        case KEYPAD_AC_LED:
          state = properties.getLEDState(LEDStateType.AC_LED_STATE);
          updateState(channelUID, new DecimalType(state));
          break;
        default:
          logger.debug("updateChannel(): Keypad Channel not updated - {}.", channelUID);
          break;
      }
    }
  }
  /** {@inheritDoc} */
  @Override
  public void updateProperties(ChannelUID channelUID, int state, String description) {
    logger.debug("updateProperties(): Keypad Channel UID: {}", channelUID);

    if (channelUID != null) {
      switch (channelUID.getId()) {
        case KEYPAD_READY_LED:
          properties.setLEDState(LEDStateType.READY_LED_STATE, state);
          break;
        case KEYPAD_ARMED_LED:
          properties.setLEDState(LEDStateType.ARMED_LED_STATE, state);
          break;
        case KEYPAD_MEMORY_LED:
          properties.setLEDState(LEDStateType.MEMORY_LED_STATE, state);
          break;
        case KEYPAD_BYPASS_LED:
          properties.setLEDState(LEDStateType.BYPASS_LED_STATE, state);
          break;
        case KEYPAD_TROUBLE_LED:
          properties.setLEDState(LEDStateType.TROUBLE_LED_STATE, state);
          break;
        case KEYPAD_PROGRAM_LED:
          properties.setLEDState(LEDStateType.PROGRAM_LED_STATE, state);
          break;
        case KEYPAD_FIRE_LED:
          properties.setLEDState(LEDStateType.FIRE_LED_STATE, state);
          break;
        case KEYPAD_BACKLIGHT_LED:
          properties.setLEDState(LEDStateType.BACKLIGHT_LED_STATE, state);
          break;
        case KEYPAD_AC_LED:
          properties.setLEDState(LEDStateType.AC_LED_STATE, state);
          break;
        default:
          logger.debug("updateProperties(): Keypad property not updated.");
          break;
      }
    }
  }
 @Override
 public void handleCommand(ChannelUID channelUID, Command command) {
   if (squeezeBoxServerHandler == null) {
     logger.warn("Player has no server configured, ignoring command");
     return;
   }
   String mac = getConfigAs(SqueezeBoxPlayerConfig.class).mac;
   switch (channelUID.getIdWithoutGroup()) {
     case CHANNEL_POWER:
       if (command.equals(OnOffType.ON)) {
         squeezeBoxServerHandler.powerOn(mac);
       } else {
         squeezeBoxServerHandler.powerOff(mac);
       }
       break;
     case CHANNEL_MUTE:
       if (command.equals(OnOffType.ON)) {
         mute();
       } else {
         squeezeBoxServerHandler.unMute(mac, unmuteVolume);
       }
       break;
     case CHANNEL_STOP:
       if (command.equals(OnOffType.ON)) {
         squeezeBoxServerHandler.stop(mac);
       } else if (command.equals(OnOffType.OFF)) {
         squeezeBoxServerHandler.play(mac);
       }
       break;
     case CHANNEL_PLAY_PAUSE:
       if (command.equals(OnOffType.ON)) {
         squeezeBoxServerHandler.play(mac);
       } else if (command.equals(OnOffType.OFF)) {
         squeezeBoxServerHandler.pause(mac);
       }
       break;
     case CHANNEL_PREV:
       if (command.equals(OnOffType.ON)) {
         squeezeBoxServerHandler.prev(mac);
       }
       break;
     case CHANNEL_NEXT:
       if (command.equals(OnOffType.ON)) {
         squeezeBoxServerHandler.next(mac);
       }
       break;
     case CHANNEL_VOLUME:
       if (command instanceof PercentType) {
         squeezeBoxServerHandler.setVolume(mac, ((PercentType) command).intValue());
       } else if (command.equals(IncreaseDecreaseType.INCREASE)) {
         squeezeBoxServerHandler.volumeUp(mac, currentVolume());
       } else if (command.equals(IncreaseDecreaseType.DECREASE)) {
         squeezeBoxServerHandler.volumeDown(mac, currentVolume());
       } else if (command.equals(OnOffType.OFF)) {
         mute();
       } else if (command.equals(OnOffType.ON)) {
         squeezeBoxServerHandler.unMute(mac, unmuteVolume);
       }
       break;
     case CHANNEL_CONTROL:
       if (command instanceof PlayPauseType) {
         if (command.equals(PlayPauseType.PLAY)) {
           squeezeBoxServerHandler.play(mac);
         } else if (command.equals(PlayPauseType.PAUSE)) {
           squeezeBoxServerHandler.pause(mac);
         }
       }
       if (command instanceof NextPreviousType) {
         if (command.equals(NextPreviousType.NEXT)) {
           squeezeBoxServerHandler.next(mac);
         } else if (command.equals(NextPreviousType.PREVIOUS)) {
           squeezeBoxServerHandler.prev(mac);
         }
       }
       if (command instanceof RewindFastforwardType) {
         if (command.equals(RewindFastforwardType.REWIND)) {
           squeezeBoxServerHandler.setPlayingTime(mac, currentTime() - 5);
         } else if (command.equals(RewindFastforwardType.FASTFORWARD)) {
           squeezeBoxServerHandler.setPlayingTime(mac, currentTime() + 5);
         }
       }
       break;
     case CHANNEL_STREAM:
       squeezeBoxServerHandler.playUrl(mac, command.toString());
       break;
     case CHANNEL_SYNC:
       if (StringUtils.isBlank(command.toString())) {
         squeezeBoxServerHandler.unSyncPlayer(mac);
       } else {
         squeezeBoxServerHandler.syncPlayer(mac, command.toString());
       }
     case CHANNEL_UNSYNC:
       if (command.equals(OnOffType.ON)) {
         squeezeBoxServerHandler.unSyncPlayer(mac);
       }
       break;
     case CHANNEL_PLAYLIST_INDEX:
       squeezeBoxServerHandler.playPlaylistItem(mac, ((DecimalType) command).intValue());
       break;
     case CHANNEL_CURRENT_PLAYING_TIME:
       squeezeBoxServerHandler.setPlayingTime(mac, ((DecimalType) command).intValue());
       break;
     case CHANNEL_CURRENT_PLAYLIST_SHUFFLE:
       squeezeBoxServerHandler.setShuffleMode(mac, ((DecimalType) command).intValue());
       break;
     case CHANNEL_CURRENT_PLAYLIST_REPEAT:
       squeezeBoxServerHandler.setRepeatMode(mac, ((DecimalType) command).intValue());
       break;
     default:
       break;
   }
 }
  /** {@inheritDoc} */
  @Override
  public void updateChannel(ChannelUID channelUID) {
    logger.debug("updateChannel(): Panel Channel UID: {}", channelUID);

    int state;
    String str = "";
    boolean trigger;
    boolean trouble;
    boolean boolState;
    OnOffType onOffType;

    if (channelUID != null) {
      switch (channelUID.getId()) {
        case PANEL_MESSAGE:
          str = properties.getSystemMessage();
          updateState(channelUID, new StringType(str));
          break;
        case PANEL_SYSTEM_ERROR:
          str =
              String.format("%03d", properties.getSystemErrorCode())
                  + ": "
                  + properties.getSystemErrorDescription();
          updateState(channelUID, new StringType(str));
          break;
        case PANEL_TIME:
          str = properties.getSystemTime();
          updateState(channelUID, new DateTimeType(str));
          break;
        case PANEL_TIME_STAMP:
          boolState = properties.getSystemTimeStamp();
          onOffType = boolState ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_TIME_BROADCAST:
          boolState = properties.getSystemTimeBroadcast();
          onOffType = boolState ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_COMMAND:
          state = properties.getSystemCommand();
          str = String.valueOf(state);
          updateState(channelUID, new StringType(str));
          break;
        case PANEL_TROUBLE_MESSAGE:
          str = properties.getTroubleMessage();
          updateState(channelUID, new StringType(str));
          break;
        case PANEL_TROUBLE_LED:
          boolState = properties.getTroubleLED();
          onOffType = boolState ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_SERVICE_REQUIRED:
          trouble = properties.getTrouble(TroubleType.SERVICE_REQUIRED);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_AC_TROUBLE:
          trouble = properties.getTrouble(TroubleType.AC_TROUBLE);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_TELEPHONE_TROUBLE:
          trouble = properties.getTrouble(TroubleType.TELEPHONE_LINE_TROUBLE);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_FTC_TROUBLE:
          trouble = properties.getTrouble(TroubleType.FAILURE_TO_COMMUNICATE);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_ZONE_FAULT:
          trouble = properties.getTrouble(TroubleType.ZONE_FAULT);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_ZONE_TAMPER:
          trouble = properties.getTrouble(TroubleType.ZONE_TAMPER);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_ZONE_LOW_BATTERY:
          trouble = properties.getTrouble(TroubleType.ZONE_LOW_BATTERY);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_TIME_LOSS:
          trouble = properties.getTrouble(TroubleType.LOSS_OF_TIME);
          onOffType = trouble ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_FIRE_KEY_ALARM:
          trigger = properties.getTrigger(TriggerType.FIRE_KEY_ALARM);
          onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_PANIC_KEY_ALARM:
          trigger = properties.getTrigger(TriggerType.PANIC_KEY_ALARM);
          onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_AUX_KEY_ALARM:
          trigger = properties.getTrigger(TriggerType.AUX_KEY_ALARM);
          onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        case PANEL_AUX_INPUT_ALARM:
          trigger = properties.getTrigger(TriggerType.AUX_KEY_ALARM);
          onOffType = trigger ? OnOffType.ON : OnOffType.OFF;
          updateState(channelUID, onOffType);
          break;
        default:
          logger.debug("updateChannel(): Panel Channel not updated - {}.", channelUID);
          break;
      }
    }
  }
  /** {@inheritDoc} */
  @Override
  public void handleCommand(ChannelUID channelUID, Command command) {
    if (dscAlarmBridgeHandler == null) {
      logger.warn("DSC Alarm bridge handler not available. Cannot handle command without bridge.");
      return;
    }

    int cmd;

    boolean connected = dscAlarmBridgeHandler.isConnected();

    if (connected) {
      switch (channelUID.getId()) {
        case PANEL_COMMAND:
          cmd = Integer.parseInt(command.toString());
          switch (cmd) {
            case 0:
              dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.Poll);
              break;
            case 1:
              dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.StatusReport);
              break;
            case 2:
              dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.LabelsRequest);
              break;
            case 8:
              dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.DumpZoneTimers);
              break;
            case 10:
              dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.SetTimeDate);
              break;
            case 200:
              dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.CodeSend, getUserCode());
              break;
            default:
              break;
          }

          updateState(channelUID, new StringType(String.valueOf(-1)));

          break;
        case PANEL_TIME_STAMP:
          if (command instanceof OnOffType) {
            cmd = command == OnOffType.ON ? 1 : 0;
            dscAlarmBridgeHandler.sendCommand(DSCAlarmCode.TimeStampControl, String.valueOf(cmd));
            updateProperties(channelUID, cmd, "");
            updateState(channelUID, (OnOffType) command);
          }
          break;
        case PANEL_TIME_BROADCAST:
          if (command instanceof OnOffType) {
            cmd = command == OnOffType.ON ? 1 : 0;
            dscAlarmBridgeHandler.sendCommand(
                DSCAlarmCode.TimeDateBroadcastControl, String.valueOf(cmd));
            updateProperties(channelUID, cmd, "");
            updateState(channelUID, (OnOffType) command);
          }
          break;
        default:
          break;
      }
    }
  }
  /** {@inheritDoc} */
  @Override
  public void updateProperties(ChannelUID channelUID, int state, String description) {
    logger.debug("updateProperties(): Panel Channel UID: {}", channelUID);

    boolean trouble = state != 0 ? true : false;
    boolean trigger = state != 0 ? true : false;
    boolean boolState = state != 0 ? true : false;

    if (channelUID != null) {
      switch (channelUID.getId()) {
        case PANEL_MESSAGE:
          properties.setSystemMessage(description);
          break;
        case PANEL_TIME:
          properties.setSystemTime(description);
          break;
        case PANEL_TIME_STAMP:
          properties.setSystemTimeStamp(state == 1 ? true : false);
          break;
        case PANEL_TIME_BROADCAST:
          properties.setSystemTimeBroadcast(state == 1 ? true : false);
          break;
        case PANEL_COMMAND:
          properties.setSystemCommand(state);
          break;
        case PANEL_TROUBLE_MESSAGE:
          properties.setTroubleMessage(description);
          break;
        case PANEL_TROUBLE_LED:
          properties.setTroubleLED(boolState);
          break;
        case PANEL_SERVICE_REQUIRED:
          properties.setTrouble(TroubleType.SERVICE_REQUIRED, trouble);
          break;
        case PANEL_AC_TROUBLE:
          properties.setTrouble(TroubleType.AC_TROUBLE, trouble);
          break;
        case PANEL_TELEPHONE_TROUBLE:
          properties.setTrouble(TroubleType.TELEPHONE_LINE_TROUBLE, trouble);
          break;
        case PANEL_FTC_TROUBLE:
          properties.setTrouble(TroubleType.FAILURE_TO_COMMUNICATE, trouble);
          break;
        case PANEL_ZONE_FAULT:
          properties.setTrouble(TroubleType.ZONE_FAULT, trouble);
          break;
        case PANEL_ZONE_TAMPER:
          properties.setTrouble(TroubleType.ZONE_TAMPER, trouble);
          break;
        case PANEL_ZONE_LOW_BATTERY:
          properties.setTrouble(TroubleType.ZONE_LOW_BATTERY, trouble);
          break;
        case PANEL_TIME_LOSS:
          properties.setTrouble(TroubleType.LOSS_OF_TIME, trouble);
          break;
        case PANEL_FIRE_KEY_ALARM:
          properties.setTrigger(TriggerType.FIRE_KEY_ALARM, trigger);
          break;
        case PANEL_PANIC_KEY_ALARM:
          properties.setTrigger(TriggerType.PANIC_KEY_ALARM, trigger);
          break;
        case PANEL_AUX_KEY_ALARM:
          properties.setTrigger(TriggerType.AUX_KEY_ALARM, trigger);
          break;
        case PANEL_AUX_INPUT_ALARM:
          properties.setTrigger(TriggerType.AUX_INPUT_ALARM, trigger);
          break;
        default:
          logger.debug("updateProperties(): Panel property not updated.");
          break;
      }
    }
  }
Пример #9
0
  @Override
  public void handleCommand(ChannelUID channelUID, Command command) {

    String channelID = channelUID.getId();
    TeslaChannelSelector selector = TeslaChannelSelector.getValueSelectorFromChannelID(channelID);

    if (selector != null) {
      try {
        switch (selector) {
          case CHARGE_LIMIT_SOC:
            {
              if (command instanceof PercentType) {
                setChargeLimit(((PercentType) command).intValue());
              } else if (command instanceof OnOffType && command == OnOffType.ON) {
                setChargeLimit(100);
              } else if (command instanceof OnOffType && command == OnOffType.OFF) {
                setChargeLimit(0);
              } else if (command instanceof IncreaseDecreaseType
                  && command == IncreaseDecreaseType.INCREASE) {
                setChargeLimit(Math.min(chargeState.charge_limit_soc + 1, 100));
              } else if (command instanceof IncreaseDecreaseType
                  && command == IncreaseDecreaseType.DECREASE) {
                setChargeLimit(Math.max(chargeState.charge_limit_soc - 1, 0));
              }
              break;
            }
          case TEMPERATURE:
            {
              if (command instanceof DecimalType) {
                setTemperature(((DecimalType) command).floatValue());
              }
              break;
            }
          case SUN_ROOF_STATE:
            {
              if (command instanceof StringType) {
                setSunroof(command.toString());
              }
              break;
            }
          case SUN_ROOF:
            {
              if (command instanceof PercentType) {
                moveSunroof(((PercentType) command).intValue());
              } else if (command instanceof OnOffType && command == OnOffType.ON) {
                moveSunroof(100);
              } else if (command instanceof OnOffType && command == OnOffType.OFF) {
                moveSunroof(0);
              } else if (command instanceof IncreaseDecreaseType
                  && command == IncreaseDecreaseType.INCREASE) {
                moveSunroof(Math.min(chargeState.charge_limit_soc + 1, 100));
              } else if (command instanceof IncreaseDecreaseType
                  && command == IncreaseDecreaseType.DECREASE) {
                moveSunroof(Math.max(chargeState.charge_limit_soc - 1, 0));
              }
              break;
            }
          case CHARGE_TO_MAX:
            {
              if (command instanceof OnOffType) {
                if (((OnOffType) command) == OnOffType.ON) {
                  setMaxRangeCharging(true);
                } else {
                  setMaxRangeCharging(false);
                }
              }
              break;
            }
          case CHARGE:
            {
              if (command instanceof OnOffType) {
                if (((OnOffType) command) == OnOffType.ON) {
                  charge(true);
                } else {
                  charge(false);
                }
              }
              break;
            }
          case FLASH:
            {
              if (command instanceof OnOffType) {
                if (((OnOffType) command) == OnOffType.ON) {
                  flashLights();
                }
              }
              break;
            }
          case HONK_HORN:
            {
              if (command instanceof OnOffType) {
                if (((OnOffType) command) == OnOffType.ON) {
                  honkHorn();
                }
              }
              break;
            }
          case CHARGEPORT:
            {
              if (command instanceof OnOffType) {
                if (((OnOffType) command) == OnOffType.ON) {
                  openChargePort();
                }
              }
              break;
            }
          case DOOR_LOCK:
            {
              if (command instanceof OnOffType) {
                if (((OnOffType) command) == OnOffType.ON) {
                  lockDoors(true);
                } else {
                  lockDoors(false);
                }
              }
              break;
            }
          case AUTO_COND:
            {
              if (command instanceof OnOffType) {
                if (((OnOffType) command) == OnOffType.ON) {
                  autoConditioning(true);
                } else {
                  autoConditioning(false);
                }
              }
              break;
            }
          default:
            break;
        }
        return;
      } catch (IllegalArgumentException e) {
        logger.warn(
            "An error occurred while trying to set the read-only variable associated with channel '{}' to '{}'",
            channelID,
            command.toString());
      }
    }
  }