Skip to content

Commit

Permalink
[openwebnet] updated README and own4j version. Code cleanup.
Browse files Browse the repository at this point in the history
Signed-off-by: Massimo Valla <[email protected]>
  • Loading branch information
mvalla committed Nov 19, 2023
1 parent c326fe5 commit b643ed6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 46 deletions.
11 changes: 9 additions & 2 deletions bundles/org.openhab.binding.openwebnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The following Things and OpenWebNet `WHOs` are supported:
| Category | WHO | Thing Type IDs | Description | Status |
|-------------------------------|:-----------:|:----------------------------------------------------------:|------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Gateway Management | `13` | `bus_gateway` | Any IP gateway supporting OpenWebNet protocol should work | Successfully tested: F452, F453, F453AV,F454, F455, MyHOMEServer1, MyHOME_Screen10, MyHOME_Screen3,5, 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) |
| Lighting | `1` | `bus_on_off_switch`, `bus_dimmer`, `bus_light_group` | BUS switches and dimmers and groups of them | 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_thermo_zone`, `bus_thermo_sensor`, `bus_thermo_cu` | Thermo zones management and temperature sensors (probes) | Successfully tested: H/LN4691, HS4692, KG4691; thermo sensors: L/N/NT4577 + 3455; Central Units (4 or 99 zones) are not fully supported yet. See [Channels - Thermo](#configuring-thermo) for more details |
| Alarm | `5` | `bus_alarm_system`, `bus_alarm_zone` | BUS Alarm system and zones | Successfully tested: Burglar-alarm Unit 3486 |
Expand Down Expand Up @@ -131,6 +131,7 @@ For any manually added device, you must configure:
- example for BUS/SCS system:
- light device A=`2` (Area 2), PL=`4` (Light-point 4) --> `where="24"`
- light device A=`03`, PL=`11` on local bus `01` --> `where="0311#4#01"`
- light area A=`5` (Area 5) --> `where="5"`
- scenario control module address `53` --> `where="53"`
- CEN scenario A=`05`, PL=`12` --> `where="0512"`
- CEN+ scenario `5`: add `2` before --> `where="25"`
Expand Down Expand Up @@ -210,7 +211,7 @@ OPEN command to execute: *5*8#134##

| 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 |
| `switch` or `switch_01`/`02` for Zigbee | `bus_on_off_switch`, `bus_light_group`, `zb_on_off_switch`, `zb_on_off_switch2u` | Switch | To switch the device (or group) `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 |
| `scenario`   | `bus_scenario_control` | String | Trigger channel for Basic scenario events [see possible values](#scenario-channels) | R (TRIGGER) |
Expand Down Expand Up @@ -319,6 +320,8 @@ BUS gateway and things configuration:

```java
Bridge openwebnet:bus_gateway:mybridge "MyHOMEServer1" [ host="192.168.1.35", passwd="abcde", port=20000, discoveryByActivation=false ] {
bus_light_group ALL_lights "All lights" [ where="0" ]
bus_light_group LR_area "Living Room Area" [ where="5" ]
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="20050"]
Expand Down Expand Up @@ -361,6 +364,8 @@ NOTE: lights, blinds and zones (thermostat) can be handled from personal assista
In the following example some `Google Assistant` (`ga="..."`) and `HomeKit` (`homekit="..."`) metadata were added as examples according to the [documentation for Google Assistant integration on openHAB](https://www.openhab.org/docs/ecosystem/google-assistant) and [the openHAB HomeKit Add-on documentation](https://www.openhab.org/addons/integrations/homekit/): see the specific documentation for more metadata options and specific configurations.

```java
Switch iALL_lights "All Lights" { channel="openwebnet:bus_light_group:mybridge:ALL_lights:switch", ga="Light", homekit="Lighting" }
Switch iLR_area "Living Room Area" { channel="openwebnet:bus_light_group:mybridge:LR_area:switch", ga="Light", homekit="Lighting" }
Switch iLR_switch "Light" (gLivingRoom) { channel="openwebnet:bus_on_off_switch:mybridge:LR_switch:switch", ga="Light", homekit="Lighting" }
Dimmer iLR_dimmer "Dimmer [%.0f %%]" (gLivingRoom) { channel="openwebnet:bus_dimmer:mybridge:LR_dimmer:brightness", ga="Light", homekit="Lighting" }

Expand Down Expand Up @@ -426,6 +431,8 @@ sitemap openwebnet label="OpenWebNet Binding Example Sitemap"
{
Frame label="Living Room"
{
Default item=iALL_lights icon="light"
Default item=iLR_area icon="light"
Default item=iLR_switch icon="light"
Default item=iLR_dimmer icon="light"
Default item=iLR_shutter
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.binding.openwebnet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>io.github.openwebnet4j</groupId>
<artifactId>openwebnet4j</artifactId>
<version>0.11.0-SNAPSHOT</version>
<version>0.11.0</version>
<scope>compile</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public class OpenWebNetLightingGroupHandler extends OpenWebNetThingHandler {

protected Set<String> listOn = new HashSet<String>();

// TODO private boolean isGeneral = false;

public OpenWebNetLightingGroupHandler(Thing thing) {
super(thing);
}
Expand All @@ -62,7 +60,6 @@ public OpenWebNetLightingGroupHandler(Thing thing) {
public void initialize() {
super.initialize();
WhereLightAutom w = (WhereLightAutom) deviceWhere;
// isGeneral = w.isGeneral();

OpenWebNetBridgeHandler bridge = bridgeHandler;
if (w != null && bridge != null) {
Expand Down Expand Up @@ -201,37 +198,20 @@ protected void handleMessage(BaseOpenMessage msg) {
}
}

/*
* private String getAPLorAreaFromMessage(Lighting lmsg) {
* String oId = null;
* if (!isGeneral) {
* oId = bridgeHandler.ownIdFromMessage(lmsg);
* } else { // add A to GEN
* WhereLightAutom wl = (WhereLightAutom) lmsg.getWhere();
* int area = wl.getArea();
* if (area > 0) {
* oId = this.getManagedWho().value() + "." + area;
* }
* }
* return oId;
* }
*/

@Override
protected Where buildBusWhere(String wStr) throws IllegalArgumentException {
return new WhereLightAutom(wStr);
}

@Override
public void dispose() {
// TODO
Where w = deviceWhere;
if (w != null) {
int area = ((WhereLightAutom) w).getArea();
OpenWebNetBridgeHandler brH = this.bridgeHandler;

// remove light from lightsMap
brH.removeLight(area, this);
if (brH != null) {
brH.removeLight(area, this);
}
}
super.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class OpenWebNetLightingHandler extends OpenWebNetThingHandler {
private int brightness = UNKNOWN_STATE; // current brightness percent value for this device
private int brightnessBeforeOff = UNKNOWN_STATE; // latest brightness before device was set to off

// Set<String> listOn = new HashSet<String>();
@Nullable
String areaOwnId = null;
int area = -1;
Expand Down Expand Up @@ -270,15 +269,13 @@ protected void handleMessage(BaseOpenMessage msg) {
updateOnOffState((Lighting) msg);
}

// TODO WhereLightAutom msgWhere = (WhereLightAutom) msg.getWhere();

OpenWebNetBridgeHandler brH = this.bridgeHandler;
if (brH != null && dw != null && ownId != null && dw.isAPL()) {
// Propagate APL msg to AREA handler, if exists
OpenWebNetLightingGroupHandler areaHandler = (OpenWebNetLightingGroupHandler) brH
.getRegisteredDevice(areaOwnId);
if (areaHandler != null) {
logger.debug("//////////////////// Device {} is Propagating msg {} to AREA handler {}", dw, msg,
logger.debug("//////////////////// Light {} is propagating msg {} to AREA handler {}", dw, msg,
areaOwnId);
areaHandler.handlePropagatedMessage((Lighting) msg, this.ownId);
} else {
Expand All @@ -287,7 +284,7 @@ protected void handleMessage(BaseOpenMessage msg) {
OpenWebNetLightingGroupHandler genHandler = (OpenWebNetLightingGroupHandler) brH
.getRegisteredDevice(genOwnId);
if (genHandler != null) {
logger.debug("//////////////////// Device {} is Propagating msg {} to GEN handler", dw, msg);
logger.debug("//////////////////// Light {} is propagating msg {} to GEN handler", dw, msg);
genHandler.handlePropagatedMessage((Lighting) msg, this.ownId);
}
}
Expand All @@ -300,21 +297,16 @@ protected void handleMultipleMessage(Lighting msg) {
List<OpenWebNetThingHandler> l = null;
if (w.isGeneral()) {
l = this.bridgeHandler.getAllLights();
if (l != null) {
for (OpenWebNetThingHandler hndlr : l) {
hndlr.handleMessage(msg);
}
}
} else if (w.getArea() > 0) {
// l = map.getAreaHandlers(w.getArea());

try {
send(Lighting.requestStatus(w.getArea() + ""));
} catch (OWNException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}
}
if (l != null) {
for (OpenWebNetThingHandler hndlr : l) {
// TODO if (hndlr instanceof OpenWebNetLightingHandler) {
hndlr.handleMessage(msg);
// }
logger.warn("Excpetion while requesting refresh for light area: {}", e.getMessage());
}
}
}
Expand Down Expand Up @@ -474,9 +466,7 @@ public void dispose() {
Where w = deviceWhere;
if (w != null) {
int area = ((WhereLightAutom) w).getArea();

OpenWebNetBridgeHandler brH = this.bridgeHandler;

if (areaOwnId != null) {
// remove light from listOn for Area
OpenWebNetLightingGroupHandler areaHandler = (OpenWebNetLightingGroupHandler) brH
Expand All @@ -487,7 +477,6 @@ public void dispose() {
}
}
}

// remove light from lightsMap
brH.removeLight(area, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ thing-type.openwebnet.bus_energy_meter.label = Energy Meter
thing-type.openwebnet.bus_energy_meter.description = An OpenWebNet BUS/SCS Energy Meter. BTicino models: F52x
thing-type.openwebnet.bus_gateway.label = BUS Gateway
thing-type.openwebnet.bus_gateway.description = This thing allows to connect to an IP BUS/SCS gateway that supports the OpenWebNet protocol (models: F454, MyHOMEServer1, F455, MH200N, F453, etc.)
thing-type.openwebnet.bus_light_group.label = Switch Group
thing-type.openwebnet.bus_light_group.description = An OpenWebNet BUS/SCS group of lights/loads (General, Area or Group BUS addressing).
thing-type.openwebnet.bus_on_off_switch.label = Switch
thing-type.openwebnet.bus_on_off_switch.description = An OpenWebNet BUS/SCS switch for the control of 1 light/load. BTicino models: xxx/yyyy/etc.
thing-type.openwebnet.bus_scenario_control.label = Scenario Control
Expand Down Expand Up @@ -84,6 +86,8 @@ thing-type.config.openwebnet.bus_gateway.passwd.label = Password
thing-type.config.openwebnet.bus_gateway.passwd.description = OpenWebNet gateway password (default: 12345)
thing-type.config.openwebnet.bus_gateway.port.label = Port
thing-type.config.openwebnet.bus_gateway.port.description = OpenWebNet gateway port (default: 20000)
thing-type.config.openwebnet.bus_light_group.where.label = OpenWebNet Address (where)
thing-type.config.openwebnet.bus_light_group.where.description = Example: GEN (general) --> where="0", A=5 (area 5) --> where="5", GR=#25 (group 25) --> where="#25"
thing-type.config.openwebnet.bus_on_off_switch.where.label = OpenWebNet Address (where)
thing-type.config.openwebnet.bus_on_off_switch.where.description = Example: A/PL address: A=1 PL=3 --> where="13". On local bus: where="13#4#01"
thing-type.config.openwebnet.bus_scenario_control.where.label = OpenWebNet Address (where)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</supported-bridge-type-refs>

<label>Switch Group</label>
<description>An OpenWebNet BUS/SCS group of lights/loads (General, Area or Group addressing).</description>
<description>An OpenWebNet BUS/SCS group of lights/loads (General, Area or Group BUS addressing).</description>

<channels>
<channel id="switch" typeId="switch"/>
Expand Down

0 comments on commit b643ed6

Please sign in to comment.