Ejemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  protected synchronized void internalReceiveCommand(String itemName, Command command) {

    PLCBusBindingConfig config = tryGetConfigFor(itemName);

    if (config == null) {
      logger.error("No config found for item %s", itemName);
      return;
    }

    if (command == OnOffType.ON) {
      plcBusController.switchOn(config.getUnit());
    } else if (command == OnOffType.OFF) {
      plcBusController.switchOff(config.getUnit());
    } else if (command == IncreaseDecreaseType.INCREASE) {
      plcBusController.bright(config.getUnit(), config.getSeconds());
    } else if (command == IncreaseDecreaseType.DECREASE) {
      plcBusController.dim(config.getUnit(), config.getSeconds());
    } else if (command == StopMoveType.STOP) {
      plcBusController.fadeStop(config.getUnit());
    } else if (command == UpDownType.UP) {
      plcBusController.switchOn(config.getUnit());
    } else if (command == UpDownType.DOWN) {
      plcBusController.switchOff(config.getUnit());
    }
  }
Ejemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  protected synchronized void internalReceiveUpdate(String itemName, State newState) {

    PLCBusBindingConfig config = tryGetConfigFor(itemName);

    if (config == null) {
      logger.error("No config found for %s", itemName);
      return;
    }

    if (newState == UnDefType.UNDEF) {
      StatusResponse response = plcBusController.requestStatusFor(config.getUnit());

      State status = (response.isUnitOn()) ? OnOffType.ON : OnOffType.OFF;
      this.eventPublisher.postUpdate(itemName, status);
    }
  }