Examples of YamahaReceiverProxy


Examples of org.openhab.binding.yamahareceiver.internal.hardware.YamahaReceiverProxy

    try {
      // Iterate through all proxies
      for (Map.Entry<String, YamahaReceiverProxy> entry : proxies
          .entrySet()) {
        String deviceUid = entry.getKey();
        YamahaReceiverProxy receiverProxy = entry.getValue();
        sendUpdates(receiverProxy, deviceUid);
      }
    } catch (Throwable t) {
      logger.error("Error polling devices for " + getName(), t);
    }
View Full Code Here

Examples of org.openhab.binding.yamahareceiver.internal.hardware.YamahaReceiverProxy

    YamahaReceiverBindingConfig config = getConfigForItemName(itemName);
    if (config == null) {
      logger.error("Received command for unknown item '" + itemName + "'");
      return;
    }
    YamahaReceiverProxy proxy = proxies.get(config.getDeviceUid());
    if (proxy == null) {
      logger.error("Received command for unknown device uid '"
          + config.getDeviceUid() + "'");
      return;
    }

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

    try {
      Zone zone = config.getZone();
      BindingType type = config.getBindingType();
      if (type == BindingType.power) {
        if (command instanceof OnOffType) {
          proxy.setPower(zone, command == OnOffType.ON);
        }
      } else if (type == BindingType.volumePercent
          || type == BindingType.volumeDb) {
        if (command instanceof IncreaseDecreaseType
            || command instanceof UpDownType) {
          // increase/decrease dB by .5 dB
          float db = proxy.getState(zone).getVolume();
          float adjAmt;
          if (command == IncreaseDecreaseType.INCREASE
              || command == UpDownType.UP) {
            adjAmt = .5f;
          } else {
            adjAmt = -.5f;
          }
          float newDb = db + adjAmt;
          proxy.setVolume(zone, newDb);
          // send new value as update
          State newState = new DecimalType(newDb);
          eventPublisher.postUpdate(itemName, newState);
        } else if (command instanceof PercentType) {
          // set dB from percent
          byte percent = ((PercentType) command).byteValue();
          int db = percentToDB(percent);
          proxy.setVolume(zone, db);
        } else {
          // set dB from value
          float db = Float.parseFloat(command.toString());
          proxy.setVolume(zone, db);
        }
        // Volume updates multiple values => send update now
        sendUpdates(proxy, config.getDeviceUid());
      } else if (type == BindingType.mute) {
        if (command instanceof OnOffType) {
          proxy.setMute(zone, command == OnOffType.ON);
        }
      } else if (type == BindingType.input) {
        proxy.setInput(zone, parseString(command.toString()));
      } else if (type == BindingType.surroundProgram) {
        proxy.setSurroundProgram(zone, parseString(command.toString()));
      } else if (type == BindingType.netRadio) {
        if (command instanceof DecimalType) {
          proxy.setNetRadio(((DecimalType)command).intValue());
        }
      }
    } catch (IOException e) {
      logger.warn("Cannot communicate with " + proxy.getHost()
          + " (uid: " + config.getDeviceUid() + ")");
    } catch (Throwable t) {
      logger.error("Error processing command '" + command
          + "' for item '" + itemName + "'", t);
    }
View Full Code Here

Examples of org.openhab.binding.yamahareceiver.internal.hardware.YamahaReceiverProxy

            // no uid => one device => use default UID
            String uid = separatorIdx == -1 ? DEFAULT_DEVICE_UID
                : key.substring(0, separatorIdx);
            // proxy is stateless. keep them in a map in the
            // binding.
            proxies.put(uid, new YamahaReceiverProxy(host));
          }
        }
        setProperlyConfigured(true);
      }
    } catch (Throwable t) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.