From 79f6c1a1e2091b9c60a3c9d3b2d78297991e8da8 Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Wed, 5 May 2021 22:22:13 +0200 Subject: [PATCH 01/15] - [Thermo] porting of existing OH2 channels to OH3 (it requires own4j 0.5-shapshot) - [Thermo] new fanspeed channel to control fancoil speed (AUTO, VEL1/2/3) - [Thermo] support for mode (MANUAL, PROTECTION, OFF) and function (HEATING, COOLING, GENERIC) Signed-off-by: Conte Andrea Signed-off-by: Massimo Valla --- .../org.openhab.binding.openwebnet/README.md | 44 +- .../org.openhab.binding.openwebnet/pom.xml | 2 +- .../OpenWebNetBindingConstants.java | 36 +- .../handler/OpenWebNetBridgeHandler.java | 15 +- .../OpenWebNetThermoregulationHandler.java | 606 ++++++++++++++++++ .../internal/OpenWebNetHandlerFactory.java | 7 +- .../OpenWebNetDeviceDiscoveryService.java | 26 +- .../resources/OH-INF/thing/BusThermostat.xml | 49 ++ .../main/resources/OH-INF/thing/channels.xml | 135 ++++ 9 files changed, 897 insertions(+), 23 deletions(-) create mode 100644 bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java create mode 100644 bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml diff --git a/bundles/org.openhab.binding.openwebnet/README.md b/bundles/org.openhab.binding.openwebnet/README.md index 72b91fdb0f18d..7da867150d72b 100644 --- a/bundles/org.openhab.binding.openwebnet/README.md +++ b/bundles/org.openhab.binding.openwebnet/README.md @@ -42,6 +42,7 @@ The following Things and OpenWebNet `WHOs` are supported: | Gateway Management | `13` | `bus_gateway` | Any IP gateway supporting OpenWebNet protocol should work (e.g. F454 / MyHOMEServer1 / MH202 / F455 / MH200N, ...) | Successfully tested: F454, MyHOMEServer1, MyHOME_Screen10, F455, F452, F453AV, MH201, MH202, MH200N. Some connection stability issues/gateway resets reported with MH202 | | Lighting | `1` | `bus_on_off_switch`, `bus_dimmer` | BUS switches and dimmers | Successfully tested: F411/2, F411/4, F411U2, F422, F429. Some discovery issues reported with F429 (DALI Dimmers) | | Automation | `2` | `bus_automation` | BUS roller shutters, with position feedback and auto-calibration | Successfully tested: LN4672M2 | +| Temperature Control | `4` | `bus_thermostat` | Zones room thermostats (stand-alone thermostat) | Successfully tested: H/LN4691 | | Energy Management | `18` | `bus_energy_meter` | Energy Management | Successfully tested: F520, F521 | ### For ZigBee (Radio) @@ -127,12 +128,17 @@ For any manually added device, you must configure: Devices support some of the following channels: -| Channel Type ID (channel ID) | Item Type | Description | Read/Write | -|------------------------------------------------|---------------|---------------------------------------------------------|:----------:| -| `switch` or `switch_01`/`02` for ZigBee | Switch | To switch the device `ON` and `OFF` | R/W | -| `brightness` | Dimmer | To adjust the brightness value (Percent, `ON`, `OFF`) | R/W | -| `shutter` | Rollershutter | To activate roller shutters (`UP`, `DOWN`, `STOP`, Percent - [see Shutter position](#shutter-position)) | R/W | -| `power` | Number:Power | The current active power usage from Energy Meter | R | +| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | +|------------------------------------------------|----------------|---------------|---------------------------------------------------------|:----------:| +| `switch` or `switch_01`/`02` for ZigBee | bus_on_off_switch, zb_on_off_switch, zb_on_off_switch2u | Switch | To switch the device `ON` and `OFF` | R/W | +| `brightness` | bus_dimmer, zb_dimmer | Dimmer | To adjust the brightness value (Percent, `ON`, `OFF`) | R/W | +| `shutter` | bus_automation | Rollershutter | To activate roller shutters (`UP`, `DOWN`, `STOP`, Percent - [see Shutter position](#shutter-position)) | R/W | +| `power` | bus_energy_meter, zb_automation | Number:Power | The current active power usage from Energy Meter | R | +| `temperature` | bus_thermostat | Number:Temperature | The zone currently sensed temperature (°C) | R | +| `setpointTemperature` | bus_thermostat | Number:Temperature | The zone setpoint temperature (°C) | R/W | +| `function` | bus_thermostat | String | The zone set thermo function: `HEAT`, `COOL` or `GENERIC` (heating + cooling) | R/W | +| `mode` | bus_thermostat | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | +| `speedFanCoil` | bus_thermostat | String | The speed of the fancoil associated to the zone: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | ### Notes on channels #### `shutter` position @@ -154,11 +160,12 @@ BUS gateway and things configuration: ```xtend Bridge openwebnet:bus_gateway:mybridge "MyHOMEServer1" [ host="192.168.1.35", passwd="abcde", port=20000, discoveryByActivation=false ] { - bus_on_off_switch LR_switch "Living Room Light" [ where="51" ] - bus_dimmer LR_dimmer "Living Room Dimmer" [ where="0311#4#01" ] - bus_automation LR_shutter "Living Room Shutter" [ where="93", shutterRun="10050"] - bus_energy_meter CENTRAL_Ta "Energy Meter Ta" [ where="51" ] - bus_energy_meter CENTRAL_Tb "Energy Meter Tb" [ where="52" ] + bus_on_off_switch LR_switch "Living Room Light" [ where="51" ] + bus_dimmer LR_dimmer "Living Room Dimmer" [ where="0311#4#01" ] + bus_automation LR_shutter "Living Room Shutter" [ where="93", shutterRun="10050"] + bus_energy_meter CENTRAL_Ta "Energy Meter Ta" [ where="51" ] + bus_energy_meter CENTRAL_Tb "Energy Meter Tb" [ where="52" ] + bus_thermostat LR_thermostat "Living Room Thermostat" [ where="2"] } ``` @@ -183,6 +190,12 @@ Dimmer iLR_dimmer "Dimmer [%.0f %%]" (gShutters, gLivingRoom) [ "Blinds" ] { channel="openwebnet:bus_automation:mybridge:LR_shutter:shutter" } Number:Power iCENTRAL_Ta "Power [%.0f %unit%]" { channel="openwebnet:bus_energy_meter:mybridge:CENTRAL_Ta:power" } Number:Power iCENTRAL_Tb "Power [%.0f %unit%]" { channel="openwebnet:bus_energy_meter:mybridge:CENTRAL_Tb:power" } +Number:Temperature iLR_thermostat_temp "Temperature" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:temperature" } +Number:Temperature iLR_thermostat_set "SetPoint Temperature" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:setpointTemperature" } +String iLR_thermostat_setFanSpeed "FanSpeed" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:speedFanCoil" } +String iLR_thermostat_setMode "Mode" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:mode" } +String iLR_thermostat_setFunc "Function" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:function" } + ``` @@ -212,6 +225,15 @@ sitemap openwebnet label="OpenWebNet Binding Example Sitemap" Default item=iCENTRAL_Ta label="General" icon="energy" valuecolor=[>3000="red"] Default item=iCENTRAL_Tb label="Ground Floor" icon="energy" valuecolor=[>3000="red"] } + + Frame label="Thermoregulation" + { + Default item=iLR_thermostat_temp label="Temperature" icon="fire" valuecolor=[<20="red"] + Setpoint item=iLR_thermostat_set label="Setpoint [%.1f °C]" step=0.5 minValue=15 maxValue=30 + Selection item=iLR_thermostat_setFanSpeed label="Fan Speed" icon="fan" mappings=[AUTO="AUTO", SPEED_1="Low", SPEED_2="Medium", SPEED_3="High"] + Switch item=iLR_thermostat_setMode label="Mode" icon="settings" + Selection item=iLR_thermostat_setFunc label="Function" icon="heating" mappings=[HEATING="Heating", COOLING="Cooling", GENERIC="Heating/Cooling"] + } } ``` diff --git a/bundles/org.openhab.binding.openwebnet/pom.xml b/bundles/org.openhab.binding.openwebnet/pom.xml index 9b703d9762b6d..70f3a1e092689 100644 --- a/bundles/org.openhab.binding.openwebnet/pom.xml +++ b/bundles/org.openhab.binding.openwebnet/pom.xml @@ -23,7 +23,7 @@ io.github.openwebnet4j openwebnet4j - 0.4.1 + 0.5.0-SNAPSHOT compile diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java index 33fa4def8a9e5..bcceb43c5dad8 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java @@ -26,7 +26,8 @@ * The {@link OpenWebNetBindingConstants} class defines common constants, which are used across the whole binding. * * @author Massimo Valla - Initial contribution - * @author Andrea Conte - Energy management + * @author Andrea Conte - Energy management, Thermoregulation + * @author Gilberto Cocchi - Thermoregulation */ @NonNullByDefault @@ -55,6 +56,15 @@ public class OpenWebNetBindingConstants { public static final String THING_LABEL_BUS_AUTOMATION = "Automation"; public static final ThingTypeUID THING_TYPE_BUS_ENERGY_METER = new ThingTypeUID(BINDING_ID, "bus_energy_meter"); public static final String THING_LABEL_BUS_ENERGY_METER = "Energy Meter"; + // TODO support for bus_temp_sensor + // public static final ThingTypeUID THING_TYPE_BUS_TEMP_SENSOR = new ThingTypeUID(BINDING_ID, "bus_temp_sensor"); + // public static final String THING_LABEL_BUS_TEMP_SENSOR = "Temperature Sensor"; + public static final ThingTypeUID THING_TYPE_BUS_THERMOSTAT = new ThingTypeUID(BINDING_ID, "bus_thermostat"); + public static final String THING_LABEL_BUS_THERMOSTAT = "Thermostat (stand-alone)"; + // TODO support for bus_cu_thermostat + // public static final ThingTypeUID THING_TYPE_BUS_THERMO_CENTRAL_UNIT = new ThingTypeUID(BINDING_ID, + // "bus_cu_thermostat"); + // public static final String THING_LABEL_BUS_THERMO_CENTRAL_UNIT = "Thermo Central Unit"; // ZIGBEE public static final ThingTypeUID THING_TYPE_ZB_ON_OFF_SWITCH = new ThingTypeUID(BINDING_ID, "zb_on_off_switch"); @@ -79,6 +89,11 @@ public class OpenWebNetBindingConstants { public static final Set AUTOMATION_SUPPORTED_THING_TYPES = new HashSet<>( Arrays.asList(THING_TYPE_ZB_AUTOMATION, THING_TYPE_BUS_AUTOMATION)); + // ## Thermoregulation + public static final Set THERMOREGULATION_SUPPORTED_THING_TYPES = new HashSet<>( + Arrays.asList(THING_TYPE_BUS_THERMOSTAT)); // TODO , THING_TYPE_BUS_TEMP_SENSOR, + // THING_TYPE_BUS_THERMO_CENTRAL_UNIT)); + // ## Energy Management public static final Set ENERGY_MANAGEMENT_SUPPORTED_THING_TYPES = new HashSet<>( Arrays.asList(THING_TYPE_BUS_ENERGY_METER)); @@ -86,7 +101,8 @@ public class OpenWebNetBindingConstants { // ## Groups public static final Set DEVICE_SUPPORTED_THING_TYPES = Stream .of(LIGHTING_SUPPORTED_THING_TYPES, AUTOMATION_SUPPORTED_THING_TYPES, - ENERGY_MANAGEMENT_SUPPORTED_THING_TYPES, GENERIC_SUPPORTED_THING_TYPES) + THERMOREGULATION_SUPPORTED_THING_TYPES, ENERGY_MANAGEMENT_SUPPORTED_THING_TYPES, + GENERIC_SUPPORTED_THING_TYPES) .flatMap(Collection::stream).collect(Collectors.toCollection(HashSet::new)); public static final Set BRIDGE_SUPPORTED_THING_TYPES = new HashSet<>( @@ -106,6 +122,22 @@ public class OpenWebNetBindingConstants { // automation public static final String CHANNEL_SHUTTER = "shutter"; + // thermo + public static final String CHANNEL_TEMPERATURE = "temperature"; + // tbd public static final String CHANNEL_TEMP_TARGET = "targetTemperature"; + public static final String CHANNEL_FUNCTION = "function"; // former: "thermoFunction"; + public static final String CHANNEL_HEATING_COOLING_MODE = "thermostatMode"; // former: "heatingCoolingMode"; + // tbd public static final String CHANNEL_HEATING = "heating"; + // tbd public static final String CHANNEL_COOLING = "cooling"; + // tbd public static final String CHANNEL_ACTIVE_MODE = "activeMode"; + // tbd public static final String CHANNEL_LOCAL_MODE = "localMode"; + public static final String CHANNEL_TEMP_SETPOINT = "setpointTemperature"; + public static final String CHANNEL_MODE = "mode"; // former: setMode + // tbd public static final String CHANNEL_ALL_TEMP_SETPOINT = "allSetpointTemperature"; + // tbd public static final String CHANNEL_ALL_SET_MODE = "allSetMode"; + // tbd public static final String CHANNEL_ALL_THERMO_FUNCTION = "allThermoFunction"; + public static final String CHANNEL_FAN_SPEED = "speedFanCoil"; + // energy management public static final String CHANNEL_POWER = "power"; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetBridgeHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetBridgeHandler.java index 5b0dfb104c635..b73d3e98c7fb6 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetBridgeHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetBridgeHandler.java @@ -53,6 +53,7 @@ import org.openwebnet4j.message.GatewayMgmt; import org.openwebnet4j.message.Lighting; import org.openwebnet4j.message.OpenMessage; +import org.openwebnet4j.message.Thermoregulation; import org.openwebnet4j.message.What; import org.openwebnet4j.message.Where; import org.openwebnet4j.message.WhereZigBee; @@ -64,7 +65,8 @@ * The {@link OpenWebNetBridgeHandler} is responsible for handling communication with gateways and handling events. * * @author Massimo Valla - Initial contribution - * @author Andrea Conte - Energy management + * @author Andrea Conte - Energy management, Thermoregulation + * @author Gilberto Cocchi - Thermoregulation */ @NonNullByDefault public class OpenWebNetBridgeHandler extends ConfigStatusBridgeHandler implements GatewayListener { @@ -304,11 +306,9 @@ private void discoverByActivation(BaseOpenMessage baseMsg) { logger.warn("discoverByActivation: null OpenWebNetDeviceDiscoveryService, ignoring msg={}", baseMsg); return; } - if (baseMsg instanceof Lighting || baseMsg instanceof Automation || baseMsg instanceof EnergyManagement) { // we - // support - // these - // types - // only + // we support these types only + if (baseMsg instanceof Lighting || baseMsg instanceof Automation || baseMsg instanceof EnergyManagement + || baseMsg instanceof Thermoregulation) { BaseOpenMessage bmsg = baseMsg; if (baseMsg instanceof Lighting) { What what = baseMsg.getWhat(); @@ -418,7 +418,8 @@ public void onEventMessage(@Nullable OpenMessage msg) { BaseOpenMessage baseMsg = (BaseOpenMessage) msg; // let's try to get the Thing associated with this message... - if (baseMsg instanceof Lighting || baseMsg instanceof Automation || baseMsg instanceof EnergyManagement) { + if (baseMsg instanceof Lighting || baseMsg instanceof Automation || baseMsg instanceof EnergyManagement + || baseMsg instanceof Thermoregulation) { String ownId = ownIdFromMessage(baseMsg); logger.debug("ownIdFromMessage({}) --> {}", baseMsg, ownId); OpenWebNetThingHandler deviceHandler = registeredDevices.get(ownId); diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java new file mode 100644 index 0000000000000..41e48166044eb --- /dev/null +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -0,0 +1,606 @@ +/** + * Copyright (c) 2010-2021 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.openwebnet.handler; + +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FAN_SPEED; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FUNCTION; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_MODE; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMPERATURE; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMP_SETPOINT; +import static org.openhab.core.library.unit.SIUnits.CELSIUS; + +import java.math.BigDecimal; +import java.util.Set; + +import javax.measure.Unit; +import javax.measure.quantity.Temperature; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.openwebnet.OpenWebNetBindingConstants; +import org.openhab.core.library.types.DecimalType; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.types.StringType; +import org.openhab.core.thing.ChannelUID; +import org.openhab.core.thing.Thing; +import org.openhab.core.thing.ThingStatus; +import org.openhab.core.thing.ThingStatusInfo; +import org.openhab.core.thing.ThingTypeUID; +import org.openhab.core.types.Command; +import org.openhab.core.types.UnDefType; +import org.openwebnet4j.communication.OWNException; +import org.openwebnet4j.message.BaseOpenMessage; +import org.openwebnet4j.message.FrameException; +import org.openwebnet4j.message.MalformedFrameException; +import org.openwebnet4j.message.Thermoregulation; +import org.openwebnet4j.message.Thermoregulation.FAN_COIL_SPEED; +import org.openwebnet4j.message.Thermoregulation.FUNCTION; +import org.openwebnet4j.message.Thermoregulation.OPERATION_MODE; +import org.openwebnet4j.message.Thermoregulation.WHAT; +import org.openwebnet4j.message.Where; +import org.openwebnet4j.message.WhereThermo; +import org.openwebnet4j.message.Who; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The {@link OpenWebNetThermoregulationHandler} is responsible for handling commands/messages for a Thermoregulation + * OpenWebNet device. It extends the abstract {@link OpenWebNetThingHandler}. + * + * @author Massimo Valla - Initial contribution + * @author Andrea Conte - Thermoregulation + * @author Gilberto Cocchi - Thermoregulation + */ +@NonNullByDefault +public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler { + + private final Logger logger = LoggerFactory.getLogger(OpenWebNetThermoregulationHandler.class); + + // private enum Mode { + // // TODO make it a single map and integrate it with Thermoregulation.WHAT to have automatic translation + // UNKNOWN("UNKNOWN"), + // AUTO("AUTO"), + // MANUAL("MANUAL"), + // PROTECTION("PROTECTION"), + // OFF("OFF"); + + // private final String mode; + + // Mode(final String mode) { + // this.mode = mode; + // } + + // @Override + // public String toString() { + // return mode; + // } + // } + + // private enum ThermoFunction { + // UNKNOWN(-1), + // COOL(0), + // HEAT(1), + // GENERIC(3); + + // private final int function; + + // ThermoFunction(final int f) { + // this.function = f; + // } + + // public int getValue() { + // return function; + // } + // } + + public final static Set SUPPORTED_THING_TYPES = OpenWebNetBindingConstants.THERMOREGULATION_SUPPORTED_THING_TYPES; + + // private boolean isCentralUnit = false; + // private Mode currentSetMode = Mode.UNKNOWN; + // private Mode currentActiveMode = Mode.UNKNOWN; + // private ThermoFunction thermoFunction = ThermoFunction.UNKNOWN; + // private Thermoregulation.LOCAL_OFFSET localOffset = Thermoregulation.LOCAL_OFFSET.NORMAL; + + // 11.5 is the default setTemp used in MyHomeUP mobile app + private Double currentSetPointTemp = 11.5d; + + private Thermoregulation.FUNCTION currentFunction = Thermoregulation.FUNCTION.GENERIC; + + public OpenWebNetThermoregulationHandler(Thing thing) { + super(thing); + // TODO not yet supported + // if (OpenWebNetBindingConstants.THING_TYPE_BUS_THERMO_CENTRAL_UNIT.equals(thing.getThingTypeUID())) { + // isCentralUnit = true; + // } + } + + @Override + public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { + super.bridgeStatusChanged(bridgeStatusInfo); + + // when the bridge is ONLINE request for thing states (temp, setTemp, fanSpeed...) + if (bridgeStatusInfo.getStatus().equals(ThingStatus.ONLINE)) { + logger.debug("bridgeStatusChanged() thing={}", thing.getUID()); + + try { + // request single channels updates + bridgeHandler.gateway.send(Thermoregulation.requestTemperature(deviceWhere.value())); + bridgeHandler.gateway.send(Thermoregulation.requestSetPointTemperature(deviceWhere.value())); + bridgeHandler.gateway.send(Thermoregulation.requestFanCoilSpeed(deviceWhere.value())); + bridgeHandler.gateway.send(Thermoregulation.requestMode(deviceWhere.value())); + } catch (OWNException e) { + logger.error("bridgeStatusChanged() OWNException thingUID={}: {}", thing.getUID(), e.getMessage()); + } + } + } + + @Override + protected void handleChannelCommand(ChannelUID channel, Command command) { + switch (channel.getId()) { + // TODO case CHANNEL_ALL_TEMP_SETPOINT: + case CHANNEL_TEMP_SETPOINT: + handleSetpointCommand(command); + break; + // TODO case CHANNEL_ALL_SET_MODE: + // TODO case CHANNEL_SET_MODE: + // handleModeCommand(command); + // logger.trace("handleChannelCommand() Unsupported handleModeCommand! {}", channel.getId()); + // break; + case CHANNEL_FUNCTION: + handleFunction(command); + break; + case CHANNEL_MODE: + handleMode(command); + break; + case CHANNEL_FAN_SPEED: + handleSetFanSpeedCommand(command); + break; + default: { + logger.warn("handleChannelCommand() Unsupported ChannelUID {}", channel.getId()); + } + } + } + + @Override + protected void requestChannelState(ChannelUID channel) { + logger.debug("requestChannelState() thingUID={} channel={}", thing.getUID(), channel.getId()); + + try { + // this works for bus_thermostat, not for central unit + // bridgeHandler.gateway.send(Thermoregulation.requestStatus(deviceWhere.value())); + + // for bus_thermostat request single channels updates + bridgeHandler.gateway.send(Thermoregulation.requestTemperature(deviceWhere.value())); + bridgeHandler.gateway.send(Thermoregulation.requestSetPointTemperature(deviceWhere.value())); + bridgeHandler.gateway.send(Thermoregulation.requestFanCoilSpeed(deviceWhere.value())); + bridgeHandler.gateway.send(Thermoregulation.requestMode(deviceWhere.value())); + } catch (OWNException e) { + logger.error("requestChannelState() OWNException thingUID={} channel={}: {}", thing.getUID(), + channel.getId(), e.getMessage()); + } + } + + @Override + protected Where buildBusWhere(String wStr) throws IllegalArgumentException { + return new WhereThermo(wStr); + } + + @Override + protected String ownIdPrefix() { + return Who.THERMOREGULATION.value().toString(); + } + + private void handleSetFanSpeedCommand(Command command) { + logger.debug("handleSetFanSpeedCommand() (command={})", command); + + if (command instanceof StringType) { + FAN_COIL_SPEED speed = FAN_COIL_SPEED.valueOf(command.toString()); + + try { + bridgeHandler.gateway.send(Thermoregulation.requestWriteFanCoilSpeed(deviceWhere.value(), speed)); + } catch (OWNException e) { + logger.warn("handleSetFanSpeedCommand() {}", e.getMessage()); + } + } else { + logger.warn("handleSetFanSpeedCommand() Cannot handle command {} for thing {}", command, + getThing().getUID()); + } + } + + private void handleSetpointCommand(Command command) { + logger.debug("handleSetpointCommand() (command={})", command); + + if (command instanceof QuantityType || command instanceof DecimalType) { + BigDecimal value = BigDecimal.ZERO; + if (command instanceof QuantityType) { + Unit unit = CELSIUS; + QuantityType quantity = commandToQuantityType(command, unit); + value = quantity.toBigDecimal(); + } else { + value = ((DecimalType) command).toBigDecimal(); + } + + try { + Thermoregulation mm = Thermoregulation.requestWriteSetpointTemperature(deviceWhere.value(), + value.floatValue(), currentFunction); + + bridgeHandler.gateway.send(mm); + } catch (MalformedFrameException | OWNException e) { + logger.warn("handleSetpointCommand() {}", e.getMessage()); + } + } else { + logger.warn("handleSetpointCommand() Cannot handle command {} for thing {}", command, getThing().getUID()); + } + } + + private void handleMode(Command command) { + if (command instanceof StringType) { + try { + + OPERATION_MODE mode = OPERATION_MODE.valueOf(((StringType) command).toString()); + if (mode == OPERATION_MODE.MANUAL) + logger.debug("handleMode() mode={} function={} setPointTemp={}°", mode.toString(), + currentFunction.toString(), currentSetPointTemp); + else + logger.debug("handleMode() mode={} function={}", mode.toString(), currentFunction.toString()); + + bridgeHandler.gateway.send(Thermoregulation.requestWriteMode(deviceWhere.value(), mode, currentFunction, + currentSetPointTemp)); + } catch (OWNException e) { + logger.warn("handleMode() {}", e.getMessage()); + } + + } else { + logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); + } + } + + private void handleFunction(Command command) { + logger.debug("handleFunction() (command={})", command); + + if (command instanceof StringType) { + try { + + FUNCTION function = FUNCTION.valueOf(((StringType) command).toString()); + logger.debug("handleFunction() mode={}", function.toString()); + + bridgeHandler.gateway.send(Thermoregulation.requestWriteFunction(deviceWhere.value(), function)); + } catch (OWNException e) { + logger.warn("handleFunction() {}", e.getMessage()); + } + + } else { + logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); + } + } + + // TODO not yet supported + // private void handleModeCommand(Command command) { + // logger.debug("handleModeCommand() (command={})", command); + // if (command instanceof StringType) { + // Thermoregulation.WHAT modeWhat = null; + // try { + // Mode mode = Mode.valueOf(((StringType) command).toString()); + // modeWhat = modeToWhat(mode); + // } catch (IllegalArgumentException e) { + // logger.warn("Cannot handle command {} for thing {}. Exception: {}", command, getThing().getUID(), + // e.getMessage()); + // return; + // } + // logger.debug("handleModeCommand() modeWhat={}", modeWhat); + // if (modeWhat != null) { + // try { + // bridgeHandler.gateway.send(Thermoregulation.requestWriteSetMode(deviceWhere.value(), modeWhat)); + // } catch (MalformedFrameException | OWNException e) { + // logger.warn("handleModeCommand() {}", e.getMessage()); + // } + // } else { + // logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); + // } + // } else { + // logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); + // } + // } + + private QuantityType commandToQuantityType(Command command, Unit unit) { + return new QuantityType(command.toFullString()); + } + + @Override + protected void handleMessage(BaseOpenMessage msg) { + super.handleMessage(msg); + if (msg.isCommand()) { + updateModeAndFunction((Thermoregulation) msg); + } else { + if (msg.getDim() == null) + return; + + if (msg.getDim() == Thermoregulation.DIM.TEMPERATURE) { + updateTemperature((Thermoregulation) msg); + } else if (msg.getDim() == Thermoregulation.DIM.TEMP_SETPOINT + || msg.getDim() == Thermoregulation.DIM.COMPLETE_PROBE_STATUS) { + updateSetpoint((Thermoregulation) msg); + + // TODO not applicable for bus_thermostat + // } else if (msg.getDim() == Thermoregulation.DIM.OFFSET) { + // updateLocalMode((Thermoregulation) msg); + // } else if (msg.getDim() == Thermoregulation.DIM.ACTUATOR_STATUS) { + // updateActuatorStatus((Thermoregulation) msg); + // } else if (msg.getDim() == Thermoregulation.DIM.TEMP_TARGET) { + // updateTargetTemp((Thermoregulation) msg); + } else if (msg.getDim() == Thermoregulation.DIM.FAN_COIL_SPEED) { + updateFanCoilSpeed((Thermoregulation) msg); + } else { + logger.debug("handleMessage() Ignoring unsupported DIM {} for thing {}. Frame={}", msg.getDim(), + getThing().getUID(), msg); + } + } + } + + // private void updateMode(Thermoregulation tmsg) { + // logger.debug("updateMode() for thing: {} msg={}", thing.getUID(), tmsg); + + // try { + // OPERATION_MODE mode = Thermoregulation.parseMode(tmsg); + + // if (mode == OPERATION_MODE.MANUAL) + // logger.debug("updateMode() mode={} setPointTemp={}°", mode.toString(), currentSetPointTemp); + // else + // logger.debug("updateMode() mode={}", mode.toString()); + + // updateState(CHANNEL_MODE, new StringType(mode.toString())); + // } catch (FrameException e) { + // logger.warn("updateMode() FrameException on frame {}: {}", tmsg, e.getMessage()); + // // do not update channel state, simply skip wrong message + // } + // } + + // private void updateFunction(Thermoregulation tmsg) { + // logger.debug("updateFunction() for thing: {} msg={}", thing.getUID(), tmsg); + + // try { + // FUNCTION function = Thermoregulation.parseFunction(tmsg); + // logger.debug("updateFunction() FUNCTION={}", function.toString()); + // updateState(CHANNEL_FUNCTION, new StringType(function.toString())); + + // // store current function + // currentFunction = function; + // } catch (FrameException e) { + // logger.warn("updateFunction() FrameException on frame {}: {}", tmsg, e.getMessage()); + // // do not update channel state, simply skip wrong message + // } + // } + + private void updateModeAndFunction(Thermoregulation tmsg) { + logger.debug("updateModeAndFunction() for thing: {} msg={}", thing.getUID(), tmsg); + + if (tmsg.getWhat() == null) { + logger.warn("updateModeAndFunction() Could not parse Mode from: {}", tmsg.getFrameValue()); + return; + } + + try { + logger.debug("updateModeAndFunction() WHAT={}", tmsg.getWhat()); + WHAT w = WHAT.fromValue(tmsg.getWhat().value()); + + OPERATION_MODE mode = w.mode(); + FUNCTION function = w.function(); + + if (w == WHAT.HEATING) + function = FUNCTION.HEATING; + else if (w == WHAT.CONDITIONING) + function = FUNCTION.COOLING; + + if (mode == OPERATION_MODE.MANUAL) + logger.debug("updateModeAndFunction() function={} mode={} setPointTemp={}°", function.toString(), + mode.toString(), currentSetPointTemp); + else + logger.debug("updateModeAndFunction() function={} mode={}", function.toString(), mode.toString()); + + updateState(CHANNEL_MODE, new StringType(mode.toString())); + updateState(CHANNEL_FUNCTION, new StringType(function.toString())); + + // store current function + currentFunction = function; + } catch (Exception e) { + logger.warn("updateModeAndFunction() FrameException on frame {}: {}", tmsg, e.getMessage()); + // do not update channel state, simply skip wrong message + } + } + + private void updateTemperature(Thermoregulation tmsg) { + logger.debug("updateTemperature() for thing: {}", thing.getUID()); + try { + Double temp = Thermoregulation.parseTemperature(tmsg); + updateState(CHANNEL_TEMPERATURE, new DecimalType(temp)); + } catch (FrameException e) { + logger.warn("updateTemperature() FrameException on frame {}: {}", tmsg, e.getMessage()); + updateState(CHANNEL_TEMPERATURE, UnDefType.UNDEF); + } + } + + private void updateSetpoint(Thermoregulation tmsg) { + logger.debug("updateSetpoint() for thing: {}", thing.getUID()); + String channelID = CHANNEL_TEMP_SETPOINT; + + // TODO not yet supported + // if (isCentralUnit) + // channelID = CHANNEL_ALL_TEMP_SETPOINT; + + try { + Double temp = Thermoregulation.parseTemperature(tmsg); + updateState(channelID, new DecimalType(temp)); + + // store current setPoint T + currentSetPointTemp = temp; + } catch (FrameException e) { + logger.warn("updateSetpoint() FrameException on frame {}: {}", tmsg, e.getMessage()); + updateState(channelID, UnDefType.UNDEF); + } + } + + // TODO not yet supported + // private void updateLocalMode(Thermoregulation msg) { + // logger.debug("updateLocalMode() for thing: {}", thing.getUID()); + // LOCAL_OFFSET newOffset; + // try { + // newOffset = msg.getLocalOffset(); + // if (newOffset != null) { + // localOffset = newOffset; + // logger.debug("updateLocalMode() new localMode={}", localOffset); + // updateState(CHANNEL_LOCAL_MODE, new StringType(localOffset.getLabel())); + // } else { + // logger.warn("updateLocalMode() unrecognized local offset: {}", msg); + // } + // } catch (FrameException e) { + // logger.warn("updateSetpoint() FrameException on frame {}: {}", msg, e.getMessage()); + // } + // } + + // TODO not yet supported + // private void updateActuatorStatus(Thermoregulation msg) { + // logger.debug("updateActuatorStatus() for thing: {}", thing.getUID()); + // int actuator = msg.getActuator(); + // if (actuator == 1) { + // updateState(CHANNEL_HEATING, + // (msg.getActuatorStatus(actuator) == Thermoregulation.ACTUATOR_STATUS_ON ? OnOffType.ON + // : OnOffType.OFF)); + // } else if (actuator == 2) { + // updateState(CHANNEL_COOLING, + // (msg.getActuatorStatus(actuator) == Thermoregulation.ACTUATOR_STATUS_ON ? OnOffType.ON + // : OnOffType.OFF)); + // } else { + // logger.warn("==OWN:ThermoHandler== actuator number {} is not handled for thing: {}", actuator, + // thing.getUID()); + // } + // } + + // TODO not yet supported + // private void updateTargetTemp(Thermoregulation tmsg) { + // logger.debug("updateTargetTemp() for thing: {}", thing.getUID()); + + // try { + // Double temp = Thermoregulation.parseTemperature(tmsg); + // updateState(CHANNEL_TEMP_TARGET, new DecimalType(temp)); + // } catch (FrameException e) { + // logger.warn("updateTargetTemp() FrameException on frame {}: {}", tmsg, e.getMessage()); + // updateState(CHANNEL_TEMP_TARGET, UnDefType.UNDEF); + // } + // } + + private void updateFanCoilSpeed(Thermoregulation tmsg) { + logger.debug("updateFanCoilSpeed() for thing: {}", thing.getUID()); + + try { + FAN_COIL_SPEED speed = Thermoregulation.parseFanCoilSpeed(tmsg); + updateState(CHANNEL_FAN_SPEED, new StringType(speed.toString())); + } catch (FrameException e) { + logger.warn("updateFanCoilSpeed() FrameException on frame {}: {}", tmsg, e.getMessage()); + updateState(CHANNEL_FAN_SPEED, UnDefType.UNDEF); + } + } + + @Override + protected void refreshDevice(boolean refreshAll) { + requestChannelState(new ChannelUID("any:any:any:any")); + } + + // private static Mode whatToMode(Thermoregulation.WHAT w) { + // try { + // Mode m = Mode.UNKNOWN; + // switch (w) { + // case PROGRAM_HEATING: + // case PROGRAM_CONDITIONING: + // case PROGRAM_GENERIC: + // m = Mode.AUTO; + // break; + // case MANUAL_HEATING: + // case MANUAL_CONDITIONING: + // case MANUAL_GENERIC: + // m = Mode.MANUAL; + // break; + // case PROTECTION_HEATING: + // case PROTECTION_CONDITIONING: + // case PROTECTION_GENERIC: + // m = Mode.PROTECTION; + // break; + // case OFF_HEATING: + // case OFF_CONDITIONING: + // case OFF_GENERIC: + // m = Mode.OFF; + // break; + // case CONDITIONING: + // break; + // case GENERIC: + // break; + // case HEATING: + // break; + // case HOLIDAY_CONDITIONING: + // case HOLIDAY_GENERIC: + // case HOLIDAY_HEATING: + // default: + // break; + // } + // return m; + // } catch (Exception e) { + // return Mode.UNKNOWN; + // } + // } + + // private Thermoregulation.WHAT modeToWhat(Mode m) { + // Thermoregulation.WHAT newWhat = Thermoregulation.WHAT.GENERIC; + // try { + // switch (m) { + // case AUTO: + // if (thermoFunction == ThermoFunction.GENERIC) { + // newWhat = Thermoregulation.WHAT.PROGRAM_GENERIC; + // } else if (thermoFunction == ThermoFunction.COOL) { + // newWhat = Thermoregulation.WHAT.PROGRAM_CONDITIONING; + // } else { + // newWhat = Thermoregulation.WHAT.PROGRAM_HEATING; + // } + // break; + // case MANUAL: + // if (thermoFunction == ThermoFunction.GENERIC) { + // newWhat = Thermoregulation.WHAT.MANUAL_GENERIC; + // } else if (thermoFunction == ThermoFunction.COOL) { + // newWhat = Thermoregulation.WHAT.MANUAL_CONDITIONING; + // } else { + // newWhat = Thermoregulation.WHAT.MANUAL_HEATING; + // } + // break; + // case PROTECTION: + // if (thermoFunction == ThermoFunction.GENERIC) { + // newWhat = Thermoregulation.WHAT.PROTECTION_GENERIC; + // } else if (thermoFunction == ThermoFunction.COOL) { + // newWhat = Thermoregulation.WHAT.PROTECTION_CONDITIONING; + // } else { + // newWhat = Thermoregulation.WHAT.PROTECTION_HEATING; + // } + // break; + // case OFF: + // if (thermoFunction == ThermoFunction.GENERIC) { + // newWhat = Thermoregulation.WHAT.OFF_GENERIC; + // } else if (thermoFunction == ThermoFunction.COOL) { + // newWhat = Thermoregulation.WHAT.OFF_CONDITIONING; + // } else { + // newWhat = Thermoregulation.WHAT.OFF_HEATING; + // } + // break; + // } + + // return newWhat; + // } catch (Exception e) { + // return Thermoregulation.WHAT.GENERIC; + // } + // } +} diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetHandlerFactory.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetHandlerFactory.java index 8e1058f6a1304..0d4205d36c7f7 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetHandlerFactory.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/OpenWebNetHandlerFactory.java @@ -21,6 +21,7 @@ import org.openhab.binding.openwebnet.handler.OpenWebNetEnergyHandler; import org.openhab.binding.openwebnet.handler.OpenWebNetGenericHandler; import org.openhab.binding.openwebnet.handler.OpenWebNetLightingHandler; +import org.openhab.binding.openwebnet.handler.OpenWebNetThermoregulationHandler; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; @@ -35,7 +36,8 @@ * The {@link OpenWebNetHandlerFactory} is responsible for creating thing handlers. * * @author Massimo Valla - Initial contribution - * @author Andrea Conte - Energy management + * @author Andrea Conte - Energy management, Thermoregulation + * @author Gilberto Cocchi - Thermoregulation */ @NonNullByDefault @Component(configurationPid = "binding.openwebnet", service = ThingHandlerFactory.class) @@ -65,6 +67,9 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { } else if (OpenWebNetEnergyHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) { logger.debug("creating NEW ENERGY Handler"); return new OpenWebNetEnergyHandler(thing); + } else if (OpenWebNetThermoregulationHandler.SUPPORTED_THING_TYPES.contains(thing.getThingTypeUID())) { + logger.debug("creating NEW THERMO Handler"); + return new OpenWebNetThermoregulationHandler(thing); } logger.warn("ThingType {} is not supported by this binding", thing.getThingTypeUID()); return null; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java index 1dc4420c4f783..a4a959b69e3ed 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java @@ -41,7 +41,8 @@ * bridge/gateway * * @author Massimo Valla - Initial contribution - * @author Andrea Conte - Energy management + * @author Andrea Conte - Energy management, Thermoregulation + * @author Gilberto Cocchi - Thermoregulation */ @NonNullByDefault public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService @@ -131,6 +132,29 @@ public void newDiscoveryResult(Where where, OpenDeviceType deviceType, @Nullable break; } + // TODO: support for bus_temp_sensor + case SCS_TEMP_SENSOR: { + logger.warn("newDiscoveryResult() Unsupported channel! WHERE={}, deviceType={}", where, deviceType); + // thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_TEMP_SENSOR; + // thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_TEMP_SENSOR; + // deviceWho = Who.THERMOREGULATION; + break; + } + case SCS_THERMOSTAT: { + thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_THERMOSTAT; + thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_THERMOSTAT; + deviceWho = Who.THERMOREGULATION; + break; + } + + // TODO: support for bus_cu_thermostat + case SCS_THERMO_CENTRAL_UNIT: { + logger.warn("newDiscoveryResult() Unsupported channel! WHERE={}, deviceType={}", where, deviceType); + // thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_THERMO_CENTRAL_UNIT; + // thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_THERMO_CENTRAL_UNIT; + // deviceWho = Who.THERMOREGULATION; + break; + } case SCS_ENERGY_METER: { thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_ENERGY_METER; thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_ENERGY_METER; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml new file mode 100644 index 0000000000000..778b3f89f9265 --- /dev/null +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + A BUS/SCS zone stand-alone thermostat. BTicino models: LN4691. + + + + + + + + + + + + + + + + + + + BTicino/Legrand + BTI-LN4691 + 410/420/430 + + + ownId + + + + + Example: Zone 2 --> WHERE=2. + true + + + + + diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index 612739564ed0a..01094da101b72 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -37,6 +37,141 @@ + + + Number:Temperature + + Current temperature (read only) + Temperature + + CurrentTemperature + + + + + + + + String + + Thermo function of the thermostat (read/write) + + + + + + + + + + + + + + + + + + + + + Number:Temperature + + Setpoint temperature (read/write) + Temperature + + TargetTemperature + + + + + + String + + Set mode of the thermostat (read/write) + + + + + + + + + + + String + + Set speed of the Fan Coil (read/write) + + + + + + + + + + Number:Power From 72db07026c18e25ec92fb259e91495bd54f4354a Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Sat, 15 May 2021 23:36:30 +0200 Subject: [PATCH 02/15] [openwebnet] - add channel conditioningValve - add channel heatingValve - removed unused code and comments - replaced bridgeHandler.gateway.send() with this.send() --> better check for null Signed-off-by: Conte Andrea Signed-off-by: Massimo Valla --- .../org.openhab.binding.openwebnet/README.md | 8 +- .../OpenWebNetBindingConstants.java | 16 +- .../OpenWebNetThermoregulationHandler.java | 346 +++--------------- .../resources/OH-INF/thing/BusThermostat.xml | 8 +- .../main/resources/OH-INF/thing/channels.xml | 112 ++---- 5 files changed, 107 insertions(+), 383 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/README.md b/bundles/org.openhab.binding.openwebnet/README.md index 7da867150d72b..13206889dd9a5 100644 --- a/bundles/org.openhab.binding.openwebnet/README.md +++ b/bundles/org.openhab.binding.openwebnet/README.md @@ -124,7 +124,9 @@ For any manually added device, you must configure: - example for BUS/SCS device with WHERE address Point to Point `A=03 PL=11` on local bus --> `where="0311#4#01"` - example for ZigBee devices: `where=765432101#9`. The ID of the device (ADDR part) is usually written in hexadecimal on the device itself, for example `ID 0074CBB1`: convert to decimal (`7654321`) and add `01#9` at the end to obtain `where=765432101#9`. For 2-unit switch devices (`zb_on_off_switch2u`), last part should be `00#9`. -## Channels +## Channels + +### Lighting & Automation... Devices support some of the following channels: @@ -139,6 +141,10 @@ Devices support some of the following channels: | `function` | bus_thermostat | String | The zone set thermo function: `HEAT`, `COOL` or `GENERIC` (heating + cooling) | R/W | | `mode` | bus_thermostat | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | | `speedFanCoil` | bus_thermostat | String | The speed of the fancoil associated to the zone: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | + +### Thermo +dfgdfgf + ### Notes on channels #### `shutter` position diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java index bcceb43c5dad8..a338570f8cb5f 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java @@ -124,19 +124,13 @@ public class OpenWebNetBindingConstants { // thermo public static final String CHANNEL_TEMPERATURE = "temperature"; - // tbd public static final String CHANNEL_TEMP_TARGET = "targetTemperature"; - public static final String CHANNEL_FUNCTION = "function"; // former: "thermoFunction"; - public static final String CHANNEL_HEATING_COOLING_MODE = "thermostatMode"; // former: "heatingCoolingMode"; - // tbd public static final String CHANNEL_HEATING = "heating"; - // tbd public static final String CHANNEL_COOLING = "cooling"; - // tbd public static final String CHANNEL_ACTIVE_MODE = "activeMode"; - // tbd public static final String CHANNEL_LOCAL_MODE = "localMode"; + public static final String CHANNEL_FUNCTION = "function"; + public static final String CHANNEL_HEATING_COOLING_MODE = "thermostatMode"; public static final String CHANNEL_TEMP_SETPOINT = "setpointTemperature"; - public static final String CHANNEL_MODE = "mode"; // former: setMode - // tbd public static final String CHANNEL_ALL_TEMP_SETPOINT = "allSetpointTemperature"; - // tbd public static final String CHANNEL_ALL_SET_MODE = "allSetMode"; - // tbd public static final String CHANNEL_ALL_THERMO_FUNCTION = "allThermoFunction"; + public static final String CHANNEL_MODE = "mode"; public static final String CHANNEL_FAN_SPEED = "speedFanCoil"; + public static final String CHANNEL_CONDITIONING_VALVE = "conditioningValve"; + public static final String CHANNEL_HEATING_VALVE = "heatingValve"; // energy management public static final String CHANNEL_POWER = "power"; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index 41e48166044eb..cdb81f19f7234 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -12,8 +12,10 @@ */ package org.openhab.binding.openwebnet.handler; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_CONDITIONING_VALVE; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FAN_SPEED; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FUNCTION; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_HEATING_VALVE; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_MODE; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMPERATURE; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMP_SETPOINT; @@ -45,6 +47,7 @@ import org.openwebnet4j.message.Thermoregulation.FAN_COIL_SPEED; import org.openwebnet4j.message.Thermoregulation.FUNCTION; import org.openwebnet4j.message.Thermoregulation.OPERATION_MODE; +import org.openwebnet4j.message.Thermoregulation.VALVE_STATUS; import org.openwebnet4j.message.Thermoregulation.WHAT; import org.openwebnet4j.message.Where; import org.openwebnet4j.message.WhereThermo; @@ -65,51 +68,8 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler { private final Logger logger = LoggerFactory.getLogger(OpenWebNetThermoregulationHandler.class); - // private enum Mode { - // // TODO make it a single map and integrate it with Thermoregulation.WHAT to have automatic translation - // UNKNOWN("UNKNOWN"), - // AUTO("AUTO"), - // MANUAL("MANUAL"), - // PROTECTION("PROTECTION"), - // OFF("OFF"); - - // private final String mode; - - // Mode(final String mode) { - // this.mode = mode; - // } - - // @Override - // public String toString() { - // return mode; - // } - // } - - // private enum ThermoFunction { - // UNKNOWN(-1), - // COOL(0), - // HEAT(1), - // GENERIC(3); - - // private final int function; - - // ThermoFunction(final int f) { - // this.function = f; - // } - - // public int getValue() { - // return function; - // } - // } - public final static Set SUPPORTED_THING_TYPES = OpenWebNetBindingConstants.THERMOREGULATION_SUPPORTED_THING_TYPES; - // private boolean isCentralUnit = false; - // private Mode currentSetMode = Mode.UNKNOWN; - // private Mode currentActiveMode = Mode.UNKNOWN; - // private ThermoFunction thermoFunction = ThermoFunction.UNKNOWN; - // private Thermoregulation.LOCAL_OFFSET localOffset = Thermoregulation.LOCAL_OFFSET.NORMAL; - // 11.5 is the default setTemp used in MyHomeUP mobile app private Double currentSetPointTemp = 11.5d; @@ -117,10 +77,6 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler { public OpenWebNetThermoregulationHandler(Thing thing) { super(thing); - // TODO not yet supported - // if (OpenWebNetBindingConstants.THING_TYPE_BUS_THERMO_CENTRAL_UNIT.equals(thing.getThingTypeUID())) { - // isCentralUnit = true; - // } } @Override @@ -131,14 +87,18 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { if (bridgeStatusInfo.getStatus().equals(ThingStatus.ONLINE)) { logger.debug("bridgeStatusChanged() thing={}", thing.getUID()); - try { - // request single channels updates - bridgeHandler.gateway.send(Thermoregulation.requestTemperature(deviceWhere.value())); - bridgeHandler.gateway.send(Thermoregulation.requestSetPointTemperature(deviceWhere.value())); - bridgeHandler.gateway.send(Thermoregulation.requestFanCoilSpeed(deviceWhere.value())); - bridgeHandler.gateway.send(Thermoregulation.requestMode(deviceWhere.value())); - } catch (OWNException e) { - logger.error("bridgeStatusChanged() OWNException thingUID={}: {}", thing.getUID(), e.getMessage()); + if (deviceWhere != null) { + String w = deviceWhere.value(); + try { + // request single channels updates + send(Thermoregulation.requestTemperature(w)); + send(Thermoregulation.requestSetPointTemperature(w)); + send(Thermoregulation.requestFanCoilSpeed(w)); + send(Thermoregulation.requestMode(w)); + send(Thermoregulation.requestValveStatus(w)); + } catch (OWNException e) { + logger.error("bridgeStatusChanged() OWNException thingUID={}: {}", thing.getUID(), e.getMessage()); + } } } } @@ -146,15 +106,9 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { @Override protected void handleChannelCommand(ChannelUID channel, Command command) { switch (channel.getId()) { - // TODO case CHANNEL_ALL_TEMP_SETPOINT: case CHANNEL_TEMP_SETPOINT: handleSetpointCommand(command); break; - // TODO case CHANNEL_ALL_SET_MODE: - // TODO case CHANNEL_SET_MODE: - // handleModeCommand(command); - // logger.trace("handleChannelCommand() Unsupported handleModeCommand! {}", channel.getId()); - // break; case CHANNEL_FUNCTION: handleFunction(command); break; @@ -174,18 +128,20 @@ protected void handleChannelCommand(ChannelUID channel, Command command) { protected void requestChannelState(ChannelUID channel) { logger.debug("requestChannelState() thingUID={} channel={}", thing.getUID(), channel.getId()); - try { - // this works for bus_thermostat, not for central unit - // bridgeHandler.gateway.send(Thermoregulation.requestStatus(deviceWhere.value())); - - // for bus_thermostat request single channels updates - bridgeHandler.gateway.send(Thermoregulation.requestTemperature(deviceWhere.value())); - bridgeHandler.gateway.send(Thermoregulation.requestSetPointTemperature(deviceWhere.value())); - bridgeHandler.gateway.send(Thermoregulation.requestFanCoilSpeed(deviceWhere.value())); - bridgeHandler.gateway.send(Thermoregulation.requestMode(deviceWhere.value())); - } catch (OWNException e) { - logger.error("requestChannelState() OWNException thingUID={} channel={}: {}", thing.getUID(), - channel.getId(), e.getMessage()); + if (deviceWhere != null) { + String w = deviceWhere.value(); + + try { + // for bus_thermostat request single channels updates + send(Thermoregulation.requestTemperature(w)); + send(Thermoregulation.requestSetPointTemperature(w)); + send(Thermoregulation.requestFanCoilSpeed(w)); + send(Thermoregulation.requestMode(w)); + send(Thermoregulation.requestValveStatus(w)); + } catch (OWNException e) { + logger.error("requestChannelState() OWNException thingUID={} channel={}: {}", thing.getUID(), + channel.getId(), e.getMessage()); + } } } @@ -206,7 +162,7 @@ private void handleSetFanSpeedCommand(Command command) { FAN_COIL_SPEED speed = FAN_COIL_SPEED.valueOf(command.toString()); try { - bridgeHandler.gateway.send(Thermoregulation.requestWriteFanCoilSpeed(deviceWhere.value(), speed)); + send(Thermoregulation.requestWriteFanCoilSpeed(deviceWhere.value(), speed)); } catch (OWNException e) { logger.warn("handleSetFanSpeedCommand() {}", e.getMessage()); } @@ -230,10 +186,8 @@ private void handleSetpointCommand(Command command) { } try { - Thermoregulation mm = Thermoregulation.requestWriteSetpointTemperature(deviceWhere.value(), - value.floatValue(), currentFunction); - - bridgeHandler.gateway.send(mm); + send(Thermoregulation.requestWriteSetpointTemperature(deviceWhere.value(), value.floatValue(), + currentFunction)); } catch (MalformedFrameException | OWNException e) { logger.warn("handleSetpointCommand() {}", e.getMessage()); } @@ -253,7 +207,7 @@ private void handleMode(Command command) { else logger.debug("handleMode() mode={} function={}", mode.toString(), currentFunction.toString()); - bridgeHandler.gateway.send(Thermoregulation.requestWriteMode(deviceWhere.value(), mode, currentFunction, + send(Thermoregulation.requestWriteMode(deviceWhere.value(), mode, currentFunction, currentSetPointTemp)); } catch (OWNException e) { logger.warn("handleMode() {}", e.getMessage()); @@ -273,7 +227,7 @@ private void handleFunction(Command command) { FUNCTION function = FUNCTION.valueOf(((StringType) command).toString()); logger.debug("handleFunction() mode={}", function.toString()); - bridgeHandler.gateway.send(Thermoregulation.requestWriteFunction(deviceWhere.value(), function)); + send(Thermoregulation.requestWriteFunction(deviceWhere.value(), function)); } catch (OWNException e) { logger.warn("handleFunction() {}", e.getMessage()); } @@ -283,34 +237,6 @@ private void handleFunction(Command command) { } } - // TODO not yet supported - // private void handleModeCommand(Command command) { - // logger.debug("handleModeCommand() (command={})", command); - // if (command instanceof StringType) { - // Thermoregulation.WHAT modeWhat = null; - // try { - // Mode mode = Mode.valueOf(((StringType) command).toString()); - // modeWhat = modeToWhat(mode); - // } catch (IllegalArgumentException e) { - // logger.warn("Cannot handle command {} for thing {}. Exception: {}", command, getThing().getUID(), - // e.getMessage()); - // return; - // } - // logger.debug("handleModeCommand() modeWhat={}", modeWhat); - // if (modeWhat != null) { - // try { - // bridgeHandler.gateway.send(Thermoregulation.requestWriteSetMode(deviceWhere.value(), modeWhat)); - // } catch (MalformedFrameException | OWNException e) { - // logger.warn("handleModeCommand() {}", e.getMessage()); - // } - // } else { - // logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); - // } - // } else { - // logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); - // } - // } - private QuantityType commandToQuantityType(Command command, Unit unit) { return new QuantityType(command.toFullString()); } @@ -329,14 +255,8 @@ protected void handleMessage(BaseOpenMessage msg) { } else if (msg.getDim() == Thermoregulation.DIM.TEMP_SETPOINT || msg.getDim() == Thermoregulation.DIM.COMPLETE_PROBE_STATUS) { updateSetpoint((Thermoregulation) msg); - - // TODO not applicable for bus_thermostat - // } else if (msg.getDim() == Thermoregulation.DIM.OFFSET) { - // updateLocalMode((Thermoregulation) msg); - // } else if (msg.getDim() == Thermoregulation.DIM.ACTUATOR_STATUS) { - // updateActuatorStatus((Thermoregulation) msg); - // } else if (msg.getDim() == Thermoregulation.DIM.TEMP_TARGET) { - // updateTargetTemp((Thermoregulation) msg); + } else if (msg.getDim() == Thermoregulation.DIM.VALVES_STATUS) { + updateValveStatus((Thermoregulation) msg); } else if (msg.getDim() == Thermoregulation.DIM.FAN_COIL_SPEED) { updateFanCoilSpeed((Thermoregulation) msg); } else { @@ -346,40 +266,6 @@ protected void handleMessage(BaseOpenMessage msg) { } } - // private void updateMode(Thermoregulation tmsg) { - // logger.debug("updateMode() for thing: {} msg={}", thing.getUID(), tmsg); - - // try { - // OPERATION_MODE mode = Thermoregulation.parseMode(tmsg); - - // if (mode == OPERATION_MODE.MANUAL) - // logger.debug("updateMode() mode={} setPointTemp={}°", mode.toString(), currentSetPointTemp); - // else - // logger.debug("updateMode() mode={}", mode.toString()); - - // updateState(CHANNEL_MODE, new StringType(mode.toString())); - // } catch (FrameException e) { - // logger.warn("updateMode() FrameException on frame {}: {}", tmsg, e.getMessage()); - // // do not update channel state, simply skip wrong message - // } - // } - - // private void updateFunction(Thermoregulation tmsg) { - // logger.debug("updateFunction() for thing: {} msg={}", thing.getUID(), tmsg); - - // try { - // FUNCTION function = Thermoregulation.parseFunction(tmsg); - // logger.debug("updateFunction() FUNCTION={}", function.toString()); - // updateState(CHANNEL_FUNCTION, new StringType(function.toString())); - - // // store current function - // currentFunction = function; - // } catch (FrameException e) { - // logger.warn("updateFunction() FrameException on frame {}: {}", tmsg, e.getMessage()); - // // do not update channel state, simply skip wrong message - // } - // } - private void updateModeAndFunction(Thermoregulation tmsg) { logger.debug("updateModeAndFunction() for thing: {} msg={}", thing.getUID(), tmsg); @@ -432,10 +318,6 @@ private void updateSetpoint(Thermoregulation tmsg) { logger.debug("updateSetpoint() for thing: {}", thing.getUID()); String channelID = CHANNEL_TEMP_SETPOINT; - // TODO not yet supported - // if (isCentralUnit) - // channelID = CHANNEL_ALL_TEMP_SETPOINT; - try { Double temp = Thermoregulation.parseTemperature(tmsg); updateState(channelID, new DecimalType(temp)); @@ -448,55 +330,6 @@ private void updateSetpoint(Thermoregulation tmsg) { } } - // TODO not yet supported - // private void updateLocalMode(Thermoregulation msg) { - // logger.debug("updateLocalMode() for thing: {}", thing.getUID()); - // LOCAL_OFFSET newOffset; - // try { - // newOffset = msg.getLocalOffset(); - // if (newOffset != null) { - // localOffset = newOffset; - // logger.debug("updateLocalMode() new localMode={}", localOffset); - // updateState(CHANNEL_LOCAL_MODE, new StringType(localOffset.getLabel())); - // } else { - // logger.warn("updateLocalMode() unrecognized local offset: {}", msg); - // } - // } catch (FrameException e) { - // logger.warn("updateSetpoint() FrameException on frame {}: {}", msg, e.getMessage()); - // } - // } - - // TODO not yet supported - // private void updateActuatorStatus(Thermoregulation msg) { - // logger.debug("updateActuatorStatus() for thing: {}", thing.getUID()); - // int actuator = msg.getActuator(); - // if (actuator == 1) { - // updateState(CHANNEL_HEATING, - // (msg.getActuatorStatus(actuator) == Thermoregulation.ACTUATOR_STATUS_ON ? OnOffType.ON - // : OnOffType.OFF)); - // } else if (actuator == 2) { - // updateState(CHANNEL_COOLING, - // (msg.getActuatorStatus(actuator) == Thermoregulation.ACTUATOR_STATUS_ON ? OnOffType.ON - // : OnOffType.OFF)); - // } else { - // logger.warn("==OWN:ThermoHandler== actuator number {} is not handled for thing: {}", actuator, - // thing.getUID()); - // } - // } - - // TODO not yet supported - // private void updateTargetTemp(Thermoregulation tmsg) { - // logger.debug("updateTargetTemp() for thing: {}", thing.getUID()); - - // try { - // Double temp = Thermoregulation.parseTemperature(tmsg); - // updateState(CHANNEL_TEMP_TARGET, new DecimalType(temp)); - // } catch (FrameException e) { - // logger.warn("updateTargetTemp() FrameException on frame {}: {}", tmsg, e.getMessage()); - // updateState(CHANNEL_TEMP_TARGET, UnDefType.UNDEF); - // } - // } - private void updateFanCoilSpeed(Thermoregulation tmsg) { logger.debug("updateFanCoilSpeed() for thing: {}", thing.getUID()); @@ -509,98 +342,25 @@ private void updateFanCoilSpeed(Thermoregulation tmsg) { } } + private void updateValveStatus(Thermoregulation tmsg) { + logger.debug("updateValveStatus() for thing: {}", thing.getUID()); + + try { + VALVE_STATUS cv = Thermoregulation.parseValveStatus(tmsg, WHAT.CONDITIONING); + updateState(CHANNEL_CONDITIONING_VALVE, new StringType(cv.toString())); + + VALVE_STATUS hv = Thermoregulation.parseValveStatus(tmsg, WHAT.HEATING); + updateState(CHANNEL_HEATING_VALVE, new StringType(hv.toString())); + } catch (FrameException e) { + logger.warn("updateValveStatus() FrameException on frame {}: {}", tmsg, e.getMessage()); + + updateState(CHANNEL_CONDITIONING_VALVE, UnDefType.UNDEF); + updateState(CHANNEL_HEATING_VALVE, UnDefType.UNDEF); + } + } + @Override protected void refreshDevice(boolean refreshAll) { requestChannelState(new ChannelUID("any:any:any:any")); } - - // private static Mode whatToMode(Thermoregulation.WHAT w) { - // try { - // Mode m = Mode.UNKNOWN; - // switch (w) { - // case PROGRAM_HEATING: - // case PROGRAM_CONDITIONING: - // case PROGRAM_GENERIC: - // m = Mode.AUTO; - // break; - // case MANUAL_HEATING: - // case MANUAL_CONDITIONING: - // case MANUAL_GENERIC: - // m = Mode.MANUAL; - // break; - // case PROTECTION_HEATING: - // case PROTECTION_CONDITIONING: - // case PROTECTION_GENERIC: - // m = Mode.PROTECTION; - // break; - // case OFF_HEATING: - // case OFF_CONDITIONING: - // case OFF_GENERIC: - // m = Mode.OFF; - // break; - // case CONDITIONING: - // break; - // case GENERIC: - // break; - // case HEATING: - // break; - // case HOLIDAY_CONDITIONING: - // case HOLIDAY_GENERIC: - // case HOLIDAY_HEATING: - // default: - // break; - // } - // return m; - // } catch (Exception e) { - // return Mode.UNKNOWN; - // } - // } - - // private Thermoregulation.WHAT modeToWhat(Mode m) { - // Thermoregulation.WHAT newWhat = Thermoregulation.WHAT.GENERIC; - // try { - // switch (m) { - // case AUTO: - // if (thermoFunction == ThermoFunction.GENERIC) { - // newWhat = Thermoregulation.WHAT.PROGRAM_GENERIC; - // } else if (thermoFunction == ThermoFunction.COOL) { - // newWhat = Thermoregulation.WHAT.PROGRAM_CONDITIONING; - // } else { - // newWhat = Thermoregulation.WHAT.PROGRAM_HEATING; - // } - // break; - // case MANUAL: - // if (thermoFunction == ThermoFunction.GENERIC) { - // newWhat = Thermoregulation.WHAT.MANUAL_GENERIC; - // } else if (thermoFunction == ThermoFunction.COOL) { - // newWhat = Thermoregulation.WHAT.MANUAL_CONDITIONING; - // } else { - // newWhat = Thermoregulation.WHAT.MANUAL_HEATING; - // } - // break; - // case PROTECTION: - // if (thermoFunction == ThermoFunction.GENERIC) { - // newWhat = Thermoregulation.WHAT.PROTECTION_GENERIC; - // } else if (thermoFunction == ThermoFunction.COOL) { - // newWhat = Thermoregulation.WHAT.PROTECTION_CONDITIONING; - // } else { - // newWhat = Thermoregulation.WHAT.PROTECTION_HEATING; - // } - // break; - // case OFF: - // if (thermoFunction == ThermoFunction.GENERIC) { - // newWhat = Thermoregulation.WHAT.OFF_GENERIC; - // } else if (thermoFunction == ThermoFunction.COOL) { - // newWhat = Thermoregulation.WHAT.OFF_CONDITIONING; - // } else { - // newWhat = Thermoregulation.WHAT.OFF_HEATING; - // } - // break; - // } - - // return newWhat; - // } catch (Exception e) { - // return Thermoregulation.WHAT.GENERIC; - // } - // } } diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml index 778b3f89f9265..d22ff5a18b670 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml @@ -16,12 +16,8 @@ - - - - - - + + diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index 01094da101b72..afca7993b37a0 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -49,14 +49,6 @@ - - String @@ -70,70 +62,6 @@ - - - - - - - - - - Number:Temperature @@ -172,6 +100,46 @@ + + String + + Conditioning Valve status (read only) + + + + + + + + + + + + + + + + + + String + + Heating Valve status (read only) + + + + + + + + + + + + + + + + Number:Power From 86451d297d2e6f02413aed22611e3158fbbf204c Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Sun, 16 May 2021 11:46:28 +0200 Subject: [PATCH 03/15] [openwebnet] added actuator channel (DIM=20) Signed-off-by: Conte Andrea Signed-off-by: Massimo Valla --- .../OpenWebNetBindingConstants.java | 1 + .../OpenWebNetThermoregulationHandler.java | 24 +++++++++++++++---- .../resources/OH-INF/thing/BusThermostat.xml | 1 + .../main/resources/OH-INF/thing/channels.xml | 20 ++++++++++++++++ 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java index a338570f8cb5f..9c095a5b3c2de 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java @@ -131,6 +131,7 @@ public class OpenWebNetBindingConstants { public static final String CHANNEL_FAN_SPEED = "speedFanCoil"; public static final String CHANNEL_CONDITIONING_VALVE = "conditioningValve"; public static final String CHANNEL_HEATING_VALVE = "heatingValve"; + public static final String CHANNEL_ACTUATOR = "actuator"; // energy management public static final String CHANNEL_POWER = "power"; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index cdb81f19f7234..65344f2680d99 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.openwebnet.handler; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_ACTUATOR; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_CONDITIONING_VALVE; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FAN_SPEED; import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FUNCTION; @@ -47,7 +48,7 @@ import org.openwebnet4j.message.Thermoregulation.FAN_COIL_SPEED; import org.openwebnet4j.message.Thermoregulation.FUNCTION; import org.openwebnet4j.message.Thermoregulation.OPERATION_MODE; -import org.openwebnet4j.message.Thermoregulation.VALVE_STATUS; +import org.openwebnet4j.message.Thermoregulation.VALVE_OR_ACTUATOR_STATUS; import org.openwebnet4j.message.Thermoregulation.WHAT; import org.openwebnet4j.message.Where; import org.openwebnet4j.message.WhereThermo; @@ -89,7 +90,7 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { if (deviceWhere != null) { String w = deviceWhere.value(); - try { + try { // request single channels updates send(Thermoregulation.requestTemperature(w)); send(Thermoregulation.requestSetPointTemperature(w)); @@ -257,6 +258,8 @@ protected void handleMessage(BaseOpenMessage msg) { updateSetpoint((Thermoregulation) msg); } else if (msg.getDim() == Thermoregulation.DIM.VALVES_STATUS) { updateValveStatus((Thermoregulation) msg); + } else if (msg.getDim() == Thermoregulation.DIM.ACTUATOR_STATUS) { + updateActuatorStatus((Thermoregulation) msg); } else if (msg.getDim() == Thermoregulation.DIM.FAN_COIL_SPEED) { updateFanCoilSpeed((Thermoregulation) msg); } else { @@ -346,10 +349,10 @@ private void updateValveStatus(Thermoregulation tmsg) { logger.debug("updateValveStatus() for thing: {}", thing.getUID()); try { - VALVE_STATUS cv = Thermoregulation.parseValveStatus(tmsg, WHAT.CONDITIONING); + VALVE_OR_ACTUATOR_STATUS cv = Thermoregulation.parseValveStatus(tmsg, WHAT.CONDITIONING); updateState(CHANNEL_CONDITIONING_VALVE, new StringType(cv.toString())); - VALVE_STATUS hv = Thermoregulation.parseValveStatus(tmsg, WHAT.HEATING); + VALVE_OR_ACTUATOR_STATUS hv = Thermoregulation.parseValveStatus(tmsg, WHAT.HEATING); updateState(CHANNEL_HEATING_VALVE, new StringType(hv.toString())); } catch (FrameException e) { logger.warn("updateValveStatus() FrameException on frame {}: {}", tmsg, e.getMessage()); @@ -359,6 +362,19 @@ private void updateValveStatus(Thermoregulation tmsg) { } } + private void updateActuatorStatus(Thermoregulation tmsg) { + logger.debug("updateActuatorStatus() for thing: {}", thing.getUID()); + + try { + VALVE_OR_ACTUATOR_STATUS hv = Thermoregulation.parseActuatorStatus(tmsg); + updateState(CHANNEL_ACTUATOR, new StringType(hv.toString())); + } catch (FrameException e) { + logger.warn("updateActuatorStatus() FrameException on frame {}: {}", tmsg, e.getMessage()); + + updateState(CHANNEL_ACTUATOR, UnDefType.UNDEF); + } + } + @Override protected void refreshDevice(boolean refreshAll) { requestChannelState(new ChannelUID("any:any:any:any")); diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml index d22ff5a18b670..d1c46d24212ac 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml @@ -18,6 +18,7 @@ + diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index afca7993b37a0..71795b25dd002 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -140,6 +140,26 @@ + + String + + Actuator status (read only) + + + + + + + + + + + + + + + + Number:Power From 8f53caa20b731c4f3368f50d74da44fa0c115dda Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Mon, 17 May 2021 18:02:53 +0200 Subject: [PATCH 04/15] [openwebnet] - handled refreshDevice() request - added requestActuatorStatus() inside initialize() and bridgeStatusUpdate() Signed-off-by: Conte Andrea Signed-off-by: Massimo Valla --- .../OpenWebNetThermoregulationHandler.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index 65344f2680d99..e2f087bde5b3e 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -97,6 +97,7 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { send(Thermoregulation.requestFanCoilSpeed(w)); send(Thermoregulation.requestMode(w)); send(Thermoregulation.requestValveStatus(w)); + send(Thermoregulation.requestActuatorStatus(w)); } catch (OWNException e) { logger.error("bridgeStatusChanged() OWNException thingUID={}: {}", thing.getUID(), e.getMessage()); } @@ -139,6 +140,7 @@ protected void requestChannelState(ChannelUID channel) { send(Thermoregulation.requestFanCoilSpeed(w)); send(Thermoregulation.requestMode(w)); send(Thermoregulation.requestValveStatus(w)); + send(Thermoregulation.requestActuatorStatus(w)); } catch (OWNException e) { logger.error("requestChannelState() OWNException thingUID={} channel={}: {}", thing.getUID(), channel.getId(), e.getMessage()); @@ -377,6 +379,20 @@ private void updateActuatorStatus(Thermoregulation tmsg) { @Override protected void refreshDevice(boolean refreshAll) { - requestChannelState(new ChannelUID("any:any:any:any")); + if (deviceWhere != null) { + String w = deviceWhere.value(); + + try { + // for bus_thermostat request single channels updates + send(Thermoregulation.requestTemperature(w)); + send(Thermoregulation.requestSetPointTemperature(w)); + send(Thermoregulation.requestFanCoilSpeed(w)); + send(Thermoregulation.requestMode(w)); + send(Thermoregulation.requestValveStatus(w)); + send(Thermoregulation.requestActuatorStatus(w)); + } catch (OWNException e) { + logger.error("refreshDevice() where='{}' --> OWNException {}", w, e.getMessage()); + } + } } } From a0526290b8ff986f71c7bdfdadace32c1599dc51 Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Tue, 18 May 2021 15:09:14 +0200 Subject: [PATCH 05/15] [openwebnet] updated README Signed-off-by: Conte Andrea Signed-off-by: Massimo Valla --- .../org.openhab.binding.openwebnet/README.md | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/README.md b/bundles/org.openhab.binding.openwebnet/README.md index 13206889dd9a5..fecec1afe0056 100644 --- a/bundles/org.openhab.binding.openwebnet/README.md +++ b/bundles/org.openhab.binding.openwebnet/README.md @@ -42,7 +42,7 @@ The following Things and OpenWebNet `WHOs` are supported: | Gateway Management | `13` | `bus_gateway` | Any IP gateway supporting OpenWebNet protocol should work (e.g. F454 / MyHOMEServer1 / MH202 / F455 / MH200N, ...) | Successfully tested: F454, MyHOMEServer1, MyHOME_Screen10, F455, F452, F453AV, MH201, MH202, MH200N. Some connection stability issues/gateway resets reported with MH202 | | Lighting | `1` | `bus_on_off_switch`, `bus_dimmer` | BUS switches and dimmers | Successfully tested: F411/2, F411/4, F411U2, F422, F429. Some discovery issues reported with F429 (DALI Dimmers) | | Automation | `2` | `bus_automation` | BUS roller shutters, with position feedback and auto-calibration | Successfully tested: LN4672M2 | -| Temperature Control | `4` | `bus_thermostat` | Zones room thermostats (stand-alone thermostat) | Successfully tested: H/LN4691 | +| Temperature Control | `4` | `bus_thermostat` | Zones room thermostats (stand-alone thermostat). Please note that central unit (4 or 99 zones) is not yet supported. See [Channels - Thermo](#Thermo) for more details. | Successfully tested: H/LN4691 | | Energy Management | `18` | `bus_energy_meter` | Energy Management | Successfully tested: F520, F521 | ### For ZigBee (Radio) @@ -126,9 +126,7 @@ For any manually added device, you must configure: ## Channels -### Lighting & Automation... - -Devices support some of the following channels: +### Lighting, Automation and Power meter | Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | |------------------------------------------------|----------------|---------------|---------------------------------------------------------|:----------:| @@ -136,14 +134,21 @@ Devices support some of the following channels: | `brightness` | bus_dimmer, zb_dimmer | Dimmer | To adjust the brightness value (Percent, `ON`, `OFF`) | R/W | | `shutter` | bus_automation | Rollershutter | To activate roller shutters (`UP`, `DOWN`, `STOP`, Percent - [see Shutter position](#shutter-position)) | R/W | | `power` | bus_energy_meter, zb_automation | Number:Power | The current active power usage from Energy Meter | R | -| `temperature` | bus_thermostat | Number:Temperature | The zone currently sensed temperature (°C) | R | -| `setpointTemperature` | bus_thermostat | Number:Temperature | The zone setpoint temperature (°C) | R/W | -| `function` | bus_thermostat | String | The zone set thermo function: `HEAT`, `COOL` or `GENERIC` (heating + cooling) | R/W | -| `mode` | bus_thermostat | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | -| `speedFanCoil` | bus_thermostat | String | The speed of the fancoil associated to the zone: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | ### Thermo -dfgdfgf +Currently only stand-alone thermostats are supported (like [LN4691](https://catalogo.bticino.it/BTI-LN4691-IT)) and the specific thing `bus_thermostat` was created to manage them. + +| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | Advanced | +|------------------------------------------------|----------------|---------------|---------------------------------------------------------|:----------:|:----------:| +| `temperature` | bus_thermostat | Number:Temperature | The zone currently sensed temperature (°C) | R | N | +| `setpointTemperature` | bus_thermostat | Number:Temperature | The zone setpoint temperature (°C) | R/W | N | +| `function` | bus_thermostat | String | The zone set thermo function: `COOLING`, `HEATING` or `GENERIC` (heating + cooling) | R/W | N | +| `mode` | bus_thermostat | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | N | +| `speedFanCoil` | bus_thermostat | String | The speed of the fancoil associated to the zone: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | N | +| `actuator` | bus_thermostat | String | The status of the actuator(s) associated to the zone: `0` OFF, `1` ON, `2` Opened, `3` Closed, `4` Stop, `5` OFF Fan Coil, `6` ON speed 1, `7` ON speed 2, `8` ON speed 3, `14` Standby Fan Coil | R | Y | +| `heatingValve` | bus_thermostat | String | The status of the heating valve(s) associated to the zone: `0` OFF, `1` ON, `2` Opened, `3` Closed, `4` Stop, `5` OFF Fan Coil, `6` ON speed 1, `7` ON speed 2, `8` ON speed 3, `14` Standby Fan Coil | R | Y | +| `conditioningValve` | bus_thermostat | String | The status of the conditioning valve(s) associated to the zone: `0` OFF, `1` ON, `2` Opened, `3` Closed, `4` Stop, `5` OFF Fan Coil, `6` ON speed 1, `7` ON speed 2, `8` ON speed 3, `14` Standby Fan Coil | R | Y | + ### Notes on channels From 9b28cc9843034842978f24cbc7f4d531483e882b Mon Sep 17 00:00:00 2001 From: Massimo Valla Date: Sat, 22 May 2021 13:47:41 +0200 Subject: [PATCH 06/15] [openwebnet] Added bus_temp_sensor thing with discovery. Updated conditioning/heatingValve and actutor channels values to strings. Updated and cleaned-up README Signed-off-by: Massimo Valla --- .../org.openhab.binding.openwebnet/README.md | 82 ++++++----- .../OpenWebNetBindingConstants.java | 14 +- .../OpenWebNetThermoregulationHandler.java | 134 +++++++++--------- .../OpenWebNetDeviceDiscoveryService.java | 16 +-- .../resources/OH-INF/thing/BusTempSensor.xml | 36 +++++ .../resources/OH-INF/thing/BusThermostat.xml | 3 +- .../main/resources/OH-INF/thing/channels.xml | 62 ++++---- 7 files changed, 183 insertions(+), 164 deletions(-) create mode 100644 bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml diff --git a/bundles/org.openhab.binding.openwebnet/README.md b/bundles/org.openhab.binding.openwebnet/README.md index fecec1afe0056..1f1c5c4a3619a 100644 --- a/bundles/org.openhab.binding.openwebnet/README.md +++ b/bundles/org.openhab.binding.openwebnet/README.md @@ -37,21 +37,21 @@ The following Things and OpenWebNet `WHOs` are supported: ### For BUS/SCS -| Category | WHO | Thing Type IDs | Description | Status | -| -------------------- | :----------: | :------------------------------------------: | -------------------------------------------------------------- | ---------------- | -| Gateway Management | `13` | `bus_gateway` | Any IP gateway supporting OpenWebNet protocol should work (e.g. F454 / MyHOMEServer1 / MH202 / F455 / MH200N, ...) | Successfully tested: F454, MyHOMEServer1, MyHOME_Screen10, F455, F452, F453AV, MH201, MH202, MH200N. Some connection stability issues/gateway resets reported with MH202 | -| Lighting | `1` | `bus_on_off_switch`, `bus_dimmer` | BUS switches and dimmers | Successfully tested: F411/2, F411/4, F411U2, F422, F429. Some discovery issues reported with F429 (DALI Dimmers) | -| Automation | `2` | `bus_automation` | BUS roller shutters, with position feedback and auto-calibration | Successfully tested: LN4672M2 | -| Temperature Control | `4` | `bus_thermostat` | Zones room thermostats (stand-alone thermostat). Please note that central unit (4 or 99 zones) is not yet supported. See [Channels - Thermo](#Thermo) for more details. | Successfully tested: H/LN4691 | -| Energy Management | `18` | `bus_energy_meter` | Energy Management | Successfully tested: F520, F521 | +| Category | WHO | Thing Type IDs | Description | Status | +| -------------------- | :----------: | :---------------------------------: | ---------------------------------------------------------------- | ---------------- | +| Gateway Management | `13` | `bus_gateway` | Any IP gateway supporting OpenWebNet protocol should work (e.g. F454 / MyHOMEServer1 / MH202 / F455 / MH200N, ...) | Successfully tested: F454, MyHOMEServer1, MyHOME_Screen10, F455, F452, F453AV, MH201, MH202, MH200N. Some connection stability issues/gateway resets reported with MH202 | +| Lighting | `1` | `bus_on_off_switch`, `bus_dimmer` | BUS switches and dimmers | Successfully tested: F411/2, F411/4, F411U2, F422, F429. Some discovery issues reported with F429 (DALI Dimmers) | +| Automation | `2` | `bus_automation` | BUS roller shutters, with position feedback and auto-calibration | Successfully tested: LN4672M2 | +| Temperature Control | `4` | `bus_thermostat`, `bus_temp_sensor` | Zones room thermostats (stand-alone) and external wireless temperature sensors. Please note that Central Unit configurations (4 or 99 zones) are not yet supported. See [Channels - Thermo](#thermo-channels) for more details. | Successfully tested: H/LN4691; external sensors: L/N/NT4577 + 3455 | +| Energy Management | `18` | `bus_energy_meter` | Energy Management | Successfully tested: F520, F521 | ### For ZigBee (Radio) | Category | WHO | Thing Type IDs | Description | Status | | -------------------- | :----: | :-------------------------------: | :-------------------------------------------------------------------: | ------------------------------------ | -| Gateway Management | `13` | `zb_gateway` | ZigBee USB Gateway (models: BTI-3578 / LG 088328) | Tested: BTI-3578 and LG 088328 | -| Lighting | `1` | `zb_dimmer`, `zb_on_off_switch`, `zb_on_off_switch2u` | ZigBee dimmers, switches and 2-unit switches | Tested: BTI-4591, BTI-3584, BTI-4585 | -| Automation | `2` | `zb_automation` | ZigBee roller shutters | | +| Gateway Management | `13` | `zb_gateway` | ZigBee USB Gateway (models: BTI-3578 / LG 088328) | Tested: BTI-3578 and LG 088328 | +| Lighting | `1` | `zb_dimmer`, `zb_on_off_switch`, `zb_on_off_switch2u` | ZigBee dimmers, switches and 2-unit switches | Tested: BTI-4591, BTI-3584, BTI-4585 | +| Automation | `2` | `zb_automation` | ZigBee roller shutters | | ## Discovery @@ -122,32 +122,34 @@ For any manually added device, you must configure: - the `where` config parameter (`OpenWebNet Device Address`): - example for BUS/SCS device with WHERE address Point to Point `A=2 PL=4` --> `where="24"` - example for BUS/SCS device with WHERE address Point to Point `A=03 PL=11` on local bus --> `where="0311#4#01"` + - example for BUS/SCS thermo Zones: `Zone=1` --> `where="1"`; external sensor `5` --> `where="500"` - example for ZigBee devices: `where=765432101#9`. The ID of the device (ADDR part) is usually written in hexadecimal on the device itself, for example `ID 0074CBB1`: convert to decimal (`7654321`) and add `01#9` at the end to obtain `where=765432101#9`. For 2-unit switch devices (`zb_on_off_switch2u`), last part should be `00#9`. ## Channels -### Lighting, Automation and Power meter +### Lighting, Automation and Power meter channels -| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | -|------------------------------------------------|----------------|---------------|---------------------------------------------------------|:----------:| -| `switch` or `switch_01`/`02` for ZigBee | bus_on_off_switch, zb_on_off_switch, zb_on_off_switch2u | Switch | To switch the device `ON` and `OFF` | R/W | -| `brightness` | bus_dimmer, zb_dimmer | Dimmer | To adjust the brightness value (Percent, `ON`, `OFF`) | R/W | -| `shutter` | bus_automation | Rollershutter | To activate roller shutters (`UP`, `DOWN`, `STOP`, Percent - [see Shutter position](#shutter-position)) | R/W | -| `power` | bus_energy_meter, zb_automation | Number:Power | The current active power usage from Energy Meter | R | +| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | +| ---------------------------------------- | ------------------------------------------------------------- | ------------- | ----------------------------------------------------- | :--------: | +| `switch` or `switch_01`/`02` for ZigBee | `bus_on_off_switch`, `zb_on_off_switch`, `zb_on_off_switch2u` | Switch | To switch the device `ON` and `OFF` | R/W | +| `brightness` | `bus_dimmer`, `zb_dimmer` | Dimmer | To adjust the brightness value (Percent, `ON`, `OFF`) | R/W | +| `shutter` | `bus_automation` | Rollershutter | To activate roller shutters (`UP`, `DOWN`, `STOP`, Percent - [see Shutter position](#shutter-position)) | R/W | +| `power` | `bus_energy_meter` | Number:Power | The current active power usage from Energy Meter | R | + +### Thermo channels -### Thermo Currently only stand-alone thermostats are supported (like [LN4691](https://catalogo.bticino.it/BTI-LN4691-IT)) and the specific thing `bus_thermostat` was created to manage them. -| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | Advanced | -|------------------------------------------------|----------------|---------------|---------------------------------------------------------|:----------:|:----------:| -| `temperature` | bus_thermostat | Number:Temperature | The zone currently sensed temperature (°C) | R | N | -| `setpointTemperature` | bus_thermostat | Number:Temperature | The zone setpoint temperature (°C) | R/W | N | -| `function` | bus_thermostat | String | The zone set thermo function: `COOLING`, `HEATING` or `GENERIC` (heating + cooling) | R/W | N | -| `mode` | bus_thermostat | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | N | -| `speedFanCoil` | bus_thermostat | String | The speed of the fancoil associated to the zone: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | N | -| `actuator` | bus_thermostat | String | The status of the actuator(s) associated to the zone: `0` OFF, `1` ON, `2` Opened, `3` Closed, `4` Stop, `5` OFF Fan Coil, `6` ON speed 1, `7` ON speed 2, `8` ON speed 3, `14` Standby Fan Coil | R | Y | -| `heatingValve` | bus_thermostat | String | The status of the heating valve(s) associated to the zone: `0` OFF, `1` ON, `2` Opened, `3` Closed, `4` Stop, `5` OFF Fan Coil, `6` ON speed 1, `7` ON speed 2, `8` ON speed 3, `14` Standby Fan Coil | R | Y | -| `conditioningValve` | bus_thermostat | String | The status of the conditioning valve(s) associated to the zone: `0` OFF, `1` ON, `2` Opened, `3` Closed, `4` Stop, `5` OFF Fan Coil, `6` ON speed 1, `7` ON speed 2, `8` ON speed 3, `14` Standby Fan Coil | R | Y | +| Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | Advanced | +| ---------------------------- | ----------------------------------- | ------------------ | ------------------------------------------------- | :--------: | :------: | +| `temperature` | `bus_thermostat`, `bus_temp_sensor` | Number:Temperature | The zone currently sensed temperature (°C) | R | N | +| `setpointTemperature` | `bus_thermostat` | Number:Temperature | The zone setpoint temperature (°C) | R/W | N | +| `function` | `bus_thermostat` | String | The zone set thermo function: `COOLING`, `HEATING` or `GENERIC` (heating + cooling) | R/W | N | +| `mode` | `bus_thermostat` | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | N | +| `speedFanCoil` | `bus_thermostat` | String | The zone fancoil speed: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | N | +| `actuator` | `bus_thermostat` | String | The zone actuator(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `STANDBY_FAN_COIL` | R | Y | +| `heatingValve` | `bus_thermostat` | String | The zone heating valve(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `STANDBY_FAN_COIL` | R | Y | +| `conditioningValve` | `bus_thermostat` | String | The zone conditioning valve(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `STANDBY_FAN_COIL` | R | Y | ### Notes on channels @@ -176,7 +178,8 @@ Bridge openwebnet:bus_gateway:mybridge "MyHOMEServer1" [ host="192.168.1.35", pa bus_automation LR_shutter "Living Room Shutter" [ where="93", shutterRun="10050"] bus_energy_meter CENTRAL_Ta "Energy Meter Ta" [ where="51" ] bus_energy_meter CENTRAL_Tb "Energy Meter Tb" [ where="52" ] - bus_thermostat LR_thermostat "Living Room Thermostat" [ where="2"] + bus_thermostat LR_thermostat "Living Room Thermostat" [ where="2"] + bus_temp_sensor EXT_tempsensor "External Temperature" [ where="500"] } ``` @@ -196,16 +199,17 @@ Bridge openwebnet:zb_gateway:myZBgateway [ serialPort="COM3" ] { Example items linked to BUS devices: ```xtend -Switch iLR_switch "Light" (gLivingRoom) [ "Lighting" ] { channel="openwebnet:bus_on_off_switch:mybridge:LR_switch:switch" } -Dimmer iLR_dimmer "Dimmer [%.0f %%]" (gLivingRoom) [ "Lighting" ] { channel="openwebnet:bus_dimmer:mybridge:LR_dimmer:brightness" } -Rollershutter iLR_shutter "Shutter [%.0f %%]" (gShutters, gLivingRoom) [ "Blinds" ] { channel="openwebnet:bus_automation:mybridge:LR_shutter:shutter" } -Number:Power iCENTRAL_Ta "Power [%.0f %unit%]" { channel="openwebnet:bus_energy_meter:mybridge:CENTRAL_Ta:power" } -Number:Power iCENTRAL_Tb "Power [%.0f %unit%]" { channel="openwebnet:bus_energy_meter:mybridge:CENTRAL_Tb:power" } -Number:Temperature iLR_thermostat_temp "Temperature" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:temperature" } -Number:Temperature iLR_thermostat_set "SetPoint Temperature" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:setpointTemperature" } -String iLR_thermostat_setFanSpeed "FanSpeed" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:speedFanCoil" } -String iLR_thermostat_setMode "Mode" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:mode" } -String iLR_thermostat_setFunc "Function" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:function" } +Switch iLR_switch "Light" (gLivingRoom) [ "Lighting" ] { channel="openwebnet:bus_on_off_switch:mybridge:LR_switch:switch" } +Dimmer iLR_dimmer "Dimmer [%.0f %%]" (gLivingRoom) [ "Lighting" ] { channel="openwebnet:bus_dimmer:mybridge:LR_dimmer:brightness" } +Rollershutter iLR_shutter "Shutter [%.0f %%]" (gShutters, gLivingRoom) [ "Blinds" ] { channel="openwebnet:bus_automation:mybridge:LR_shutter:shutter" } +Number:Power iCENTRAL_Ta "Power [%.0f %unit%]" { channel="openwebnet:bus_energy_meter:mybridge:CENTRAL_Ta:power" } +Number:Power iCENTRAL_Tb "Power [%.0f %unit%]" { channel="openwebnet:bus_energy_meter:mybridge:CENTRAL_Tb:power" } +Number:Temperature iLR_thermostat_temp "Temperature" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:temperature" } +Number:Temperature iLR_thermostat_set "SetPoint Temperature" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:setpointTemperature" } +String iLR_thermostat_setFanSpeed "FanSpeed" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:speedFanCoil" } +String iLR_thermostat_setMode "Mode" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:mode" } +String iLR_thermostat_setFunc "Function" (gLivingRoom) { channel="openwebnet:bus_thermostat:mybridge:LR_thermostat:function" } +Number:Temperature iEXT_temp "Temperature [%.1f °C]" (gExternal) { channel="openwebnet:bus_temp_sensor:mybridge:EXT_tempsensor:temperature" } ``` diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java index 9c095a5b3c2de..93572081acfaa 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java @@ -56,15 +56,10 @@ public class OpenWebNetBindingConstants { public static final String THING_LABEL_BUS_AUTOMATION = "Automation"; public static final ThingTypeUID THING_TYPE_BUS_ENERGY_METER = new ThingTypeUID(BINDING_ID, "bus_energy_meter"); public static final String THING_LABEL_BUS_ENERGY_METER = "Energy Meter"; - // TODO support for bus_temp_sensor - // public static final ThingTypeUID THING_TYPE_BUS_TEMP_SENSOR = new ThingTypeUID(BINDING_ID, "bus_temp_sensor"); - // public static final String THING_LABEL_BUS_TEMP_SENSOR = "Temperature Sensor"; + public static final ThingTypeUID THING_TYPE_BUS_TEMP_SENSOR = new ThingTypeUID(BINDING_ID, "bus_temp_sensor"); + public static final String THING_LABEL_BUS_TEMP_SENSOR = "Temperature Sensor"; public static final ThingTypeUID THING_TYPE_BUS_THERMOSTAT = new ThingTypeUID(BINDING_ID, "bus_thermostat"); public static final String THING_LABEL_BUS_THERMOSTAT = "Thermostat (stand-alone)"; - // TODO support for bus_cu_thermostat - // public static final ThingTypeUID THING_TYPE_BUS_THERMO_CENTRAL_UNIT = new ThingTypeUID(BINDING_ID, - // "bus_cu_thermostat"); - // public static final String THING_LABEL_BUS_THERMO_CENTRAL_UNIT = "Thermo Central Unit"; // ZIGBEE public static final ThingTypeUID THING_TYPE_ZB_ON_OFF_SWITCH = new ThingTypeUID(BINDING_ID, "zb_on_off_switch"); @@ -91,8 +86,7 @@ public class OpenWebNetBindingConstants { // ## Thermoregulation public static final Set THERMOREGULATION_SUPPORTED_THING_TYPES = new HashSet<>( - Arrays.asList(THING_TYPE_BUS_THERMOSTAT)); // TODO , THING_TYPE_BUS_TEMP_SENSOR, - // THING_TYPE_BUS_THERMO_CENTRAL_UNIT)); + Arrays.asList(THING_TYPE_BUS_THERMOSTAT, THING_TYPE_BUS_TEMP_SENSOR)); // ## Energy Management public static final Set ENERGY_MANAGEMENT_SUPPORTED_THING_TYPES = new HashSet<>( @@ -125,7 +119,7 @@ public class OpenWebNetBindingConstants { // thermo public static final String CHANNEL_TEMPERATURE = "temperature"; public static final String CHANNEL_FUNCTION = "function"; - public static final String CHANNEL_HEATING_COOLING_MODE = "thermostatMode"; + // TODO REMOVE public static final String CHANNEL_HEATING_COOLING_MODE = "thermostatMode"; public static final String CHANNEL_TEMP_SETPOINT = "setpointTemperature"; public static final String CHANNEL_MODE = "mode"; public static final String CHANNEL_FAN_SPEED = "speedFanCoil"; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index e2f087bde5b3e..f3c71bfea4603 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -12,14 +12,7 @@ */ package org.openhab.binding.openwebnet.handler; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_ACTUATOR; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_CONDITIONING_VALVE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FAN_SPEED; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FUNCTION; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_HEATING_VALVE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_MODE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMPERATURE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMP_SETPOINT; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.*; import static org.openhab.core.library.unit.SIUnits.CELSIUS; import java.math.BigDecimal; @@ -71,8 +64,7 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler { public final static Set SUPPORTED_THING_TYPES = OpenWebNetBindingConstants.THERMOREGULATION_SUPPORTED_THING_TYPES; - // 11.5 is the default setTemp used in MyHomeUP mobile app - private Double currentSetPointTemp = 11.5d; + private Double currentSetPointTemp = 11.5d; // 11.5 is the default setTemp used in MyHomeUP mobile app private Thermoregulation.FUNCTION currentFunction = Thermoregulation.FUNCTION.GENERIC; @@ -160,39 +152,41 @@ protected String ownIdPrefix() { private void handleSetFanSpeedCommand(Command command) { logger.debug("handleSetFanSpeedCommand() (command={})", command); - - if (command instanceof StringType) { - FAN_COIL_SPEED speed = FAN_COIL_SPEED.valueOf(command.toString()); - - try { - send(Thermoregulation.requestWriteFanCoilSpeed(deviceWhere.value(), speed)); - } catch (OWNException e) { - logger.warn("handleSetFanSpeedCommand() {}", e.getMessage()); + Where w = deviceWhere; + if (w != null) { + if (command instanceof StringType) { + FAN_COIL_SPEED speed = FAN_COIL_SPEED.valueOf(command.toString()); + try { + send(Thermoregulation.requestWriteFanCoilSpeed(w.value(), speed)); + } catch (OWNException e) { + logger.warn("handleSetFanSpeedCommand() {}", e.getMessage()); + } + } else { + logger.warn("handleSetFanSpeedCommand() Cannot handle command {} for thing {}", command, + getThing().getUID()); } - } else { - logger.warn("handleSetFanSpeedCommand() Cannot handle command {} for thing {}", command, - getThing().getUID()); } } private void handleSetpointCommand(Command command) { logger.debug("handleSetpointCommand() (command={})", command); - if (command instanceof QuantityType || command instanceof DecimalType) { - BigDecimal value = BigDecimal.ZERO; - if (command instanceof QuantityType) { - Unit unit = CELSIUS; - QuantityType quantity = commandToQuantityType(command, unit); - value = quantity.toBigDecimal(); - } else { - value = ((DecimalType) command).toBigDecimal(); - } - - try { - send(Thermoregulation.requestWriteSetpointTemperature(deviceWhere.value(), value.floatValue(), - currentFunction)); - } catch (MalformedFrameException | OWNException e) { - logger.warn("handleSetpointCommand() {}", e.getMessage()); + Where w = deviceWhere; + if (w != null) { + BigDecimal value = BigDecimal.ZERO; + if (command instanceof QuantityType) { + Unit unit = CELSIUS; + QuantityType quantity = commandToQuantityType(command, unit); + value = quantity.toBigDecimal(); + } else { + value = ((DecimalType) command).toBigDecimal(); + } + try { + send(Thermoregulation.requestWriteSetpointTemperature(w.value(), value.floatValue(), + currentFunction)); + } catch (MalformedFrameException | OWNException e) { + logger.warn("handleSetpointCommand() {}", e.getMessage()); + } } } else { logger.warn("handleSetpointCommand() Cannot handle command {} for thing {}", command, getThing().getUID()); @@ -201,19 +195,22 @@ private void handleSetpointCommand(Command command) { private void handleMode(Command command) { if (command instanceof StringType) { - try { + Where w = deviceWhere; + if (w != null) { + try { - OPERATION_MODE mode = OPERATION_MODE.valueOf(((StringType) command).toString()); - if (mode == OPERATION_MODE.MANUAL) - logger.debug("handleMode() mode={} function={} setPointTemp={}°", mode.toString(), - currentFunction.toString(), currentSetPointTemp); - else - logger.debug("handleMode() mode={} function={}", mode.toString(), currentFunction.toString()); + OPERATION_MODE mode = OPERATION_MODE.valueOf(((StringType) command).toString()); + if (mode == OPERATION_MODE.MANUAL) { + logger.debug("handleMode() mode={} function={} setPointTemp={}°", mode.toString(), + currentFunction.toString(), currentSetPointTemp); + } else { + logger.debug("handleMode() mode={} function={}", mode.toString(), currentFunction.toString()); + } - send(Thermoregulation.requestWriteMode(deviceWhere.value(), mode, currentFunction, - currentSetPointTemp)); - } catch (OWNException e) { - logger.warn("handleMode() {}", e.getMessage()); + send(Thermoregulation.requestWriteMode(w.value(), mode, currentFunction, currentSetPointTemp)); + } catch (OWNException e) { + logger.warn("handleMode() {}", e.getMessage()); + } } } else { @@ -223,18 +220,17 @@ private void handleMode(Command command) { private void handleFunction(Command command) { logger.debug("handleFunction() (command={})", command); - if (command instanceof StringType) { - try { - - FUNCTION function = FUNCTION.valueOf(((StringType) command).toString()); - logger.debug("handleFunction() mode={}", function.toString()); - - send(Thermoregulation.requestWriteFunction(deviceWhere.value(), function)); - } catch (OWNException e) { - logger.warn("handleFunction() {}", e.getMessage()); + Where w = deviceWhere; + if (w != null) { + try { + FUNCTION function = FUNCTION.valueOf(((StringType) command).toString()); + logger.debug("handleFunction() mode={}", function.toString()); + send(Thermoregulation.requestWriteFunction(w.value(), function)); + } catch (OWNException e) { + logger.warn("handleFunction() {}", e.getMessage()); + } } - } else { logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); } @@ -250,10 +246,12 @@ protected void handleMessage(BaseOpenMessage msg) { if (msg.isCommand()) { updateModeAndFunction((Thermoregulation) msg); } else { - if (msg.getDim() == null) + if (msg.getDim() == null) { return; + } - if (msg.getDim() == Thermoregulation.DIM.TEMPERATURE) { + if (msg.getDim() == Thermoregulation.DIM.TEMPERATURE + || msg.getDim() == Thermoregulation.DIM.PROBE_TEMPERATURE) { updateTemperature((Thermoregulation) msg); } else if (msg.getDim() == Thermoregulation.DIM.TEMP_SETPOINT || msg.getDim() == Thermoregulation.DIM.COMPLETE_PROBE_STATUS) { @@ -286,16 +284,18 @@ private void updateModeAndFunction(Thermoregulation tmsg) { OPERATION_MODE mode = w.mode(); FUNCTION function = w.function(); - if (w == WHAT.HEATING) + if (w == WHAT.HEATING) { function = FUNCTION.HEATING; - else if (w == WHAT.CONDITIONING) + } else if (w == WHAT.CONDITIONING) { function = FUNCTION.COOLING; + } - if (mode == OPERATION_MODE.MANUAL) + if (mode == OPERATION_MODE.MANUAL) { logger.debug("updateModeAndFunction() function={} mode={} setPointTemp={}°", function.toString(), mode.toString(), currentSetPointTemp); - else + } else { logger.debug("updateModeAndFunction() function={} mode={}", function.toString(), mode.toString()); + } updateState(CHANNEL_MODE, new StringType(mode.toString())); updateState(CHANNEL_FUNCTION, new StringType(function.toString())); @@ -322,11 +322,9 @@ private void updateTemperature(Thermoregulation tmsg) { private void updateSetpoint(Thermoregulation tmsg) { logger.debug("updateSetpoint() for thing: {}", thing.getUID()); String channelID = CHANNEL_TEMP_SETPOINT; - try { Double temp = Thermoregulation.parseTemperature(tmsg); updateState(channelID, new DecimalType(temp)); - // store current setPoint T currentSetPointTemp = temp; } catch (FrameException e) { @@ -358,7 +356,6 @@ private void updateValveStatus(Thermoregulation tmsg) { updateState(CHANNEL_HEATING_VALVE, new StringType(hv.toString())); } catch (FrameException e) { logger.warn("updateValveStatus() FrameException on frame {}: {}", tmsg, e.getMessage()); - updateState(CHANNEL_CONDITIONING_VALVE, UnDefType.UNDEF); updateState(CHANNEL_HEATING_VALVE, UnDefType.UNDEF); } @@ -366,13 +363,11 @@ private void updateValveStatus(Thermoregulation tmsg) { private void updateActuatorStatus(Thermoregulation tmsg) { logger.debug("updateActuatorStatus() for thing: {}", thing.getUID()); - try { VALVE_OR_ACTUATOR_STATUS hv = Thermoregulation.parseActuatorStatus(tmsg); updateState(CHANNEL_ACTUATOR, new StringType(hv.toString())); } catch (FrameException e) { logger.warn("updateActuatorStatus() FrameException on frame {}: {}", tmsg, e.getMessage()); - updateState(CHANNEL_ACTUATOR, UnDefType.UNDEF); } } @@ -381,7 +376,6 @@ private void updateActuatorStatus(Thermoregulation tmsg) { protected void refreshDevice(boolean refreshAll) { if (deviceWhere != null) { String w = deviceWhere.value(); - try { // for bus_thermostat request single channels updates send(Thermoregulation.requestTemperature(w)); @@ -391,7 +385,7 @@ protected void refreshDevice(boolean refreshAll) { send(Thermoregulation.requestValveStatus(w)); send(Thermoregulation.requestActuatorStatus(w)); } catch (OWNException e) { - logger.error("refreshDevice() where='{}' --> OWNException {}", w, e.getMessage()); + logger.warn("refreshDevice() where='{}' returned OWNException {}", w, e.getMessage()); } } } diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java index a4a959b69e3ed..c1ccc624bab60 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java @@ -131,13 +131,10 @@ public void newDiscoveryResult(Where where, OpenDeviceType deviceType, @Nullable deviceWho = Who.AUTOMATION; break; } - - // TODO: support for bus_temp_sensor case SCS_TEMP_SENSOR: { - logger.warn("newDiscoveryResult() Unsupported channel! WHERE={}, deviceType={}", where, deviceType); - // thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_TEMP_SENSOR; - // thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_TEMP_SENSOR; - // deviceWho = Who.THERMOREGULATION; + thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_TEMP_SENSOR; + thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_TEMP_SENSOR; + deviceWho = Who.THERMOREGULATION; break; } case SCS_THERMOSTAT: { @@ -146,13 +143,8 @@ public void newDiscoveryResult(Where where, OpenDeviceType deviceType, @Nullable deviceWho = Who.THERMOREGULATION; break; } - - // TODO: support for bus_cu_thermostat case SCS_THERMO_CENTRAL_UNIT: { - logger.warn("newDiscoveryResult() Unsupported channel! WHERE={}, deviceType={}", where, deviceType); - // thingTypeUID = OpenWebNetBindingConstants.THING_TYPE_BUS_THERMO_CENTRAL_UNIT; - // thingLabel = OpenWebNetBindingConstants.THING_LABEL_BUS_THERMO_CENTRAL_UNIT; - // deviceWho = Who.THERMOREGULATION; + logger.warn("newDiscoveryResult() deviceType={} is not supported yet (WHERE={})", deviceType, where); break; } case SCS_ENERGY_METER: { diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml new file mode 100644 index 0000000000000..e7bd2ef207986 --- /dev/null +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml @@ -0,0 +1,36 @@ + + + + + + + + + + A OpenWebNet BUS/SCS temperature sensor. BTicino models: L/N/NT4577 etc. + + + + + + + BTicino/Legrand + BTI-L/N/NT4577 etc. + --- + + + ownId + + + + + Example: Zone 2 --> where=2. For external sensors: sensor 5 --> where=500 + + + + + + diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml index d1c46d24212ac..1090b0940623f 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml @@ -37,8 +37,7 @@ - Example: Zone 2 --> WHERE=2. - true + Example: Zone 2 --> where=2. diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index 71795b25dd002..d53cc357172aa 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -55,8 +55,8 @@ Thermo function of the thermostat (read/write) + - @@ -106,16 +106,16 @@ Conditioning Valve status (read only) - - - - - - - - - - + + + + + + + + + + @@ -126,16 +126,16 @@ Heating Valve status (read only) - - - - - - - - - - + + + + + + + + + + @@ -146,16 +146,16 @@ Actuator status (read only) - - - - - - - - - - + + + + + + + + + + From 0c30582aa10169ea62ab012d62f3491dd57bd1fc Mon Sep 17 00:00:00 2001 From: Massimo Valla Date: Sat, 22 May 2021 16:30:39 +0200 Subject: [PATCH 07/15] [openwebnet] added checks for enum conversions in Thermo Signed-off-by: Massimo Valla --- .../OpenWebNetThermoregulationHandler.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index f3c71bfea4603..edeac0f06398b 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -121,10 +121,8 @@ protected void handleChannelCommand(ChannelUID channel, Command command) { @Override protected void requestChannelState(ChannelUID channel) { logger.debug("requestChannelState() thingUID={} channel={}", thing.getUID(), channel.getId()); - if (deviceWhere != null) { String w = deviceWhere.value(); - try { // for bus_thermostat request single channels updates send(Thermoregulation.requestTemperature(w)); @@ -152,19 +150,22 @@ protected String ownIdPrefix() { private void handleSetFanSpeedCommand(Command command) { logger.debug("handleSetFanSpeedCommand() (command={})", command); - Where w = deviceWhere; - if (w != null) { - if (command instanceof StringType) { - FAN_COIL_SPEED speed = FAN_COIL_SPEED.valueOf(command.toString()); + if (command instanceof StringType) { + Where w = deviceWhere; + if (w != null) { try { + FAN_COIL_SPEED speed = FAN_COIL_SPEED.valueOf(command.toString()); send(Thermoregulation.requestWriteFanCoilSpeed(w.value(), speed)); } catch (OWNException e) { logger.warn("handleSetFanSpeedCommand() {}", e.getMessage()); + } catch (IllegalArgumentException e) { + logger.warn("handleSetFanSpeedCommand() Unsupported command {} for thing {}", command, + getThing().getUID()); + return; } - } else { - logger.warn("handleSetFanSpeedCommand() Cannot handle command {} for thing {}", command, - getThing().getUID()); } + } else { + logger.warn("handleSetFanSpeedCommand() Unsupported command {} for thing {}", command, getThing().getUID()); } } @@ -189,7 +190,7 @@ private void handleSetpointCommand(Command command) { } } } else { - logger.warn("handleSetpointCommand() Cannot handle command {} for thing {}", command, getThing().getUID()); + logger.warn("handleSetpointCommand() Unsupported command {} for thing {}", command, getThing().getUID()); } } @@ -198,7 +199,6 @@ private void handleMode(Command command) { Where w = deviceWhere; if (w != null) { try { - OPERATION_MODE mode = OPERATION_MODE.valueOf(((StringType) command).toString()); if (mode == OPERATION_MODE.MANUAL) { logger.debug("handleMode() mode={} function={} setPointTemp={}°", mode.toString(), @@ -206,15 +206,17 @@ private void handleMode(Command command) { } else { logger.debug("handleMode() mode={} function={}", mode.toString(), currentFunction.toString()); } - send(Thermoregulation.requestWriteMode(w.value(), mode, currentFunction, currentSetPointTemp)); } catch (OWNException e) { logger.warn("handleMode() {}", e.getMessage()); + } catch (IllegalArgumentException e) { + logger.warn("handleMode() Unsupported command {} for thing {}", command, getThing().getUID()); + return; } } } else { - logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); + logger.warn("handleMode() Unsupported command {} for thing {}", command, getThing().getUID()); } } @@ -229,10 +231,13 @@ private void handleFunction(Command command) { send(Thermoregulation.requestWriteFunction(w.value(), function)); } catch (OWNException e) { logger.warn("handleFunction() {}", e.getMessage()); + } catch (IllegalArgumentException e) { + logger.warn("handleFunction() Unsupported command {} for thing {}", command, getThing().getUID()); + return; } } } else { - logger.warn("Cannot handle command {} for thing {}", command, getThing().getUID()); + logger.warn("handleFunction() Unsupported command {} for thing {}", command, getThing().getUID()); } } @@ -249,7 +254,6 @@ protected void handleMessage(BaseOpenMessage msg) { if (msg.getDim() == null) { return; } - if (msg.getDim() == Thermoregulation.DIM.TEMPERATURE || msg.getDim() == Thermoregulation.DIM.PROBE_TEMPERATURE) { updateTemperature((Thermoregulation) msg); From 23946c5cdcdb1b66a5418bacedb496d2d98ddcaa Mon Sep 17 00:00:00 2001 From: Massimo Valla Date: Sat, 22 May 2021 16:39:24 +0200 Subject: [PATCH 08/15] [openwebnet] style check Signed-off-by: Massimo Valla --- .../resources/OH-INF/thing/BusTempSensor.xml | 17 ++++---- .../main/resources/OH-INF/thing/channels.xml | 42 +++++++++---------- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml index e7bd2ef207986..7f48c8279656b 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml @@ -3,34 +3,33 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0" xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> - + - + A OpenWebNet BUS/SCS temperature sensor. BTicino models: L/N/NT4577 etc. - + - + - + BTicino/Legrand BTI-L/N/NT4577 etc. --- - + ownId - + Example: Zone 2 --> where=2. For external sensors: sensor 5 --> where=500 - + - diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index d53cc357172aa..f6de8a848de08 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -55,7 +55,7 @@ Thermo function of the thermostat (read/write) - + @@ -126,16 +126,16 @@ Heating Valve status (read only) - - - - - - - - - - + + + + + + + + + + @@ -146,16 +146,16 @@ Actuator status (read only) - - - - - - - - - - + + + + + + + + + + From 341f80fc9bcf9c191e7e175cdd8e34a99175026f Mon Sep 17 00:00:00 2001 From: Massimo Valla Date: Sun, 23 May 2021 09:25:59 +0200 Subject: [PATCH 09/15] aded property to detect tempSensors to enhance refreshDevice Signed-off-by: Massimo Valla --- .../OpenWebNetThermoregulationHandler.java | 57 ++++++------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index edeac0f06398b..ceefe0df2cfc7 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -64,6 +64,8 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler { public final static Set SUPPORTED_THING_TYPES = OpenWebNetBindingConstants.THERMOREGULATION_SUPPORTED_THING_TYPES; + private boolean isTempSensor = false; // is the device a sensor or thermostat? + private Double currentSetPointTemp = 11.5d; // 11.5 is the default setTemp used in MyHomeUP mobile app private Thermoregulation.FUNCTION currentFunction = Thermoregulation.FUNCTION.GENERIC; @@ -75,25 +77,10 @@ public OpenWebNetThermoregulationHandler(Thing thing) { @Override public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { super.bridgeStatusChanged(bridgeStatusInfo); - // when the bridge is ONLINE request for thing states (temp, setTemp, fanSpeed...) if (bridgeStatusInfo.getStatus().equals(ThingStatus.ONLINE)) { logger.debug("bridgeStatusChanged() thing={}", thing.getUID()); - - if (deviceWhere != null) { - String w = deviceWhere.value(); - try { - // request single channels updates - send(Thermoregulation.requestTemperature(w)); - send(Thermoregulation.requestSetPointTemperature(w)); - send(Thermoregulation.requestFanCoilSpeed(w)); - send(Thermoregulation.requestMode(w)); - send(Thermoregulation.requestValveStatus(w)); - send(Thermoregulation.requestActuatorStatus(w)); - } catch (OWNException e) { - logger.error("bridgeStatusChanged() OWNException thingUID={}: {}", thing.getUID(), e.getMessage()); - } - } + refreshDevice(false); } } @@ -121,26 +108,16 @@ protected void handleChannelCommand(ChannelUID channel, Command command) { @Override protected void requestChannelState(ChannelUID channel) { logger.debug("requestChannelState() thingUID={} channel={}", thing.getUID(), channel.getId()); - if (deviceWhere != null) { - String w = deviceWhere.value(); - try { - // for bus_thermostat request single channels updates - send(Thermoregulation.requestTemperature(w)); - send(Thermoregulation.requestSetPointTemperature(w)); - send(Thermoregulation.requestFanCoilSpeed(w)); - send(Thermoregulation.requestMode(w)); - send(Thermoregulation.requestValveStatus(w)); - send(Thermoregulation.requestActuatorStatus(w)); - } catch (OWNException e) { - logger.error("requestChannelState() OWNException thingUID={} channel={}: {}", thing.getUID(), - channel.getId(), e.getMessage()); - } - } + refreshDevice(false); } @Override protected Where buildBusWhere(String wStr) throws IllegalArgumentException { - return new WhereThermo(wStr); + WhereThermo wt = new WhereThermo(wStr); + if (wt.isProbe()) { + isTempSensor = true; + } + return wt; } @Override @@ -277,7 +254,7 @@ private void updateModeAndFunction(Thermoregulation tmsg) { logger.debug("updateModeAndFunction() for thing: {} msg={}", thing.getUID(), tmsg); if (tmsg.getWhat() == null) { - logger.warn("updateModeAndFunction() Could not parse Mode from: {}", tmsg.getFrameValue()); + logger.debug("updateModeAndFunction() Could not parse Mode from: {}", tmsg.getFrameValue()); return; } @@ -381,13 +358,15 @@ protected void refreshDevice(boolean refreshAll) { if (deviceWhere != null) { String w = deviceWhere.value(); try { - // for bus_thermostat request single channels updates send(Thermoregulation.requestTemperature(w)); - send(Thermoregulation.requestSetPointTemperature(w)); - send(Thermoregulation.requestFanCoilSpeed(w)); - send(Thermoregulation.requestMode(w)); - send(Thermoregulation.requestValveStatus(w)); - send(Thermoregulation.requestActuatorStatus(w)); + if (!this.isTempSensor) { + // for bus_thermostat request also other single channels updates + send(Thermoregulation.requestSetPointTemperature(w)); + send(Thermoregulation.requestFanCoilSpeed(w)); + send(Thermoregulation.requestMode(w)); + send(Thermoregulation.requestValveStatus(w)); + send(Thermoregulation.requestActuatorStatus(w)); + } } catch (OWNException e) { logger.warn("refreshDevice() where='{}' returned OWNException {}", w, e.getMessage()); } From 016cb49c49ed29c0cd67f8627de6b0228ded1bce Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Sun, 23 May 2021 10:17:04 +0200 Subject: [PATCH 10/15] fixed Thermostat thing description Signed-off-by: Conte Andrea --- .../src/main/resources/OH-INF/thing/BusThermostat.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml index 1090b0940623f..0458b3c5b873e 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml @@ -11,7 +11,7 @@ - A BUS/SCS zone stand-alone thermostat. BTicino models: LN4691. + A OpenWebNet BUS/SCS zone stand-alone thermostat. BTicino models: LN4691. From af54a8179bf2c3dc7f9e3056988231d77d71c5d1 Mon Sep 17 00:00:00 2001 From: Massimo Valla Date: Sun, 23 May 2021 23:11:40 +0200 Subject: [PATCH 11/15] - use normalizeWhere for whereConfig to detect thermostats correctly - added tests for WhereThermo and OwnId Signed-off-by: Massimo Valla --- .../OpenWebNetDeviceDiscoveryService.java | 2 +- .../binding/openwebnet/handler/OwnIdTest.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java index c1ccc624bab60..2cfe7a2a0f977 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java @@ -177,7 +177,7 @@ public void newDiscoveryResult(Where where, OpenDeviceType deviceType, @Nullable DiscoveryResult discoveryResult = null; - String whereConfig = where.value(); + String whereConfig = bridgeHandler.normalizeWhere(where); if (where instanceof WhereZigBee && WhereZigBee.UNIT_02.equals(((WhereZigBee) where).getUnit())) { logger.debug("UNIT=02 found (WHERE={}) -> will remove previous result if exists", where); thingRemoved(thingUID); // remove previously discovered thing diff --git a/bundles/org.openhab.binding.openwebnet/src/test/java/org/openhab/binding/openwebnet/handler/OwnIdTest.java b/bundles/org.openhab.binding.openwebnet/src/test/java/org/openhab/binding/openwebnet/handler/OwnIdTest.java index 992e6f10c2c94..ce8910e12da43 100644 --- a/bundles/org.openhab.binding.openwebnet/src/test/java/org/openhab/binding/openwebnet/handler/OwnIdTest.java +++ b/bundles/org.openhab.binding.openwebnet/src/test/java/org/openhab/binding/openwebnet/handler/OwnIdTest.java @@ -24,6 +24,7 @@ import org.openwebnet4j.message.Where; import org.openwebnet4j.message.WhereEnergyManagement; import org.openwebnet4j.message.WhereLightAutom; +import org.openwebnet4j.message.WhereThermo; import org.openwebnet4j.message.WhereZigBee; import org.openwebnet4j.message.Who; import org.slf4j.Logger; @@ -55,11 +56,12 @@ public class OwnIdTest { * BUS Local Bus 25#4#01 25h4h01 1.25h4h01 25h4h01 * BUS Autom 93 93 2.93 93 * BUS Thermo #1 or 1 1 4.1 1 + * BUS Thermo actuator 1#2 1 4.1 1 * BUS TempSensor 500 500 4.500 500 * BUS Energy 51 51 18.51 51 - * BUS CEN 51 51 15.51 51 - * BUS CEN+ 212 212 25.212 212 - * BUS DryContact 399 399 25.399 399 + * -INACTIVE- BUS CEN 51 51 15.51 51 + * -INACTIVE- BUS CEN+ 212 212 25.212 212 + * -INACTIVE- BUS DryContact 399 399 25.399 399 * */ // @formatter:on @@ -71,10 +73,11 @@ public enum TEST { zb_switch_2u_2(new WhereZigBee("789301202#9"), Who.fromValue(1), "*1*1*789301202#9##", "789301200h9", "1.789301200h9", "789301200h9"), bus_switch(new WhereLightAutom("51"), Who.fromValue(1), "*1*1*51##", "51", "1.51", "51"), bus_localbus(new WhereLightAutom("25#4#01"), Who.fromValue(1), "*1*1*25#4#01##", "25h4h01", "1.25h4h01", "25h4h01"), - //bus_thermo_zone(new WhereThermo("1"), Who.fromValue(4),"*#4*1*0*0020##" , "1", "4.1", "1"), - //bus_thermo_zone_act(new WhereThermo("2#1"), Who.fromValue(4),"*#4*2#1*20*0##" ,"2", "4.2", "2"), - //bus_thermo_via_cu(new WhereThermo("#1"), Who.fromValue(4),"*#4*#1*0*0020##" ,"1", "4.1", "1"), - // bus_tempSensor("500", "4", "500", "4.500", "500"), + bus_autom(new WhereLightAutom("93"), Who.fromValue(2), "*2*0*93##", "93", "2.93", "93"), + bus_thermo_via_cu(new WhereThermo("#1"), Who.fromValue(4),"*#4*#1*0*0020##" ,"1", "4.1", "1"), + bus_thermo(new WhereThermo("1"), Who.fromValue(4),"*#4*1*0*0020##" , "1", "4.1", "1"), + bus_thermo_act(new WhereThermo("1#2"), Who.fromValue(4),"*#4*1#2*20*0##" ,"1", "4.1", "1"), + bus_tempSensor(new WhereThermo("500"), Who.fromValue(4), "*#4*500*15*1*0020*0001##", "500", "4.500", "500"), bus_energy(new WhereEnergyManagement("51"), Who.fromValue(18), "*#18*51*113##", "51", "18.51", "51"); // @formatter:on From e2020da04e47c1c0579e0b1f19d5952269cfbc56 Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Mon, 24 May 2021 11:48:25 +0200 Subject: [PATCH 12/15] fixed own4j reference with published version Signed-off-by: Conte Andrea --- bundles/org.openhab.binding.openwebnet/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.openwebnet/pom.xml b/bundles/org.openhab.binding.openwebnet/pom.xml index 70f3a1e092689..34f1b6caea72b 100644 --- a/bundles/org.openhab.binding.openwebnet/pom.xml +++ b/bundles/org.openhab.binding.openwebnet/pom.xml @@ -23,7 +23,7 @@ io.github.openwebnet4j openwebnet4j - 0.5.0-SNAPSHOT + 0.5.0 compile From 538be86f0decdeabafa29c832294523d6ffe0f9f Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Wed, 26 May 2021 19:35:13 +0200 Subject: [PATCH 13/15] added OFF_SPEED_1, OFF_SPEED_2 and OFF_SPEED_3 according to BTicino forum hint to actuator/valve status Signed-off-by: Conte Andrea --- bundles/org.openhab.binding.openwebnet/README.md | 6 +++--- bundles/org.openhab.binding.openwebnet/pom.xml | 2 +- .../src/main/resources/OH-INF/thing/channels.xml | 12 +++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/README.md b/bundles/org.openhab.binding.openwebnet/README.md index 1f1c5c4a3619a..18a43f5e7d093 100644 --- a/bundles/org.openhab.binding.openwebnet/README.md +++ b/bundles/org.openhab.binding.openwebnet/README.md @@ -147,9 +147,9 @@ Currently only stand-alone thermostats are supported (like [LN4691](https://cat | `function` | `bus_thermostat` | String | The zone set thermo function: `COOLING`, `HEATING` or `GENERIC` (heating + cooling) | R/W | N | | `mode` | `bus_thermostat` | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | N | | `speedFanCoil` | `bus_thermostat` | String | The zone fancoil speed: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | N | -| `actuator` | `bus_thermostat` | String | The zone actuator(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `STANDBY_FAN_COIL` | R | Y | -| `heatingValve` | `bus_thermostat` | String | The zone heating valve(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `STANDBY_FAN_COIL` | R | Y | -| `conditioningValve` | `bus_thermostat` | String | The zone conditioning valve(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `STANDBY_FAN_COIL` | R | Y | +| `actuator` | `bus_thermostat` | String | The zone actuator(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `OFF_SPEED_1`, `OFF_SPEED_2`, `OFF_SPEED_3` | R | Y | +| `heatingValve` | `bus_thermostat` | String | The zone heating valve(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `OFF_SPEED_1`, `OFF_SPEED_2`, `OFF_SPEED_3` | R | Y | +| `conditioningValve` | `bus_thermostat` | String | The zone conditioning valve(s) status: `OFF`, `ON`, `OPENED`, `CLOSED` , `STOP`, `OFF_FAN_COIL`, `ON_SPEED_1`, `ON_SPEED_2`, `ON_SPEED_3`, `OFF_SPEED_1`, `OFF_SPEED_2`, `OFF_SPEED_3` | R | Y | ### Notes on channels diff --git a/bundles/org.openhab.binding.openwebnet/pom.xml b/bundles/org.openhab.binding.openwebnet/pom.xml index 34f1b6caea72b..b5b8e3b955457 100644 --- a/bundles/org.openhab.binding.openwebnet/pom.xml +++ b/bundles/org.openhab.binding.openwebnet/pom.xml @@ -23,7 +23,7 @@ io.github.openwebnet4j openwebnet4j - 0.5.0 + 0.5.1 compile diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index f6de8a848de08..86ca7bb8219e0 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -115,7 +115,9 @@ - + + + @@ -135,7 +137,9 @@ - + + + @@ -155,7 +159,9 @@ - + + + From fde4bede80ba4df80dc47c48a010e445cc259097 Mon Sep 17 00:00:00 2001 From: Conte Andrea Date: Fri, 28 May 2021 08:10:38 +0200 Subject: [PATCH 14/15] =?UTF-8?q?fixed=20checkstyle=20warnings,=20=C2=B0C/?= =?UTF-8?q?=C2=B0F=20Unit,=20removed=20several=20log.debug=20lines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Conte Andrea --- .../org.openhab.binding.openwebnet/README.md | 4 +- .../org.openhab.binding.openwebnet/pom.xml | 2 +- .../OpenWebNetBindingConstants.java | 26 ++-- .../OpenWebNetThermoregulationHandler.java | 131 +++++++----------- .../OpenWebNetDeviceDiscoveryService.java | 1 - .../resources/OH-INF/thing/BusTempSensor.xml | 2 +- .../resources/OH-INF/thing/BusThermostat.xml | 2 +- .../main/resources/OH-INF/thing/channels.xml | 6 +- 8 files changed, 70 insertions(+), 104 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/README.md b/bundles/org.openhab.binding.openwebnet/README.md index 18a43f5e7d093..7b2ab4585a330 100644 --- a/bundles/org.openhab.binding.openwebnet/README.md +++ b/bundles/org.openhab.binding.openwebnet/README.md @@ -142,8 +142,8 @@ Currently only stand-alone thermostats are supported (like [LN4691](https://cat | Channel Type ID (channel ID) | Applies to Thing Type IDs | Item Type | Description | Read/Write | Advanced | | ---------------------------- | ----------------------------------- | ------------------ | ------------------------------------------------- | :--------: | :------: | -| `temperature` | `bus_thermostat`, `bus_temp_sensor` | Number:Temperature | The zone currently sensed temperature (°C) | R | N | -| `setpointTemperature` | `bus_thermostat` | Number:Temperature | The zone setpoint temperature (°C) | R/W | N | +| `temperature` | `bus_thermostat`, `bus_temp_sensor` | Number:Temperature | The zone currently sensed temperature | R | N | +| `setpointTemperature` | `bus_thermostat` | Number:Temperature | The zone setpoint temperature | R/W | N | | `function` | `bus_thermostat` | String | The zone set thermo function: `COOLING`, `HEATING` or `GENERIC` (heating + cooling) | R/W | N | | `mode` | `bus_thermostat` | String | The zone set mode: `MANUAL`, `PROTECTION`, `OFF` | R/W | N | | `speedFanCoil` | `bus_thermostat` | String | The zone fancoil speed: `AUTO`, `SPEED_1`, `SPEED_2`, `SPEED_3` | R/W | N | diff --git a/bundles/org.openhab.binding.openwebnet/pom.xml b/bundles/org.openhab.binding.openwebnet/pom.xml index b5b8e3b955457..caefdc9197160 100644 --- a/bundles/org.openhab.binding.openwebnet/pom.xml +++ b/bundles/org.openhab.binding.openwebnet/pom.xml @@ -23,7 +23,7 @@ io.github.openwebnet4j openwebnet4j - 0.5.1 + 0.5.2 compile diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java index 93572081acfaa..42c369ec0e978 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/OpenWebNetBindingConstants.java @@ -12,7 +12,6 @@ */ package org.openhab.binding.openwebnet; -import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -74,23 +73,21 @@ public class OpenWebNetBindingConstants { // #SUPPORTED THINGS SETS // ## Generic - public static final Set GENERIC_SUPPORTED_THING_TYPES = new HashSet<>( - Arrays.asList(THING_TYPE_GENERIC_DEVICE)); + public static final Set GENERIC_SUPPORTED_THING_TYPES = Set.of(THING_TYPE_GENERIC_DEVICE); // ## Lighting - public static final Set LIGHTING_SUPPORTED_THING_TYPES = new HashSet<>( - Arrays.asList(THING_TYPE_ZB_ON_OFF_SWITCH, THING_TYPE_ZB_ON_OFF_SWITCH_2UNITS, THING_TYPE_ZB_DIMMER, - THING_TYPE_BUS_ON_OFF_SWITCH, THING_TYPE_BUS_DIMMER)); + public static final Set LIGHTING_SUPPORTED_THING_TYPES = Set.of(THING_TYPE_ZB_ON_OFF_SWITCH, + THING_TYPE_ZB_ON_OFF_SWITCH_2UNITS, THING_TYPE_ZB_DIMMER, THING_TYPE_BUS_ON_OFF_SWITCH, + THING_TYPE_BUS_DIMMER); // ## Automation - public static final Set AUTOMATION_SUPPORTED_THING_TYPES = new HashSet<>( - Arrays.asList(THING_TYPE_ZB_AUTOMATION, THING_TYPE_BUS_AUTOMATION)); + public static final Set AUTOMATION_SUPPORTED_THING_TYPES = Set.of(THING_TYPE_ZB_AUTOMATION, + THING_TYPE_BUS_AUTOMATION); // ## Thermoregulation - public static final Set THERMOREGULATION_SUPPORTED_THING_TYPES = new HashSet<>( - Arrays.asList(THING_TYPE_BUS_THERMOSTAT, THING_TYPE_BUS_TEMP_SENSOR)); + public static final Set THERMOREGULATION_SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BUS_THERMOSTAT, + THING_TYPE_BUS_TEMP_SENSOR); // ## Energy Management - public static final Set ENERGY_MANAGEMENT_SUPPORTED_THING_TYPES = new HashSet<>( - Arrays.asList(THING_TYPE_BUS_ENERGY_METER)); + public static final Set ENERGY_MANAGEMENT_SUPPORTED_THING_TYPES = Set.of(THING_TYPE_BUS_ENERGY_METER); // ## Groups public static final Set DEVICE_SUPPORTED_THING_TYPES = Stream @@ -99,8 +96,8 @@ public class OpenWebNetBindingConstants { GENERIC_SUPPORTED_THING_TYPES) .flatMap(Collection::stream).collect(Collectors.toCollection(HashSet::new)); - public static final Set BRIDGE_SUPPORTED_THING_TYPES = new HashSet<>( - Arrays.asList(THING_TYPE_ZB_GATEWAY, THING_TYPE_BUS_GATEWAY)); + public static final Set BRIDGE_SUPPORTED_THING_TYPES = Set.of(THING_TYPE_ZB_GATEWAY, + THING_TYPE_BUS_GATEWAY); public static final Set ALL_SUPPORTED_THING_TYPES = Stream .of(DEVICE_SUPPORTED_THING_TYPES, BRIDGE_SUPPORTED_THING_TYPES).flatMap(Collection::stream) @@ -119,7 +116,6 @@ public class OpenWebNetBindingConstants { // thermo public static final String CHANNEL_TEMPERATURE = "temperature"; public static final String CHANNEL_FUNCTION = "function"; - // TODO REMOVE public static final String CHANNEL_HEATING_COOLING_MODE = "thermostatMode"; public static final String CHANNEL_TEMP_SETPOINT = "setpointTemperature"; public static final String CHANNEL_MODE = "mode"; public static final String CHANNEL_FAN_SPEED = "speedFanCoil"; diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index ceefe0df2cfc7..3a2ac9a906d9e 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -12,13 +12,18 @@ */ package org.openhab.binding.openwebnet.handler; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.*; -import static org.openhab.core.library.unit.SIUnits.CELSIUS; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_ACTUATOR; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_CONDITIONING_VALVE; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FAN_SPEED; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FUNCTION; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_HEATING_VALVE; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_MODE; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMPERATURE; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMP_SETPOINT; import java.math.BigDecimal; import java.util.Set; -import javax.measure.Unit; import javax.measure.quantity.Temperature; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -38,11 +43,6 @@ import org.openwebnet4j.message.FrameException; import org.openwebnet4j.message.MalformedFrameException; import org.openwebnet4j.message.Thermoregulation; -import org.openwebnet4j.message.Thermoregulation.FAN_COIL_SPEED; -import org.openwebnet4j.message.Thermoregulation.FUNCTION; -import org.openwebnet4j.message.Thermoregulation.OPERATION_MODE; -import org.openwebnet4j.message.Thermoregulation.VALVE_OR_ACTUATOR_STATUS; -import org.openwebnet4j.message.Thermoregulation.WHAT; import org.openwebnet4j.message.Where; import org.openwebnet4j.message.WhereThermo; import org.openwebnet4j.message.Who; @@ -66,9 +66,9 @@ public class OpenWebNetThermoregulationHandler extends OpenWebNetThingHandler { private boolean isTempSensor = false; // is the device a sensor or thermostat? - private Double currentSetPointTemp = 11.5d; // 11.5 is the default setTemp used in MyHomeUP mobile app + private double currentSetPointTemp = 11.5d; // 11.5 is the default setTemp used in MyHomeUP mobile app - private Thermoregulation.FUNCTION currentFunction = Thermoregulation.FUNCTION.GENERIC; + private Thermoregulation.Function currentFunction = Thermoregulation.Function.GENERIC; public OpenWebNetThermoregulationHandler(Thing thing) { super(thing); @@ -79,7 +79,6 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { super.bridgeStatusChanged(bridgeStatusInfo); // when the bridge is ONLINE request for thing states (temp, setTemp, fanSpeed...) if (bridgeStatusInfo.getStatus().equals(ThingStatus.ONLINE)) { - logger.debug("bridgeStatusChanged() thing={}", thing.getUID()); refreshDevice(false); } } @@ -107,7 +106,6 @@ protected void handleChannelCommand(ChannelUID channel, Command command) { @Override protected void requestChannelState(ChannelUID channel) { - logger.debug("requestChannelState() thingUID={} channel={}", thing.getUID(), channel.getId()); refreshDevice(false); } @@ -126,12 +124,11 @@ protected String ownIdPrefix() { } private void handleSetFanSpeedCommand(Command command) { - logger.debug("handleSetFanSpeedCommand() (command={})", command); if (command instanceof StringType) { Where w = deviceWhere; if (w != null) { try { - FAN_COIL_SPEED speed = FAN_COIL_SPEED.valueOf(command.toString()); + Thermoregulation.FanCoilSpeed speed = Thermoregulation.FanCoilSpeed.valueOf(command.toString()); send(Thermoregulation.requestWriteFanCoilSpeed(w.value(), speed)); } catch (OWNException e) { logger.warn("handleSetFanSpeedCommand() {}", e.getMessage()); @@ -147,15 +144,12 @@ private void handleSetFanSpeedCommand(Command command) { } private void handleSetpointCommand(Command command) { - logger.debug("handleSetpointCommand() (command={})", command); if (command instanceof QuantityType || command instanceof DecimalType) { Where w = deviceWhere; if (w != null) { BigDecimal value = BigDecimal.ZERO; if (command instanceof QuantityType) { - Unit unit = CELSIUS; - QuantityType quantity = commandToQuantityType(command, unit); - value = quantity.toBigDecimal(); + value = new QuantityType(command.toFullString()).toBigDecimal(); } else { value = ((DecimalType) command).toBigDecimal(); } @@ -176,13 +170,7 @@ private void handleMode(Command command) { Where w = deviceWhere; if (w != null) { try { - OPERATION_MODE mode = OPERATION_MODE.valueOf(((StringType) command).toString()); - if (mode == OPERATION_MODE.MANUAL) { - logger.debug("handleMode() mode={} function={} setPointTemp={}°", mode.toString(), - currentFunction.toString(), currentSetPointTemp); - } else { - logger.debug("handleMode() mode={} function={}", mode.toString(), currentFunction.toString()); - } + Thermoregulation.OperationMode mode = Thermoregulation.OperationMode.valueOf(command.toString()); send(Thermoregulation.requestWriteMode(w.value(), mode, currentFunction, currentSetPointTemp)); } catch (OWNException e) { logger.warn("handleMode() {}", e.getMessage()); @@ -191,20 +179,17 @@ private void handleMode(Command command) { return; } } - } else { logger.warn("handleMode() Unsupported command {} for thing {}", command, getThing().getUID()); } } private void handleFunction(Command command) { - logger.debug("handleFunction() (command={})", command); if (command instanceof StringType) { Where w = deviceWhere; if (w != null) { try { - FUNCTION function = FUNCTION.valueOf(((StringType) command).toString()); - logger.debug("handleFunction() mode={}", function.toString()); + Thermoregulation.Function function = Thermoregulation.Function.valueOf(command.toString()); send(Thermoregulation.requestWriteFunction(w.value(), function)); } catch (OWNException e) { logger.warn("handleFunction() {}", e.getMessage()); @@ -218,10 +203,6 @@ private void handleFunction(Command command) { } } - private QuantityType commandToQuantityType(Command command, Unit unit) { - return new QuantityType(command.toFullString()); - } - @Override protected void handleMessage(BaseOpenMessage msg) { super.handleMessage(msg); @@ -231,17 +212,17 @@ protected void handleMessage(BaseOpenMessage msg) { if (msg.getDim() == null) { return; } - if (msg.getDim() == Thermoregulation.DIM.TEMPERATURE - || msg.getDim() == Thermoregulation.DIM.PROBE_TEMPERATURE) { + if (msg.getDim() == Thermoregulation.DimThermo.TEMPERATURE + || msg.getDim() == Thermoregulation.DimThermo.PROBE_TEMPERATURE) { updateTemperature((Thermoregulation) msg); - } else if (msg.getDim() == Thermoregulation.DIM.TEMP_SETPOINT - || msg.getDim() == Thermoregulation.DIM.COMPLETE_PROBE_STATUS) { + } else if (msg.getDim() == Thermoregulation.DimThermo.TEMP_SETPOINT + || msg.getDim() == Thermoregulation.DimThermo.COMPLETE_PROBE_STATUS) { updateSetpoint((Thermoregulation) msg); - } else if (msg.getDim() == Thermoregulation.DIM.VALVES_STATUS) { + } else if (msg.getDim() == Thermoregulation.DimThermo.VALVES_STATUS) { updateValveStatus((Thermoregulation) msg); - } else if (msg.getDim() == Thermoregulation.DIM.ACTUATOR_STATUS) { + } else if (msg.getDim() == Thermoregulation.DimThermo.ACTUATOR_STATUS) { updateActuatorStatus((Thermoregulation) msg); - } else if (msg.getDim() == Thermoregulation.DIM.FAN_COIL_SPEED) { + } else if (msg.getDim() == Thermoregulation.DimThermo.FAN_COIL_SPEED) { updateFanCoilSpeed((Thermoregulation) msg); } else { logger.debug("handleMessage() Ignoring unsupported DIM {} for thing {}. Frame={}", msg.getDim(), @@ -251,48 +232,42 @@ protected void handleMessage(BaseOpenMessage msg) { } private void updateModeAndFunction(Thermoregulation tmsg) { - logger.debug("updateModeAndFunction() for thing: {} msg={}", thing.getUID(), tmsg); - if (tmsg.getWhat() == null) { - logger.debug("updateModeAndFunction() Could not parse Mode from: {}", tmsg.getFrameValue()); + logger.debug("updateModeAndFunction() Could not parse Mode or Function from {} (what is null)", + tmsg.getFrameValue()); return; } - try { - logger.debug("updateModeAndFunction() WHAT={}", tmsg.getWhat()); - WHAT w = WHAT.fromValue(tmsg.getWhat().value()); + Thermoregulation.WhatThermo w = Thermoregulation.WhatThermo.fromValue(tmsg.getWhat().value()); - OPERATION_MODE mode = w.mode(); - FUNCTION function = w.function(); + if (w.mode() == null) { + logger.debug("updateModeAndFunction() Could not parse Mode from: {}", tmsg.getFrameValue()); + return; + } + if (w.function() == null) { + logger.debug("updateModeAndFunction() Could not parse Function from: {}", tmsg.getFrameValue()); + return; + } - if (w == WHAT.HEATING) { - function = FUNCTION.HEATING; - } else if (w == WHAT.CONDITIONING) { - function = FUNCTION.COOLING; - } + Thermoregulation.OperationMode mode = w.mode(); + Thermoregulation.Function function = w.function(); - if (mode == OPERATION_MODE.MANUAL) { - logger.debug("updateModeAndFunction() function={} mode={} setPointTemp={}°", function.toString(), - mode.toString(), currentSetPointTemp); - } else { - logger.debug("updateModeAndFunction() function={} mode={}", function.toString(), mode.toString()); - } + if (w == Thermoregulation.WhatThermo.HEATING) { + function = Thermoregulation.Function.HEATING; + } else if (w == Thermoregulation.WhatThermo.CONDITIONING) { + function = Thermoregulation.Function.COOLING; + } - updateState(CHANNEL_MODE, new StringType(mode.toString())); - updateState(CHANNEL_FUNCTION, new StringType(function.toString())); + updateState(CHANNEL_MODE, new StringType(mode.toString())); + updateState(CHANNEL_FUNCTION, new StringType(function.toString())); - // store current function - currentFunction = function; - } catch (Exception e) { - logger.warn("updateModeAndFunction() FrameException on frame {}: {}", tmsg, e.getMessage()); - // do not update channel state, simply skip wrong message - } + // store current function + currentFunction = function; } private void updateTemperature(Thermoregulation tmsg) { - logger.debug("updateTemperature() for thing: {}", thing.getUID()); try { - Double temp = Thermoregulation.parseTemperature(tmsg); + double temp = Thermoregulation.parseTemperature(tmsg); updateState(CHANNEL_TEMPERATURE, new DecimalType(temp)); } catch (FrameException e) { logger.warn("updateTemperature() FrameException on frame {}: {}", tmsg, e.getMessage()); @@ -301,10 +276,9 @@ private void updateTemperature(Thermoregulation tmsg) { } private void updateSetpoint(Thermoregulation tmsg) { - logger.debug("updateSetpoint() for thing: {}", thing.getUID()); String channelID = CHANNEL_TEMP_SETPOINT; try { - Double temp = Thermoregulation.parseTemperature(tmsg); + double temp = Thermoregulation.parseTemperature(tmsg); updateState(channelID, new DecimalType(temp)); // store current setPoint T currentSetPointTemp = temp; @@ -315,10 +289,8 @@ private void updateSetpoint(Thermoregulation tmsg) { } private void updateFanCoilSpeed(Thermoregulation tmsg) { - logger.debug("updateFanCoilSpeed() for thing: {}", thing.getUID()); - try { - FAN_COIL_SPEED speed = Thermoregulation.parseFanCoilSpeed(tmsg); + Thermoregulation.FanCoilSpeed speed = Thermoregulation.parseFanCoilSpeed(tmsg); updateState(CHANNEL_FAN_SPEED, new StringType(speed.toString())); } catch (FrameException e) { logger.warn("updateFanCoilSpeed() FrameException on frame {}: {}", tmsg, e.getMessage()); @@ -327,13 +299,13 @@ private void updateFanCoilSpeed(Thermoregulation tmsg) { } private void updateValveStatus(Thermoregulation tmsg) { - logger.debug("updateValveStatus() for thing: {}", thing.getUID()); - try { - VALVE_OR_ACTUATOR_STATUS cv = Thermoregulation.parseValveStatus(tmsg, WHAT.CONDITIONING); + Thermoregulation.ValveOrActuatorStatus cv = Thermoregulation.parseValveStatus(tmsg, + Thermoregulation.WhatThermo.CONDITIONING); updateState(CHANNEL_CONDITIONING_VALVE, new StringType(cv.toString())); - VALVE_OR_ACTUATOR_STATUS hv = Thermoregulation.parseValveStatus(tmsg, WHAT.HEATING); + Thermoregulation.ValveOrActuatorStatus hv = Thermoregulation.parseValveStatus(tmsg, + Thermoregulation.WhatThermo.HEATING); updateState(CHANNEL_HEATING_VALVE, new StringType(hv.toString())); } catch (FrameException e) { logger.warn("updateValveStatus() FrameException on frame {}: {}", tmsg, e.getMessage()); @@ -343,9 +315,8 @@ private void updateValveStatus(Thermoregulation tmsg) { } private void updateActuatorStatus(Thermoregulation tmsg) { - logger.debug("updateActuatorStatus() for thing: {}", thing.getUID()); try { - VALVE_OR_ACTUATOR_STATUS hv = Thermoregulation.parseActuatorStatus(tmsg); + Thermoregulation.ValveOrActuatorStatus hv = Thermoregulation.parseActuatorStatus(tmsg); updateState(CHANNEL_ACTUATOR, new StringType(hv.toString())); } catch (FrameException e) { logger.warn("updateActuatorStatus() FrameException on frame {}: {}", tmsg, e.getMessage()); diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java index 2cfe7a2a0f977..df53544edbbe3 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java @@ -153,7 +153,6 @@ public void newDiscoveryResult(Where where, OpenDeviceType deviceType, @Nullable deviceWho = Who.ENERGY_MANAGEMENT; break; } - default: logger.warn("Device type {} is not supported, default to GENERIC device (WHERE={})", deviceType, where); if (where instanceof WhereZigBee) { diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml index 7f48c8279656b..2770dc059bf1d 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusTempSensor.xml @@ -26,7 +26,7 @@ - + Example: Zone 2 --> where=2. For external sensors: sensor 5 --> where=500 diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml index 0458b3c5b873e..0b9051985a713 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/BusThermostat.xml @@ -36,7 +36,7 @@ - + Example: Zone 2 --> where=2. diff --git a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml index 86ca7bb8219e0..fa04e3d36c036 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.openwebnet/src/main/resources/OH-INF/thing/channels.xml @@ -29,7 +29,7 @@ Rollershutter - + Control the roller shutter position Blinds @@ -88,7 +88,7 @@ String - + Set speed of the Fan Coil (read/write) @@ -146,7 +146,7 @@ String - + Actuator status (read only) From 57a851a1ca7d753e3b66a51b694c97f74f460e33 Mon Sep 17 00:00:00 2001 From: Massimo Valla Date: Sat, 29 May 2021 17:02:04 +0200 Subject: [PATCH 15/15] added conversion to/from Celsius as required by openwebnet lib. Renamed handleSetpoint and handleSetFanSpeed Signed-off-by: Massimo Valla --- .../OpenWebNetThermoregulationHandler.java | 53 ++++++++----------- .../handler/OpenWebNetThingHandler.java | 17 ++++++ 2 files changed, 39 insertions(+), 31 deletions(-) diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java index 3a2ac9a906d9e..01a16d3aacb13 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThermoregulationHandler.java @@ -12,25 +12,16 @@ */ package org.openhab.binding.openwebnet.handler; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_ACTUATOR; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_CONDITIONING_VALVE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FAN_SPEED; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_FUNCTION; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_HEATING_VALVE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_MODE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMPERATURE; -import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.CHANNEL_TEMP_SETPOINT; - -import java.math.BigDecimal; -import java.util.Set; +import static org.openhab.binding.openwebnet.OpenWebNetBindingConstants.*; -import javax.measure.quantity.Temperature; +import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.openwebnet.OpenWebNetBindingConstants; import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; +import org.openhab.core.library.unit.SIUnits; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; @@ -87,7 +78,7 @@ public void bridgeStatusChanged(ThingStatusInfo bridgeStatusInfo) { protected void handleChannelCommand(ChannelUID channel, Command command) { switch (channel.getId()) { case CHANNEL_TEMP_SETPOINT: - handleSetpointCommand(command); + handleSetpoint(command); break; case CHANNEL_FUNCTION: handleFunction(command); @@ -96,7 +87,7 @@ protected void handleChannelCommand(ChannelUID channel, Command command) { handleMode(command); break; case CHANNEL_FAN_SPEED: - handleSetFanSpeedCommand(command); + handleSetFanSpeed(command); break; default: { logger.warn("handleChannelCommand() Unsupported ChannelUID {}", channel.getId()); @@ -123,7 +114,7 @@ protected String ownIdPrefix() { return Who.THERMOREGULATION.value().toString(); } - private void handleSetFanSpeedCommand(Command command) { + private void handleSetFanSpeed(Command command) { if (command instanceof StringType) { Where w = deviceWhere; if (w != null) { @@ -131,37 +122,39 @@ private void handleSetFanSpeedCommand(Command command) { Thermoregulation.FanCoilSpeed speed = Thermoregulation.FanCoilSpeed.valueOf(command.toString()); send(Thermoregulation.requestWriteFanCoilSpeed(w.value(), speed)); } catch (OWNException e) { - logger.warn("handleSetFanSpeedCommand() {}", e.getMessage()); + logger.warn("handleSetFanSpeed() {}", e.getMessage()); } catch (IllegalArgumentException e) { - logger.warn("handleSetFanSpeedCommand() Unsupported command {} for thing {}", command, + logger.warn("handleSetFanSpeed() Unsupported command {} for thing {}", command, getThing().getUID()); return; } } } else { - logger.warn("handleSetFanSpeedCommand() Unsupported command {} for thing {}", command, getThing().getUID()); + logger.warn("handleSetFanSpeed() Unsupported command {} for thing {}", command, getThing().getUID()); } } - private void handleSetpointCommand(Command command) { + private void handleSetpoint(Command command) { if (command instanceof QuantityType || command instanceof DecimalType) { Where w = deviceWhere; if (w != null) { - BigDecimal value = BigDecimal.ZERO; + double newTemp = 0; if (command instanceof QuantityType) { - value = new QuantityType(command.toFullString()).toBigDecimal(); + QuantityType tempCelsius = ((QuantityType) command).toUnit(SIUnits.CELSIUS); + if (tempCelsius != null) { + newTemp = tempCelsius.doubleValue(); + } } else { - value = ((DecimalType) command).toBigDecimal(); + newTemp = ((DecimalType) command).doubleValue(); } try { - send(Thermoregulation.requestWriteSetpointTemperature(w.value(), value.floatValue(), - currentFunction)); + send(Thermoregulation.requestWriteSetpointTemperature(w.value(), newTemp, currentFunction)); } catch (MalformedFrameException | OWNException e) { - logger.warn("handleSetpointCommand() {}", e.getMessage()); + logger.warn("handleSetpoint() {}", e.getMessage()); } } } else { - logger.warn("handleSetpointCommand() Unsupported command {} for thing {}", command, getThing().getUID()); + logger.warn("handleSetpoint() Unsupported command {} for thing {}", command, getThing().getUID()); } } @@ -268,7 +261,7 @@ private void updateModeAndFunction(Thermoregulation tmsg) { private void updateTemperature(Thermoregulation tmsg) { try { double temp = Thermoregulation.parseTemperature(tmsg); - updateState(CHANNEL_TEMPERATURE, new DecimalType(temp)); + updateState(CHANNEL_TEMPERATURE, getAsQuantityTypeOrNull(temp, SIUnits.CELSIUS)); } catch (FrameException e) { logger.warn("updateTemperature() FrameException on frame {}: {}", tmsg, e.getMessage()); updateState(CHANNEL_TEMPERATURE, UnDefType.UNDEF); @@ -276,15 +269,13 @@ private void updateTemperature(Thermoregulation tmsg) { } private void updateSetpoint(Thermoregulation tmsg) { - String channelID = CHANNEL_TEMP_SETPOINT; try { double temp = Thermoregulation.parseTemperature(tmsg); - updateState(channelID, new DecimalType(temp)); - // store current setPoint T + updateState(CHANNEL_TEMP_SETPOINT, getAsQuantityTypeOrNull(temp, SIUnits.CELSIUS)); currentSetPointTemp = temp; } catch (FrameException e) { logger.warn("updateSetpoint() FrameException on frame {}: {}", tmsg, e.getMessage()); - updateState(channelID, UnDefType.UNDEF); + updateState(CHANNEL_TEMP_SETPOINT, UnDefType.UNDEF); } } diff --git a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThingHandler.java b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThingHandler.java index 03d94a71db48e..1ff15ef96cc6c 100644 --- a/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThingHandler.java +++ b/bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetThingHandler.java @@ -18,8 +18,12 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; +import javax.measure.Quantity; +import javax.measure.Unit; + import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; +import org.openhab.core.library.types.QuantityType; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -28,6 +32,8 @@ import org.openhab.core.thing.binding.BaseThingHandler; import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; +import org.openhab.core.types.State; +import org.openhab.core.types.UnDefType; import org.openwebnet4j.OpenGateway; import org.openwebnet4j.communication.OWNException; import org.openwebnet4j.communication.Response; @@ -221,6 +227,17 @@ public void dispose() { super.dispose(); } + /** + * Helper method to return a Quantity from a Number value or UnDefType.NULL if value is null + * + * @param value to be used + * @param unit to be used + * @return Quantity + */ + protected > State getAsQuantityTypeOrNull(@Nullable Number value, Unit unit) { + return value == null ? UnDefType.NULL : new QuantityType<>(value, unit); + } + /** * Returns a prefix String for ownId specific for each handler. To be implemented by sub-classes. *