- if the BUS/SCS gateway is configured to accept connections from the openHAB computer IP address, no password should be required
- in all other cases, a password must be configured. This includes gateways that have been discovered and added from Inbox: without a password configured they will remain OFFLINE
- `discoveryByActivation`: discover BUS devices when they are activated also when a device scan hasn't been started from Inbox (`boolean`, _optional_, default: `false`). See [Discovery by Activation](#discovery-by-activation).
+- `dateTimeSynch`: synchronise date and time of slave elements on the SCS BUS using openHAB timestamp (`boolean`, _optional_, default: `false`). Set this parameter to `true` to send time-date synchronisation commands on the BUS when the timestamp received from the gateway differs by more than 1 minute from that of openHAB. Useful if the BUS gateway is not syncronized with Internet time servers and with daylight saving time changes.
Alternatively the BUS/SCS Gateway thing can be configured using the `.things` file, see `openwebnet.things` example [below](#full-example).
import static org.openhab.binding.openwebnet.internal.OpenWebNetBindingConstants.*;
+import java.time.Duration;
+import java.time.ZonedDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
private static final int REFRESH_ALL_CHECK_DELAY_SEC = 20; // Delay to wait to check which devices are
// online/offline
+ private static final int DATETIME_SYNCH_DIFF_SEC = 60; // Difference from BUS date time
+
private long lastRegisteredDeviceTS = -1; // timestamp when the last device has been associated to the bridge
private long refreshAllDevicesDelay = 0; // delay waited before starting all devices refresh
private boolean scanIsActive = false; // a device scan has been activated by OpenWebNetDeviceDiscoveryService;
private boolean discoveryByActivation;
+ private boolean dateTimeSynch = false;
public OpenWebNetBridgeHandler(Bridge bridge) {
super(bridge);
passwdMasked = "******";
}
discoveryByActivation = busBridgeConfig.getDiscoveryByActivation();
- logger.debug("Creating new BUS gateway with config properties: {}:{}, pwd={}, discoveryByActivation={}",
- host, port, passwdMasked, discoveryByActivation);
+ dateTimeSynch = busBridgeConfig.getDateTimeSynch();
+ logger.debug(
+ "Creating new BUS gateway with config properties: {}:{}, pwd={}, discoveryByActivation={}, dateTimeSynch={}",
+ host, port, passwdMasked, discoveryByActivation, dateTimeSynch);
return new BUSGateway(host, port, passwd);
}
}
}
// GATEWAY MANAGEMENT
if (msg instanceof GatewayMgmt) {
- // noop
+ GatewayMgmt gwMsg = (GatewayMgmt) msg;
+ if (dateTimeSynch && GatewayMgmt.DimGatewayMgmt.DATETIME.equals(gwMsg.getDim())) {
+ checkDateTimeDiff(gwMsg);
+ }
return;
}
}
}
+ private void checkDateTimeDiff(GatewayMgmt gwMsg) {
+ try {
+ ZonedDateTime now = ZonedDateTime.now();
+ ZonedDateTime gwTime = GatewayMgmt.parseDateTime(gwMsg);
+ long diff = Math.abs(Duration.between(now, gwTime).toSeconds());
+ if (diff > DATETIME_SYNCH_DIFF_SEC) {
+ logger.debug("checkDateTimeDiff: difference is more than 60s: {}s", diff);
+ OpenGateway gw = gateway;
+ if (gw != null) {
+ logger.debug("checkDateTimeDiff: synch DateTime to: {}", now);
+ try {
+ gw.send(GatewayMgmt.requestSetDateTime(now));
+ } catch (OWNException e) {
+ logger.warn("checkDateTimeDiff: Exception while sending set DateTime command: {}",
+ e.getMessage());
+ }
+ }
+ } else {
+ logger.debug("checkDateTimeDiff: DateTime difference: {}s", diff);
+ }
+ } catch (FrameException e) {
+ logger.warn("checkDateTimeDiff: FrameException while parsing {}", e.getMessage());
+ }
+ }
+
@Override
public void onConnected() {
isGatewayConnected = true;
thing-type.config.openwebnet.bus_dry_contact_ir.where.description = Automation Dry Contacts (N=1-201): example N=60 --> where=360. Alarm Dry Contacts and IR sensors (Zone=1-9, N=1-9): example Zone=4, N=5 --> where=345
thing-type.config.openwebnet.bus_energy_meter.where.label = OpenWebNet Address (where)
thing-type.config.openwebnet.bus_energy_meter.where.description = Example: 5N with N=[1-255]
+thing-type.config.openwebnet.bus_gateway.dateTimeSynch.label = Date Time Synchronisation
+thing-type.config.openwebnet.bus_gateway.dateTimeSynch.description = Synchronise date and time of slave elements on the SCS BUS using openHAB timestamp (default: false)
thing-type.config.openwebnet.bus_gateway.discoveryByActivation.label = Discovery By Activation
thing-type.config.openwebnet.bus_gateway.discoveryByActivation.description = Discover BUS devices when they are activated (also when a device scan is not active) (default: false)
thing-type.config.openwebnet.bus_gateway.host.label = Host