Package org.openhab.binding.maxcube.internal.message

Examples of org.openhab.binding.maxcube.internal.message.Device


              }
            } else if (message.getType() == MessageType.L) {
              Collection<? extends Device> tempDevices = ((L_Message) message).getDevices(configurations);

              for (Device d : tempDevices) {
                Device existingDevice = findDevice(d.getSerialNumber(), devices);
                if (existingDevice == null) {
                  devices.add(d);
                } else {
                  devices.remove(existingDevice);
                  devices.add(d);
                }
              }

              logger.debug("{} devices found.", devices.size());

              // the L message is the last one, while the reader
              // would hang trying to read a new line and
              // eventually the
              // cube will fail to establish
              // new connections for some time
              cont = false;
            }
          }
        } catch (Exception e) {
          logger.info("Failed to process message received by MAX! protocol.");
          logger.debug(Utils.getStackTrace(e));
        }
      }

      socket.close();

      for (MaxCubeBindingProvider provider : providers) {
        for (String itemName : provider.getItemNames()) {
          String serialNumber = provider.getSerialNumber(itemName);

          Device device = findDevice(serialNumber, devices);

          if (device == null) {
            logger.info("Cannot find MAX!cube device with serial number '{}'", serialNumber);

            if (logger.isDebugEnabled()) {
              StringBuilder sb = new StringBuilder();
              sb.append("Available MAX! devices are:");
              for (Device d : devices) {
                sb.append("\n\t");
                sb.append(d.getSerialNumber());
              }
              logger.debug(sb.toString());
            }
            continue;
          }

          switch (device.getType()) {
          case HeatingThermostatPlus:
          case HeatingThermostat:
            if (provider.getBindingType(itemName) == BindingType.VALVE) {
              eventPublisher.postUpdate(itemName, ((HeatingThermostat) device).getValvePosition());
            } else if (provider.getBindingType(itemName) == BindingType.MODE) {
View Full Code Here


      if (serialNumber.equals(null)) {
        continue;
      }

      // send command to MAX!Cube LAN Gateway
      Device device = findDevice(serialNumber, devices);

      if (device == null) {
        logger.debug("Cannot send command to device with serial number {}, device not listed.", serialNumber);
        continue;
      }

      String rfAddress = device.getRFAddress();
      String commandString = null;

      if (command instanceof DecimalType || command instanceof OnOffType) {
        DecimalType decimalType = DEFAULT_OFF_TEMPERATURE;
        if (command instanceof DecimalType) {
          decimalType = (DecimalType) command;
        } else if (command instanceof OnOffType) {
          decimalType = OnOffType.ON.equals(command) ? DEFAULT_ON_TEMPERATURE : DEFAULT_OFF_TEMPERATURE;
        }

        S_Command cmd = new S_Command(rfAddress, device.getRoomId(), decimalType.doubleValue());
        commandString = cmd.getCommandString();
      } else if (command instanceof StringType) {
        String commandContent = command.toString().trim().toUpperCase();
        ThermostatModeType commandThermoType = null;
        if (commandContent.contentEquals(ThermostatModeType.AUTOMATIC.toString())) {
          commandThermoType = ThermostatModeType.AUTOMATIC;
        } else if (commandContent.contentEquals(ThermostatModeType.BOOST.toString())) {
          commandThermoType = ThermostatModeType.BOOST;
        } else {
          logger.debug("Only updates to AUTOMATIC & BOOST supported, received value ;'{}'", commandContent);
          continue;
        }

        S_Command cmd = new S_Command(rfAddress, device.getRoomId(), commandThermoType);
        commandString = cmd.getCommandString();
      }

      if (commandString != null) {
        Socket socket = null;
View Full Code Here

TOP

Related Classes of org.openhab.binding.maxcube.internal.message.Device

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.