[nikohomecontrol] Prepare for translation (#11319)

* Externalize strings to support translation

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>

* Name events thread.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>

* Fix formatting

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>

* Fix SAT warning

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>

* Fix threadname

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>

* Fix thing lifecycle.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>

* Adjustments from review.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>

* Adjustment from review.

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
pull/11431/head
Mark Herwege 2021-10-23 16:27:56 +02:00 committed by GitHub
parent 5621c906d8
commit e54797f1a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 308 additions and 212 deletions

View File

@ -31,6 +31,9 @@ public class NikoHomeControlBindingConstants {
public static final String BINDING_ID = "nikohomecontrol"; public static final String BINDING_ID = "nikohomecontrol";
// Listener threadname prefix
public static final String THREAD_NAME_PREFIX = "OH-binding-";
// List of all Thing Type UIDs // List of all Thing Type UIDs
// bridge // bridge

View File

@ -66,8 +66,8 @@ public class NikoHomeControlActionHandler extends BaseThingHandler implements Nh
public void handleCommand(ChannelUID channelUID, Command command) { public void handleCommand(ChannelUID channelUID, Command command) {
NikoHomeControlCommunication nhcComm = getCommunication(); NikoHomeControlCommunication nhcComm = getCommunication();
if (nhcComm == null) { if (nhcComm == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"Bridge communication not initialized when trying to execute action command " + actionId); "@text/offline.bridge-unitialized");
return; return;
} }
@ -92,7 +92,7 @@ public class NikoHomeControlActionHandler extends BaseThingHandler implements Nh
logger.debug("handle command {} for {}", command, channelUID); logger.debug("handle command {} for {}", command, channelUID);
if (command == REFRESH) { if (REFRESH.equals(command)) {
actionEvent(nhcAction.getState()); actionEvent(nhcAction.getState());
return; return;
} }
@ -107,15 +107,12 @@ public class NikoHomeControlActionHandler extends BaseThingHandler implements Nh
handleBrightnessCommand(command); handleBrightnessCommand(command);
updateStatus(ThingStatus.ONLINE); updateStatus(ThingStatus.ONLINE);
break; break;
case CHANNEL_ROLLERSHUTTER: case CHANNEL_ROLLERSHUTTER:
handleRollershutterCommand(command); handleRollershutterCommand(command);
updateStatus(ThingStatus.ONLINE); updateStatus(ThingStatus.ONLINE);
break; break;
default: default:
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, logger.debug("unexpected command for channel {}", channelUID.getId());
"Channel unknown " + channelUID.getId());
} }
} }
@ -217,23 +214,25 @@ public class NikoHomeControlActionHandler extends BaseThingHandler implements Nh
NikoHomeControlCommunication nhcComm = getCommunication(); NikoHomeControlCommunication nhcComm = getCommunication();
if (nhcComm == null) { if (nhcComm == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"Connection with controller not started yet, could not initialize action " + actionId); "@text/offline.bridge-unitialized");
return; return;
} else {
updateStatus(ThingStatus.UNKNOWN);
} }
// We need to do this in a separate thread because we may have to wait for the communication to become active // We need to do this in a separate thread because we may have to wait for the communication to become active
scheduler.submit(() -> { scheduler.submit(() -> {
if (!nhcComm.communicationActive()) { if (!nhcComm.communicationActive()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"No connection with controller, could not initialize action " + actionId); "@text/offline.communication-error");
return; return;
} }
NhcAction nhcAction = nhcComm.getActions().get(actionId); NhcAction nhcAction = nhcComm.getActions().get(actionId);
if (nhcAction == null) { if (nhcAction == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Action " + actionId + " does not match an action in the controller"); "@text/offline.configuration-error.actionId");
return; return;
} }
@ -313,7 +312,7 @@ public class NikoHomeControlActionHandler extends BaseThingHandler implements Nh
break; break;
default: default:
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Unknown action type " + actionType); "@text/offline.configuration-error.actionType");
} }
} }
@ -328,7 +327,7 @@ public class NikoHomeControlActionHandler extends BaseThingHandler implements Nh
@Override @Override
public void actionRemoved() { public void actionRemoved() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Action " + actionId + " has been removed from the controller"); "@text/offline.configuration-error.actionRemoved");
} }
private void restartCommunication(NikoHomeControlCommunication nhcComm) { private void restartCommunication(NikoHomeControlCommunication nhcComm) {
@ -337,35 +336,27 @@ public class NikoHomeControlActionHandler extends BaseThingHandler implements Nh
nhcComm.restartCommunication(); nhcComm.restartCommunication();
// If still not active, take thing offline and return. // If still not active, take thing offline and return.
if (!nhcComm.communicationActive()) { if (!nhcComm.communicationActive()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Communication error"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.communication-error");
return; return;
} }
// Also put the bridge back online // Also put the bridge back online
NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler(); NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler();
if (nhcBridgeHandler != null) { if (nhcBridgeHandler != null) {
nhcBridgeHandler.bridgeOnline(); nhcBridgeHandler.bridgeOnline();
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"@text/offline.bridge-unitialized");
} }
} }
private @Nullable NikoHomeControlCommunication getCommunication() { private @Nullable NikoHomeControlCommunication getCommunication() {
NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler(); NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler();
if (nhcBridgeHandler == null) { return nhcBridgeHandler != null ? nhcBridgeHandler.getCommunication() : null;
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"No bridge initialized for action " + actionId);
return null;
}
NikoHomeControlCommunication nhcComm = nhcBridgeHandler.getCommunication();
return nhcComm;
} }
private @Nullable NikoHomeControlBridgeHandler getBridgeHandler() { private @Nullable NikoHomeControlBridgeHandler getBridgeHandler() {
Bridge nhcBridge = getBridge(); Bridge nhcBridge = getBridge();
if (nhcBridge == null) { return nhcBridge != null ? (NikoHomeControlBridgeHandler) nhcBridge.getHandler() : null;
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"No bridge initialized for action " + actionId);
return null;
}
NikoHomeControlBridgeHandler nhcBridgeHandler = (NikoHomeControlBridgeHandler) nhcBridge.getHandler();
return nhcBridgeHandler;
} }
} }

View File

@ -77,6 +77,8 @@ public abstract class NikoHomeControlBridgeHandler extends BaseBridgeHandler imp
return; return;
} }
updateStatus(ThingStatus.UNKNOWN);
scheduler.submit(() -> { scheduler.submit(() -> {
comm.startCommunication(); comm.startCommunication();
if (!comm.communicationActive()) { if (!comm.communicationActive()) {
@ -141,7 +143,7 @@ public abstract class NikoHomeControlBridgeHandler extends BaseBridgeHandler imp
*/ */
protected void bridgeOffline() { protected void bridgeOffline() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
"Error with bridge connection"); "@text/offline.communication-error");
} }
/** /**

View File

@ -12,6 +12,8 @@
*/ */
package org.openhab.binding.nikohomecontrol.internal.handler; package org.openhab.binding.nikohomecontrol.internal.handler;
import static org.openhab.binding.nikohomecontrol.internal.NikoHomeControlBindingConstants.THREAD_NAME_PREFIX;
import java.net.InetAddress; import java.net.InetAddress;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -50,11 +52,12 @@ public class NikoHomeControlBridgeHandler1 extends NikoHomeControlBridgeHandler
logger.debug("bridge handler host {}, port {}", addr, port); logger.debug("bridge handler host {}, port {}", addr, port);
if (addr != null) { if (addr != null) {
nhcComm = new NikoHomeControlCommunication1(this, scheduler); String eventThreadName = THREAD_NAME_PREFIX + thing.getUID().getAsString();
nhcComm = new NikoHomeControlCommunication1(this, scheduler, eventThreadName);
startCommunication(); startCommunication();
} else { } else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR,
"Cannot resolve bridge IP with hostname " + config.addr); "@text/offline.configuration-error.ip");
} }
} }

View File

@ -69,14 +69,15 @@ public class NikoHomeControlBridgeHandler2 extends NikoHomeControlBridgeHandler
// advanced configuration, skipping token validation. // advanced configuration, skipping token validation.
// This behavior would allow the same logic to be used (with profile UUID) as before token validation // This behavior would allow the same logic to be used (with profile UUID) as before token validation
// was introduced. // was introduced.
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, "Token is empty"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR,
"@text/offline.configuration-error.tokenEmpty");
return; return;
} }
} else { } else {
Date now = new Date(); Date now = new Date();
if (expiryDate.before(now)) { if (expiryDate.before(now)) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.CONFIGURATION_ERROR,
"Hobby api token has expired"); "@text/offline.configuration-error.tokenExpired");
return; return;
} }
} }
@ -90,7 +91,7 @@ public class NikoHomeControlBridgeHandler2 extends NikoHomeControlBridgeHandler
} catch (CertificateException e) { } catch (CertificateException e) {
// this should not happen unless there is a programming error // this should not happen unless there is a programming error
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.OFFLINE.COMMUNICATION_ERROR,
"Not able to set SSL context"); "@text/offline.communication-error");
return; return;
} }
} }

View File

@ -64,7 +64,7 @@ public class NikoHomeControlEnergyMeterHandler extends BaseThingHandler implemen
return; return;
} }
if (command == REFRESH) { if (REFRESH.equals(command)) {
energyMeterEvent(nhcEnergyMeter.getPower()); energyMeterEvent(nhcEnergyMeter.getPower());
} }
} }
@ -77,9 +77,11 @@ public class NikoHomeControlEnergyMeterHandler extends BaseThingHandler implemen
NikoHomeControlCommunication nhcComm = getCommunication(); NikoHomeControlCommunication nhcComm = getCommunication();
if (nhcComm == null) { if (nhcComm == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"Connection with controller not started yet, could not initialize energy meter " + energyMeterId); "@text/offline.bridge-unitialized");
return; return;
} else {
updateStatus(ThingStatus.UNKNOWN);
} }
// We need to do this in a separate thread because we may have to wait for the // We need to do this in a separate thread because we may have to wait for the
@ -87,14 +89,14 @@ public class NikoHomeControlEnergyMeterHandler extends BaseThingHandler implemen
scheduler.submit(() -> { scheduler.submit(() -> {
if (!nhcComm.communicationActive()) { if (!nhcComm.communicationActive()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"No connection with controller, could not initialize energy meter " + energyMeterId); "@text/offline.communication-error");
return; return;
} }
NhcEnergyMeter nhcEnergyMeter = nhcComm.getEnergyMeters().get(energyMeterId); NhcEnergyMeter nhcEnergyMeter = nhcComm.getEnergyMeters().get(energyMeterId);
if (nhcEnergyMeter == null) { if (nhcEnergyMeter == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Energy meter " + energyMeterId + " does not match a energy meter in the controller"); "@text/offline.configuration-error.energyMeterId");
return; return;
} }
@ -163,7 +165,7 @@ public class NikoHomeControlEnergyMeterHandler extends BaseThingHandler implemen
@Override @Override
public void energyMeterRemoved() { public void energyMeterRemoved() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Energy meter " + energyMeterId + " has been removed from the controller"); "@text/offline.configuration-error.energyMeterRemoved");
} }
@Override @Override
@ -171,47 +173,40 @@ public class NikoHomeControlEnergyMeterHandler extends BaseThingHandler implemen
// the channel // the channel
public void channelLinked(ChannelUID channelUID) { public void channelLinked(ChannelUID channelUID) {
NikoHomeControlCommunication nhcComm = getCommunication(); NikoHomeControlCommunication nhcComm = getCommunication();
if (nhcComm == null) { if (nhcComm != null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, // This can be expensive, therefore do it in a job.
"Bridge communication not initialized when trying to start energy meter " + energyMeterId); scheduler.submit(() -> {
return; if (!nhcComm.communicationActive()) {
restartCommunication(nhcComm);
}
if (nhcComm.communicationActive()) {
nhcComm.startEnergyMeter(energyMeterId);
updateStatus(ThingStatus.ONLINE);
}
});
} }
// This can be expensive, therefore do it in a job.
scheduler.submit(() -> {
if (!nhcComm.communicationActive()) {
restartCommunication(nhcComm);
}
if (nhcComm.communicationActive()) {
nhcComm.startEnergyMeter(energyMeterId);
updateStatus(ThingStatus.ONLINE);
}
});
} }
@Override @Override
public void channelUnlinked(ChannelUID channelUID) { public void channelUnlinked(ChannelUID channelUID) {
NikoHomeControlCommunication nhcComm = getCommunication(); NikoHomeControlCommunication nhcComm = getCommunication();
if (nhcComm == null) { if (nhcComm != null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, // This can be expensive, therefore do it in a job.
"Bridge communication not initialized when trying to stop energy meter " + energyMeterId); scheduler.submit(() -> {
return; if (!nhcComm.communicationActive()) {
restartCommunication(nhcComm);
}
if (nhcComm.communicationActive()) {
nhcComm.stopEnergyMeter(energyMeterId);
// as this is momentary power production/consumption, we set it UNDEF as we do not get readings
// anymore
updateState(CHANNEL_POWER, UnDefType.UNDEF);
updateStatus(ThingStatus.ONLINE);
}
});
} }
// This can be expensive, therefore do it in a job.
scheduler.submit(() -> {
if (!nhcComm.communicationActive()) {
restartCommunication(nhcComm);
}
if (nhcComm.communicationActive()) {
nhcComm.stopEnergyMeter(energyMeterId);
// as this is momentary power production/consumption, we set it UNDEF as we do not get readings anymore
updateState(CHANNEL_POWER, UnDefType.UNDEF);
updateStatus(ThingStatus.ONLINE);
}
});
} }
private void restartCommunication(NikoHomeControlCommunication nhcComm) { private void restartCommunication(NikoHomeControlCommunication nhcComm) {
@ -220,35 +215,27 @@ public class NikoHomeControlEnergyMeterHandler extends BaseThingHandler implemen
nhcComm.restartCommunication(); nhcComm.restartCommunication();
// If still not active, take thing offline and return. // If still not active, take thing offline and return.
if (!nhcComm.communicationActive()) { if (!nhcComm.communicationActive()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Communication error"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.communication-error");
return; return;
} }
// Also put the bridge back online // Also put the bridge back online
NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler(); NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler();
if (nhcBridgeHandler != null) { if (nhcBridgeHandler != null) {
nhcBridgeHandler.bridgeOnline(); nhcBridgeHandler.bridgeOnline();
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"@text/offline.bridge-unitialized");
} }
} }
private @Nullable NikoHomeControlCommunication getCommunication() { private @Nullable NikoHomeControlCommunication getCommunication() {
NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler(); NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler();
if (nhcBridgeHandler == null) { return nhcBridgeHandler != null ? nhcBridgeHandler.getCommunication() : null;
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"No bridge initialized for energy meter " + energyMeterId);
return null;
}
NikoHomeControlCommunication nhcComm = nhcBridgeHandler.getCommunication();
return nhcComm;
} }
private @Nullable NikoHomeControlBridgeHandler getBridgeHandler() { private @Nullable NikoHomeControlBridgeHandler getBridgeHandler() {
Bridge nhcBridge = getBridge(); Bridge nhcBridge = getBridge();
if (nhcBridge == null) { return nhcBridge != null ? (NikoHomeControlBridgeHandler) nhcBridge.getHandler() : null;
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"No bridge initialized for energy meter " + energyMeterId);
return null;
}
NikoHomeControlBridgeHandler nhcBridgeHandler = (NikoHomeControlBridgeHandler) nhcBridge.getHandler();
return nhcBridgeHandler;
} }
} }

View File

@ -68,9 +68,8 @@ public class NikoHomeControlThermostatHandler extends BaseThingHandler implement
public void handleCommand(ChannelUID channelUID, Command command) { public void handleCommand(ChannelUID channelUID, Command command) {
NikoHomeControlCommunication nhcComm = getCommunication(); NikoHomeControlCommunication nhcComm = getCommunication();
if (nhcComm == null) { if (nhcComm == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"Bridge communication not initialized when trying to execute thermostat command on " "@text/offline.bridge-unitialized");
+ thermostatId);
return; return;
} }
@ -143,10 +142,8 @@ public class NikoHomeControlThermostatHandler extends BaseThingHandler implement
} }
updateStatus(ThingStatus.ONLINE); updateStatus(ThingStatus.ONLINE);
break; break;
default: default:
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, logger.debug("unexpected command for channel {}", channelUID.getId());
"Channel unknown " + channelUID.getId());
} }
} }
@ -159,9 +156,11 @@ public class NikoHomeControlThermostatHandler extends BaseThingHandler implement
NikoHomeControlCommunication nhcComm = getCommunication(); NikoHomeControlCommunication nhcComm = getCommunication();
if (nhcComm == null) { if (nhcComm == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"Connection with controller not started yet, could not initialize thermostat " + thermostatId); "@text/offline.bridge-unitialized");
return; return;
} else {
updateStatus(ThingStatus.UNKNOWN);
} }
// We need to do this in a separate thread because we may have to wait for the // We need to do this in a separate thread because we may have to wait for the
@ -169,14 +168,14 @@ public class NikoHomeControlThermostatHandler extends BaseThingHandler implement
scheduler.submit(() -> { scheduler.submit(() -> {
if (!nhcComm.communicationActive()) { if (!nhcComm.communicationActive()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"No connection with controller, could not initialize thermostat " + thermostatId); "@text/offline.communication-error");
return; return;
} }
NhcThermostat nhcThermostat = nhcComm.getThermostats().get(thermostatId); NhcThermostat nhcThermostat = nhcComm.getThermostats().get(thermostatId);
if (nhcThermostat == null) { if (nhcThermostat == null) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Thermostat " + thermostatId + " does not match a thermostat in the controller"); "@text/offline.configuration-error.thermostatId");
return; return;
} }
@ -288,7 +287,7 @@ public class NikoHomeControlThermostatHandler extends BaseThingHandler implement
@Override @Override
public void thermostatRemoved() { public void thermostatRemoved() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
"Thermostat " + thermostatId + " has been removed from the controller"); "@text/offline.configuration-error.thermostatRemoved");
} }
private void restartCommunication(NikoHomeControlCommunication nhcComm) { private void restartCommunication(NikoHomeControlCommunication nhcComm) {
@ -297,35 +296,27 @@ public class NikoHomeControlThermostatHandler extends BaseThingHandler implement
nhcComm.restartCommunication(); nhcComm.restartCommunication();
// If still not active, take thing offline and return. // If still not active, take thing offline and return.
if (!nhcComm.communicationActive()) { if (!nhcComm.communicationActive()) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Communication error"); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.communication-error");
return; return;
} }
// Also put the bridge back online // Also put the bridge back online
NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler(); NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler();
if (nhcBridgeHandler != null) { if (nhcBridgeHandler != null) {
nhcBridgeHandler.bridgeOnline(); nhcBridgeHandler.bridgeOnline();
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"@text/offline.bridge-unitialized");
} }
} }
private @Nullable NikoHomeControlCommunication getCommunication() { private @Nullable NikoHomeControlCommunication getCommunication() {
NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler(); NikoHomeControlBridgeHandler nhcBridgeHandler = getBridgeHandler();
if (nhcBridgeHandler == null) { return nhcBridgeHandler != null ? nhcBridgeHandler.getCommunication() : null;
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"No bridge initialized for thermostat " + thermostatId);
return null;
}
NikoHomeControlCommunication nhcComm = nhcBridgeHandler.getCommunication();
return nhcComm;
} }
private @Nullable NikoHomeControlBridgeHandler getBridgeHandler() { private @Nullable NikoHomeControlBridgeHandler getBridgeHandler() {
Bridge nhcBridge = getBridge(); Bridge nhcBridge = getBridge();
if (nhcBridge == null) { return nhcBridge != null ? (NikoHomeControlBridgeHandler) nhcBridge.getHandler() : null;
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.BRIDGE_UNINITIALIZED,
"No bridge initialized for thermostat " + thermostatId);
return null;
}
NikoHomeControlBridgeHandler nhcBridgeHandler = (NikoHomeControlBridgeHandler) nhcBridge.getHandler();
return nhcBridgeHandler;
} }
} }

View File

@ -105,10 +105,7 @@ public final class NikoHomeControlDiscover {
*/ */
private boolean isNhc(DatagramPacket packet) { private boolean isNhc(DatagramPacket packet) {
byte[] packetData = packet.getData(); byte[] packetData = packet.getData();
if ((packet.getLength() > 2) && (packetData[0] == 0x44)) { return ((packet.getLength() > 2) && (packetData[0] == 0x44));
return true;
}
return false;
} }
/** /**

View File

@ -12,6 +12,8 @@
*/ */
package org.openhab.binding.nikohomecontrol.internal.protocol.nhc1; package org.openhab.binding.nikohomecontrol.internal.protocol.nhc1;
import static org.openhab.binding.nikohomecontrol.internal.NikoHomeControlBindingConstants.THREAD_NAME_PREFIX;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -56,6 +58,8 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
private Logger logger = LoggerFactory.getLogger(NikoHomeControlCommunication1.class); private Logger logger = LoggerFactory.getLogger(NikoHomeControlCommunication1.class);
private String eventThreadName = THREAD_NAME_PREFIX;
private final NhcSystemInfo1 systemInfo = new NhcSystemInfo1(); private final NhcSystemInfo1 systemInfo = new NhcSystemInfo1();
private final Map<String, NhcLocation1> locations = new ConcurrentHashMap<>(); private final Map<String, NhcLocation1> locations = new ConcurrentHashMap<>();
@ -77,9 +81,11 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
* Niko Home Control IP-interface. * Niko Home Control IP-interface.
* *
*/ */
public NikoHomeControlCommunication1(NhcControllerEvent handler, ScheduledExecutorService scheduler) { public NikoHomeControlCommunication1(NhcControllerEvent handler, ScheduledExecutorService scheduler,
String eventThreadName) {
super(handler); super(handler);
this.scheduler = scheduler; this.scheduler = scheduler;
this.eventThreadName = eventThreadName;
// When we set up this object, we want to get the proper gson adapter set up once // When we set up this object, we want to get the proper gson adapter set up once
GsonBuilder gsonBuilder = new GsonBuilder(); GsonBuilder gsonBuilder = new GsonBuilder();
@ -113,11 +119,11 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
// Start Niko Home Control event listener. This listener will act on all messages coming from // Start Niko Home Control event listener. This listener will act on all messages coming from
// IP-interface. // IP-interface.
(new Thread(this::runNhcEvents)).start(); (new Thread(this::runNhcEvents, eventThreadName)).start();
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
stopCommunication(); stopCommunication();
handler.controllerOffline("Error initializing communication"); handler.controllerOffline("@text/offline.communication-error");
} }
} }
@ -227,7 +233,7 @@ public class NikoHomeControlCommunication1 extends NikoHomeControlCommunication
logger.debug("resend json {}", json); logger.debug("resend json {}", json);
nhcOut.println(json); nhcOut.println(json);
if (nhcOut.checkError()) { if (nhcOut.checkError()) {
handler.controllerOffline("Error resending message"); handler.controllerOffline("@text/offline.communication-error");
} }
} }
} }

View File

@ -778,8 +778,7 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
mqttConnection.connectionPublish(topic, gsonMessage); mqttConnection.connectionPublish(topic, gsonMessage);
} catch (MqttException e) { } catch (MqttException e) {
String message = e.getMessage(); String message = e.getLocalizedMessage();
message = (message != null) ? message : "Communication error";
logger.debug("sending command failed, trying to restart communication"); logger.debug("sending command failed, trying to restart communication");
restartCommunication(); restartCommunication();
@ -791,12 +790,12 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
logger.debug("failed to restart communication"); logger.debug("failed to restart communication");
} }
} catch (MqttException e1) { } catch (MqttException e1) {
message = e1.getMessage(); message = e1.getLocalizedMessage();
message = (message != null) ? message : "Communication error";
logger.debug("error resending device command"); logger.debug("error resending device command");
} }
if (!communicationActive()) { if (!communicationActive()) {
message = (message != null) ? message : "@text/offline.communication-error";
connectionLost(message); connectionLost(message);
} }
} }
@ -862,8 +861,8 @@ public class NikoHomeControlCommunication2 extends NikoHomeControlCommunication
public void connectionStateChanged(MqttConnectionState state, @Nullable Throwable error) { public void connectionStateChanged(MqttConnectionState state, @Nullable Throwable error) {
if (error != null) { if (error != null) {
logger.debug("Connection state: {}", state, error); logger.debug("Connection state: {}", state, error);
String message = error.getMessage(); String message = error.getLocalizedMessage();
message = (message != null) ? message : "Error communicating with the controller"; message = (message != null) ? message : "@text/offline.communication-error";
if (!MqttConnectionState.CONNECTING.equals(state)) { if (!MqttConnectionState.CONNECTING.equals(state)) {
// This is a connection loss, try to restart // This is a connection loss, try to restart
restartCommunication(); restartCommunication();

View File

@ -3,6 +3,6 @@
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0" xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd"> xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">
<name>Niko Home Control Binding</name> <name>@text/bindingName</name>
<description>This is the binding for the Niko Home Control system</description> <description>@text/bindingDescription</description>
</binding:binding> </binding:binding>

View File

@ -0,0 +1,120 @@
# binding
bindingName = Niko Home Control Binding
bindingDescription = This is the binding for the Niko Home Control system
# bridge types
bridgeLabel = Niko Home Control I Bridge
bridgeDescription = This bridge represents a Niko Home Control I IP-interface
bridge2Label = Niko Home Control II Bridge
bridge2Description = This bridge represents a Niko Home Control II Connected Controller or Wireless Smart Hub
bridgeConfigAddressLabel = IP or Host Name
bridgeConfigAddressDescription = IP Address of Niko Home Control IP-interface
bridge2ConfigAddressDescription = IP Address of Connected Controller or Wireless Smart Hub
bridgeConfigPortLabel = Bridge Port
bridgeConfigPortDescription = Port to communicate with Niko Home Control IP-interface, default 8000
bridge2ConfigPortDescription = Port for secure MQTT communication with Connected Controller or Wireless Smart Hub, default 8884
bridge2ConfigProfileLabel = Profile
bridge2ConfigProfileDescription = Profile used in Niko Home Control II for hobby API
bridge2ConfigPasswordLabel = API Token
bridge2ConfigPasswordDescription = Token for Niko Home Control II hobby API, should not be empty. This token will have to be renewed after expiration (1 year after creation)
bridgeConfigRefreshLabel = Refresh Interval
bridgeConfigRefreshDescription = Refresh interval for connection with Niko Home Control IP-interface (min), default 300. If set to 0 or left empty, no refresh will be scheduled
bridge2ConfigRefreshDescription = Refresh interval for connection with Connected Controller or Wireless Smart Hub (min), default 300. If set to 0 or left empty, no refresh will be scheduled
# thing types
pushButtonLabel = Pushbutton
pushButtonDescription = Pushbutton type action in Niko Home Control
onOffLabel = Switch
onOffDescription = On/Off type action in Niko Home Control
dimmerLabel = Dimmer
dimmerDescription = Dimmer type action in Niko Home Control
blindLabel = Shutter
blindDescription = Rollershutter type action in Niko Home Control
thermostatLabel = Thermostat
thermostatDescription = Thermostat in the Niko Home Control system
energyMeterLabel = Energy Meter
energyMeterDescription = Energy meter in the Niko Home Control system
actionConfigActionIdLabel = Action ID
actionConfigActionIdDescription = Niko Home Control action ID
dimmerConfigStepLabel = Step Value
dimmerConfigStepDescription = Step value used for increase/decrease of dimmer brightness, default 10%
blindConfigInvertLabel = Invert Direction
blindConfigInvertDescription = Invert rollershutter direction
thermostatConfigThermostatIdLabel = Thermostat ID
thermostatConfigThermostatIdDescription = Niko Home Control Thermostat ID
thermostatConfigOverruleTimeLabel = Overrule Time
thermostatConfigOverruleTimeDescription = Default overrule duration in minutes when an overrule temperature is set without providing overrule \
time, 60 minutes by default
energyMeterConfigEnergyMeterIdLabel = Energy Meter ID
energyMeterConfigEnergyMeterIdDescription = Niko Home Control Energy Meter ID
#channel types
channelButtonLabel = Button
channelButtonDescription = Pushbutton control for action in Niko Home Control
channelRollershutterLabel = Rollershutter
channelRollershutterDescription = Rollershutter control for rollershutter action in Niko Home Control
channelMeasuredLabel = Measured
channelMeasuredDescription = Temperature measured by thermostat
channelSetpointLabel = Setpoint
channelSetpointDescription = Setpoint temperature of thermostat
channelOverruletimeLabel = Overrule Time
channelOverruletimeDescription = Time duration for overruling thermostat target temperature in min.
channelModeLabel = Mode
channelModeDescription = Thermostat mode
channelModeOption0 = day
channelModeOption1 = night
channelModeOption2 = eco
channelModeOption3 = off
channelModeOption4 = cool
channelModeOption5 = prog 1
channelModeOption6 = prog 2
channelModeOption7 = prog 3
channelPowerLabel = Power
channelPowerDescription = Momentary power consumption/production (positive is consumption)
channelAlarmLabel = Alarm
channelAlarmDescription = Alarm from Niko Home Control
channelNoticeLabel = Notice
channelNoticeDescription = Notice from Niko Home Control
# thing status messages
offline.configuration-error.ip = Cannot resolve bridge IP with given host name
offline.configuration-error.tokenEmpty = Hobby API token is empty
offline.configuration-error.tokenExpired = Hobby API token has expired
offline.configuration-error.actionId = Configured action ID does not match an action in controller
offline.configuration-error.actionType = Unsupported action type
offline.configuration-error.actionRemoved = Action has been removed from controller
offline.configuration-error.energyMeterId = Configured energy meter ID does not match an energy meter in controller
offline.configuration-error.energyMeterRemoved = Energy meter has been removed from controller
offline.configuration-error.thermostatId = Configured thermostat ID does not match an thermostat in controller
offline.configuration-error.thermostatRemoved = Thermostat has been removed from controller
offline.communication-error = Error communicating with controller
offline.bridge-unitialized = Bridge not initialized

View File

@ -5,70 +5,67 @@
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd"> xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
<bridge-type id="bridge"> <bridge-type id="bridge">
<label>Niko Home Control I Bridge</label> <label>@text/bridgeLabel</label>
<description>This bridge represents a Niko Home Control I IP-interface</description> <description>@text/bridgeDescription</description>
<channels> <channels>
<channel id="alarm" typeId="alarm"/> <channel id="alarm" typeId="alarm"/>
<channel id="notice" typeId="notice"/> <channel id="notice" typeId="notice"/>
</channels> </channels>
<config-description> <config-description>
<parameter name="addr" type="text" required="true"> <parameter name="addr" type="text" required="true">
<label>IP or Host Name</label> <label>@text/bridgeConfigAddressLabel</label>
<description>IP Address of Niko Home Control IP-interface</description> <description>@text/bridgeConfigAddressDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
<context>network-address</context> <context>network-address</context>
</parameter> </parameter>
<parameter name="port" type="integer"> <parameter name="port" type="integer">
<label>Bridge Port</label> <label>@text/bridgeConfigPortLabel</label>
<description>Port to communicate with Niko Home Control IP-interface, default 8000</description> <description>@text/bridgeConfigPortDescription</description>
<default>8000</default> <default>8000</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
<parameter name="refresh" type="integer"> <parameter name="refresh" type="integer">
<label>Refresh Interval</label> <label>@text/bridgeConfigRefreshLabel</label>
<description>Refresh interval for connection with Niko Home Control IP-interface (min), default 300. If set to 0 or <description>@text/bridgeConfigRefreshDescription</description>
left empty, no refresh will be scheduled</description>
<default>300</default> <default>300</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
</config-description> </config-description>
</bridge-type> </bridge-type>
<bridge-type id="bridge2"> <bridge-type id="bridge2">
<label>Niko Home Control II Bridge</label> <label>@text/bridge2Label</label>
<description>This bridge represents a Niko Home Control II Connected Controller</description> <description>@text/bridge2Description</description>
<channels> <channels>
<channel id="alarm" typeId="alarm"/> <channel id="alarm" typeId="alarm"/>
<channel id="notice" typeId="notice"/> <channel id="notice" typeId="notice"/>
</channels> </channels>
<config-description> <config-description>
<parameter name="addr" type="text" required="true"> <parameter name="addr" type="text" required="true">
<label>IP or Host Name</label> <label>@text/bridgeConfigAddressLabel</label>
<description>IP Address of Connected Controller</description> <description>@text/bridge2ConfigAddressDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
<context>network-address</context> <context>network-address</context>
</parameter> </parameter>
<parameter name="port" type="integer"> <parameter name="port" type="integer">
<label>Bridge Port</label> <label>@text/bridgeConfigPortLabel</label>
<description>Port for secure MQTT communication with Connected Controller, default 8884</description> <description>@text/bridge2ConfigPortDescription</description>
<default>8884</default> <default>8884</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
<parameter name="profile" type="text"> <parameter name="profile" type="text">
<label>Profile</label> <label>@text/bridge2ConfigProfileLabel</label>
<description>Profile used in Niko Home Control II for hobby API</description> <description>@text/bridge2ConfigProfileDescription</description>
<default>hobby</default> <default>hobby</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
<parameter name="password" type="text" required="true"> <parameter name="password" type="text" required="true">
<label>API Token</label> <label>@text/bridge2ConfigPasswordLabel</label>
<description>Token for Niko Home Control II hobby API, should not be empty. This token will have to be renewed after <description>@text/bridge2ConfigPasswordDescription</description>
expiration (1 year after creation)</description>
<context>password</context> <context>password</context>
</parameter> </parameter>
<parameter name="refresh" type="integer"> <parameter name="refresh" type="integer">
<label>Refresh Interval</label> <label>@text/bridgeConfigRefreshLabel</label>
<description>Refresh interval for connection with Connected Controller (min), default 300. If set to 0 or left <description>@text/bridge2ConfigRefreshDescription</description>
empty, no refresh will be scheduled</description>
<default>300</default> <default>300</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
@ -80,15 +77,15 @@
<bridge-type-ref id="bridge"/> <bridge-type-ref id="bridge"/>
<bridge-type-ref id="bridge2"/> <bridge-type-ref id="bridge2"/>
</supported-bridge-type-refs> </supported-bridge-type-refs>
<label>Pushbutton</label> <label>@text/pushButtonLabel</label>
<description>Pushbutton type action in Niko Home Control</description> <description>@text/pushButtonDescription</description>
<channels> <channels>
<channel id="button" typeId="button"/> <channel id="button" typeId="button"/>
</channels> </channels>
<config-description> <config-description>
<parameter name="actionId" type="text" required="true"> <parameter name="actionId" type="text" required="true">
<label>Action ID</label> <label>@text/actionConfigActionIdLabel</label>
<description>Niko Home Control action ID</description> <description>@text/actionConfigActionIdDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
</parameter> </parameter>
</config-description> </config-description>
@ -98,15 +95,15 @@
<bridge-type-ref id="bridge"/> <bridge-type-ref id="bridge"/>
<bridge-type-ref id="bridge2"/> <bridge-type-ref id="bridge2"/>
</supported-bridge-type-refs> </supported-bridge-type-refs>
<label>Switch</label> <label>@text/onOffLabel</label>
<description>On/Off type action in Niko Home Control</description> <description>@text/onOffDescription</description>
<channels> <channels>
<channel id="switch" typeId="system.power"/> <channel id="switch" typeId="system.power"/>
</channels> </channels>
<config-description> <config-description>
<parameter name="actionId" type="text" required="true"> <parameter name="actionId" type="text" required="true">
<label>Action ID</label> <label>@text/actionConfigActionIdLabel</label>
<description>Niko Home Control action ID</description> <description>@text/actionConfigActionIdDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
</parameter> </parameter>
</config-description> </config-description>
@ -116,20 +113,20 @@
<bridge-type-ref id="bridge"/> <bridge-type-ref id="bridge"/>
<bridge-type-ref id="bridge2"/> <bridge-type-ref id="bridge2"/>
</supported-bridge-type-refs> </supported-bridge-type-refs>
<label>Dimmer</label> <label>@text/dimmerLabel</label>
<description>Dimmer type action in Niko Home Control</description> <description>@text/dimmerDescription</description>
<channels> <channels>
<channel id="brightness" typeId="system.brightness"/> <channel id="brightness" typeId="system.brightness"/>
</channels> </channels>
<config-description> <config-description>
<parameter name="actionId" type="text" required="true"> <parameter name="actionId" type="text" required="true">
<label>Action ID</label> <label>@text/actionConfigActionIdLabel</label>
<description>Niko Home Control action ID</description> <description>@text/actionConfigActionIdDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
</parameter> </parameter>
<parameter name="step" type="integer"> <parameter name="step" type="integer">
<label>Step Value</label> <label>@text/dimmerConfigStepLabel</label>
<description>Step value used for increase/decrease of dimmer brightness, default 10%</description> <description>@text/dimmerConfigStepValue</description>
<default>10</default> <default>10</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
@ -140,20 +137,20 @@
<bridge-type-ref id="bridge"/> <bridge-type-ref id="bridge"/>
<bridge-type-ref id="bridge2"/> <bridge-type-ref id="bridge2"/>
</supported-bridge-type-refs> </supported-bridge-type-refs>
<label>Shutter</label> <label>@text/blindLabel</label>
<description>Rollershutter type action in Niko Home Control</description> <description>@text/blindDescription</description>
<channels> <channels>
<channel id="rollershutter" typeId="rollershutter"/> <channel id="rollershutter" typeId="rollershutter"/>
</channels> </channels>
<config-description> <config-description>
<parameter name="actionId" type="text" required="true"> <parameter name="actionId" type="text" required="true">
<label>Action ID</label> <label>@text/actionConfigActionIdLabel</label>
<description>Niko Home Control action ID</description> <description>@text/actionConfigActionIdDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
</parameter> </parameter>
<parameter name="invert" type="boolean"> <parameter name="invert" type="boolean">
<label>Invert Direction</label> <label>@text/blindConfigInvertLabel</label>
<description>Invert rollershutter direction</description> <description>@text/blindConfigInvertDescription</description>
<default>false</default> <default>false</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
@ -164,8 +161,8 @@
<bridge-type-ref id="bridge"/> <bridge-type-ref id="bridge"/>
<bridge-type-ref id="bridge2"/> <bridge-type-ref id="bridge2"/>
</supported-bridge-type-refs> </supported-bridge-type-refs>
<label>Thermostat</label> <label>@textThermostatLabel</label>
<description>Thermostat in the Niko Home Control system</description> <description>@textThermostatDescription</description>
<channels> <channels>
<channel id="measured" typeId="measured"/> <channel id="measured" typeId="measured"/>
<channel id="mode" typeId="mode"/> <channel id="mode" typeId="mode"/>
@ -174,14 +171,13 @@
</channels> </channels>
<config-description> <config-description>
<parameter name="thermostatId" type="text" required="true"> <parameter name="thermostatId" type="text" required="true">
<label>Thermostat ID</label> <label>@text/thermostatConfigThermostatIdLabel</label>
<description>Niko Home Control Thermostat ID</description> <description>@text/thermostatConfigThermostatIdDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
</parameter> </parameter>
<parameter name="overruleTime" type="integer"> <parameter name="overruleTime" type="integer">
<label>Overrule Time</label> <label>@text/thermostatConfigOverruleTimeLabel</label>
<description>Default overrule duration in minutes when an overrule temperature is set without providing overrule <description>@text/thermostatConfigOverruleTimeDescription</description>
time, 60 minutes by default</description>
<default>60</default> <default>60</default>
<advanced>true</advanced> <advanced>true</advanced>
</parameter> </parameter>
@ -191,15 +187,15 @@
<supported-bridge-type-refs> <supported-bridge-type-refs>
<bridge-type-ref id="bridge2"/> <bridge-type-ref id="bridge2"/>
</supported-bridge-type-refs> </supported-bridge-type-refs>
<label>Energy Meter</label> <label>@text/energyMeterLabel</label>
<description>Energy meter in the Niko Home Control system</description> <description>@text/energyMeterDescription</description>
<channels> <channels>
<channel id="power" typeId="power"/> <channel id="power" typeId="power"/>
</channels> </channels>
<config-description> <config-description>
<parameter name="energyMeterId" type="text" required="true"> <parameter name="energyMeterId" type="text" required="true">
<label>Energy Meter ID</label> <label>@text/energyMeterConfigEnergyMeterIdLabel</label>
<description>Niko Home Control Energy Meter ID</description> <description>@text/energyMeterConfigEnergyMeterIdDescription</description>
<advanced>false</advanced> <advanced>false</advanced>
</parameter> </parameter>
</config-description> </config-description>
@ -207,22 +203,22 @@
<channel-type id="button"> <channel-type id="button">
<item-type>Switch</item-type> <item-type>Switch</item-type>
<label>Button</label> <label>@text/channelButtonLabel</label>
<description>Pushbutton control for action in Niko Home Control</description> <description>@text/channelButtonDescription</description>
<category>Switch</category> <category>Switch</category>
<autoUpdatePolicy>veto</autoUpdatePolicy> <autoUpdatePolicy>veto</autoUpdatePolicy>
</channel-type> </channel-type>
<channel-type id="rollershutter"> <channel-type id="rollershutter">
<item-type>Rollershutter</item-type> <item-type>Rollershutter</item-type>
<label>Rollershutter</label> <label>@text/channelRollershutterLabel</label>
<description>Rollershutter control for rollershutter action in Niko Home Control</description> <description>@text/channelRollershutterDescription</description>
<category>Blinds</category> <category>Blinds</category>
</channel-type> </channel-type>
<channel-type id="measured"> <channel-type id="measured">
<item-type>Number:Temperature</item-type> <item-type>Number:Temperature</item-type>
<label>Measured</label> <label>@text/channelMeasuredLabel</label>
<description>Temperature measured by thermostat</description> <description>@text/channelMeasuredDescription</description>
<category>Temperature</category> <category>Temperature</category>
<tags> <tags>
<tag>Measurement</tag> <tag>Measurement</tag>
@ -232,8 +228,8 @@
</channel-type> </channel-type>
<channel-type id="setpoint"> <channel-type id="setpoint">
<item-type>Number:Temperature</item-type> <item-type>Number:Temperature</item-type>
<label>Setpoint</label> <label>@text/channelSetpointLabel</label>
<description>Setpoint temperature of thermostat</description> <description>@text/channelSetpointDescription</description>
<category>Temperature</category> <category>Temperature</category>
<tags> <tags>
<tag>Setpoint</tag> <tag>Setpoint</tag>
@ -243,33 +239,33 @@
</channel-type> </channel-type>
<channel-type id="overruletime"> <channel-type id="overruletime">
<item-type>Number</item-type> <item-type>Number</item-type>
<label>Overrule Time</label> <label>@text/channelOverruletimeLabel</label>
<description>Time duration for overruling thermostat target temperature in min.</description> <description>@text/channelOverruletimeDescription</description>
<category>Number</category> <category>Number</category>
<state min="0" max="1440" step="5"/> <state min="0" max="1440" step="5"/>
</channel-type> </channel-type>
<channel-type id="mode"> <channel-type id="mode">
<item-type>Number</item-type> <item-type>Number</item-type>
<label>Mode</label> <label>@text/channelModeLabel</label>
<description>Thermostat mode</description> <description>@text/channelModeDescription</description>
<category>Number</category> <category>Number</category>
<state> <state>
<options> <options>
<option value="0">day</option> <option value="0">@text/channelModeOption0</option>
<option value="1">night</option> <option value="1">@text/channelModeOption1</option>
<option value="2">eco</option> <option value="2">@text/channelModeOption2</option>
<option value="3">off</option> <option value="3">@text/channelModeOption3</option>
<option value="4">cool</option> <option value="4">@text/channelModeOption4</option>
<option value="5">prog 1</option> <option value="5">@text/channelModeOption5</option>
<option value="6">prog 2</option> <option value="6">@text/channelModeOption6</option>
<option value="7">prog 3</option> <option value="7">@text/channelModeOption7</option>
</options> </options>
</state> </state>
</channel-type> </channel-type>
<channel-type id="power"> <channel-type id="power">
<item-type>Number:Power</item-type> <item-type>Number:Power</item-type>
<label>Power</label> <label>@text/channelPowerLabel</label>
<description>Momentary power consumption/production (positive is consumption)</description> <description>@text/channelPowerDescription</description>
<category>Number</category> <category>Number</category>
<state readOnly="true" pattern="%.0f %unit%"/> <state readOnly="true" pattern="%.0f %unit%"/>
</channel-type> </channel-type>
@ -277,13 +273,13 @@
<channel-type id="alarm"> <channel-type id="alarm">
<kind>trigger</kind> <kind>trigger</kind>
<label>Alarm</label> <label>@text/channelAlarmLabel</label>
<description>Alarm from Niko Home Control</description> <description>@text/channelAlarmDescription</description>
</channel-type> </channel-type>
<channel-type id="notice"> <channel-type id="notice">
<kind>trigger</kind> <kind>trigger</kind>
<label>Notice</label> <label>@text/channelNoticeLabel</label>
<description>Notice from Niko Home Control</description> <description>@text/channelNoticeDescription</description>
</channel-type> </channel-type>
</thing:thing-descriptions> </thing:thing-descriptions>