Package org.openhab.binding.insteonhub.internal.hardware

Examples of org.openhab.binding.insteonhub.internal.hardware.InsteonHubProxy


    Set<InsteonHubBindingDeviceInfo> deviceInfos = InsteonHubBindingConfigUtil
        .getConfiguredDevices(providers);
    // loop through all configured devices
    for (InsteonHubBindingDeviceInfo deviceInfo : deviceInfos) {
      // lookup proxy for device
      InsteonHubProxy proxy = proxies.get(deviceInfo.getHubId());
      if (proxy != null) {
        // request device level from proxy
        // this will callback in AsyncEventPublisher if device exists
        proxy.requestDeviceLevel(deviceInfo.getDeviceId());
      }
    }

    logger.debug(BINDING_NAME + " execute complete");
  }
View Full Code Here


    BindingType type = config.getBindingType();
    String hubId = config.getDeviceInfo().getHubId();
    String deviceId = config.getDeviceInfo().getDeviceId();

    // lookup proxy from this configuration
    InsteonHubProxy proxy = proxies.get(hubId);
    if (proxy == null) {
      logger.error(BINDING_NAME
          + " received command for unknown hub id '" + hubId + "'");
      return;
    }

    if (logger.isDebugEnabled()) {
      logger.debug(BINDING_NAME + " processing command '" + command
          + "' of type '" + command.getClass().getSimpleName()
          + "' for item '" + itemName + "'");
    }

    try {
      // process according to type
      if (type == BindingType.SWITCH) {
        // set value on or off
        if (command instanceof OnOffType) {
          proxy.setDevicePower(deviceId, command == OnOffType.ON);
        }
      } else if (type == BindingType.DIMMER) {
        // INSTEON Dimmer supports Dimmer and RollerShutter types
        if (command instanceof OnOffType) {
          // ON or OFF => Set level to 255 or 0
          int level = command == OnOffType.ON ? 255 : 0;
          proxy.setDeviceLevel(deviceId, level);
        } else if (command instanceof IncreaseDecreaseType) {
          // Increase/Decrease => Incremental Brighten/Dim
          InsteonHubAdjustmentType adjustmentType;
          if (command == IncreaseDecreaseType.INCREASE)
            adjustmentType = InsteonHubAdjustmentType.BRIGHTEN;
          else
            adjustmentType = InsteonHubAdjustmentType.DIM;
          if (setDimTimeout(itemName)) {
            proxy.startDeviceAdjustment(deviceId, adjustmentType);
          }
        } else if (command instanceof UpDownType) {
          // Up/Down => Start Brighten/Dim
          InsteonHubAdjustmentType adjustmentType;
          if (command == UpDownType.UP)
            adjustmentType = InsteonHubAdjustmentType.BRIGHTEN;
          else
            adjustmentType = InsteonHubAdjustmentType.DIM;
          proxy.startDeviceAdjustment(deviceId, adjustmentType);
        } else if (command instanceof StopMoveType) {
          // Stop => Stop Brighten/Dim
          if (command == StopMoveType.STOP) {
            proxy.stopDeviceAdjustment(deviceId);
          }
        } else {
          // set level from 0 to 100 percent value
          byte percentByte = Byte.parseByte(command.toString());
          float percent = percentByte * .01f;
          int level = (int) (255 * percent);
          proxy.setDeviceLevel(deviceId, level);
        }

      }
    } catch (Throwable t) {
      logger.error("Error processing command '" + command
View Full Code Here

            .createInstances(config);
        proxies.putAll(newProxies);
        for (Map.Entry<String, InsteonHubProxy> entry : proxies
            .entrySet()) {
          String hubId = entry.getKey();
          InsteonHubProxy proxy = entry.getValue();
          proxy.addListener(new AsyncEventPublisher(hubId));
          // If activated, start proxy now
          if (activated) {
            proxy.start();
          }
        }

        // Set properly configured
        setProperlyConfigured(true);
View Full Code Here

            + CONFIG_KEY_PORT);
        int port = StringUtils.isBlank(portStr) ? InsteonHubSerialProxy.DEFAULT_PORT
            : Integer.parseInt(config.get(
                keyPrefix + CONFIG_KEY_PORT).toString());
        // Create proxy, and add it to map
        InsteonHubProxy proxy = new InsteonHubSerialProxy(host, port);
        proxies.put(hubId, proxy);
      }
    }
    return proxies;
  }
View Full Code Here

TOP

Related Classes of org.openhab.binding.insteonhub.internal.hardware.InsteonHubProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.