/** {@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); } }
/** * Updates the device & roomname * * @param configurationParameter */ private void updateDeviceName(Entry<String, Object> configurationParameter) { try { Device device = getMaxCubeBridgeHandler().getDevice(maxDeviceSerial); String name = configurationParameter.getValue().toString(); if (configurationParameter.getKey().equals(PROPERTY_DEVICENAME) && !(name.equals(device.getName()))) { logger.info("Updating device name for {} to {}", getThing().getUID().toString(), name); device.setName(name); bridgeHandler.sendDeviceAndRoomNameUpdate(name); SendCommand sendCommand = new SendCommand(maxDeviceSerial, new Q_Command(), "Reload Data"); bridgeHandler.queueCommand(sendCommand); } if (configurationParameter.getKey().equals(PROPERTY_ROOMID) || configurationParameter.getKey().equals(PROPERTY_ROOMNAME)) { int roomId = ((BigDecimal) configurationParameter.getValue()).intValue(); if (roomId != device.getRoomId()) { logger.info("Updating room for {} to {}", getThing().getUID().getAsString(), roomId); device.setRoomId(roomId); // TODO: handle if a room has no more devices, probably should be deleted. Also handle if // room rfId // is no longer valid as the related device is movd to another room bridgeHandler.sendDeviceAndRoomNameUpdate(name); SendCommand sendCommand = new SendCommand( maxDeviceSerial, Z_Command.wakeupDevice(device.getRFAddress()), "WakeUp device" + getThing().getUID().getAsString()); bridgeHandler.queueCommand(sendCommand); sendCommand = new SendCommand( maxDeviceSerial, new S_ConfigCommand(device.getRFAddress(), roomId, ConfigCommandType.SetRoom), "Set Room"); bridgeHandler.queueCommand(sendCommand); sendCommand = new SendCommand(maxDeviceSerial, new Q_Command(), "Reload Data"); bridgeHandler.queueCommand(sendCommand); sendCCommand(); } } } catch (NullPointerException e) { logger.warn( "MAX! Cube LAN gateway bridge handler not found. Cannot handle update without bridge."); } catch (Exception e) { logger.debug("Exception occurred during execution: {}", e.getMessage(), e); } }
private void sendPropertyUpdate( Map<String, Object> configurationParameters, HashMap<String, Object> deviceProperties) { try { Device device = getMaxCubeBridgeHandler().getDevice(maxDeviceSerial); rfAddress = device.getRFAddress(); int roomId = device.getRoomId(); BigDecimal tempComfort = (BigDecimal) configurationParameters.getOrDefault( PROPERTY_THERMO_COMFORT_TEMP, deviceProperties.get(PROPERTY_THERMO_COMFORT_TEMP)); BigDecimal tempEco = (BigDecimal) configurationParameters.getOrDefault( PROPERTY_THERMO_ECO_TEMP, deviceProperties.get(PROPERTY_THERMO_ECO_TEMP)); BigDecimal tempSetpointMax = (BigDecimal) configurationParameters.getOrDefault( PROPERTY_THERMO_MAX_TEMP_SETPOINT, deviceProperties.get(PROPERTY_THERMO_MAX_TEMP_SETPOINT)); BigDecimal tempSetpointMin = (BigDecimal) configurationParameters.getOrDefault( PROPERTY_THERMO_MIN_TEMP_SETPOINT, deviceProperties.get(PROPERTY_THERMO_MIN_TEMP_SETPOINT)); BigDecimal tempOffset = (BigDecimal) configurationParameters.getOrDefault( PROPERTY_THERMO_OFFSET_TEMP, deviceProperties.get(PROPERTY_THERMO_OFFSET_TEMP)); BigDecimal tempOpenWindow = (BigDecimal) configurationParameters.getOrDefault( PROPERTY_THERMO_WINDOW_OPEN_TEMP, deviceProperties.get(PROPERTY_THERMO_WINDOW_OPEN_TEMP)); BigDecimal durationOpenWindow = (BigDecimal) configurationParameters.getOrDefault( PROPERTY_THERMO_WINDOW_OPEN_DURATION, deviceProperties.get(PROPERTY_THERMO_WINDOW_OPEN_DURATION)); S_ConfigCommand cmd = new S_ConfigCommand( rfAddress, roomId, tempComfort.doubleValue(), tempEco.doubleValue(), tempSetpointMax.doubleValue(), tempSetpointMin.doubleValue(), tempOffset.doubleValue(), tempOpenWindow.doubleValue(), durationOpenWindow.intValue()); bridgeHandler.queueCommand( new SendCommand(maxDeviceSerial, cmd, "Update Thermostat Properties")); sendCCommand(); } catch (NullPointerException e) { logger.warn( "MAX! Cube LAN gateway bridge handler not found. Cannot handle update without bridge."); } catch (Exception e) { logger.debug("Exception occurred during execution: {}", e.getMessage(), e); } }