Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nikohomecontrol] Add shutter invert and fix connection with NHC does not recover #10281

Merged
merged 8 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class NikoHomeControlBridgeDiscoveryService extends AbstractDiscoveryServ

public NikoHomeControlBridgeDiscoveryService() {
super(NikoHomeControlBindingConstants.BRIDGE_THING_TYPES_UIDS, TIMEOUT);
logger.debug("Niko Home Control: bridge discovery service started");
logger.debug("bridge discovery service started");
}

/**
Expand All @@ -65,23 +65,23 @@ private void discoverBridge() {
try {
String broadcastAddr = networkAddressService.getConfiguredBroadcastAddress();
if (broadcastAddr == null) {
logger.warn("Niko Home Control: discovery not possible, no broadcast address found");
logger.warn("discovery not possible, no broadcast address found");
return;
}
logger.debug("Niko Home Control: discovery broadcast on {}", broadcastAddr);
logger.debug("discovery broadcast on {}", broadcastAddr);
NikoHomeControlDiscover nhcDiscover = new NikoHomeControlDiscover(broadcastAddr);
if (nhcDiscover.isNhcII()) {
addNhcIIBridge(nhcDiscover.getAddr(), nhcDiscover.getNhcBridgeId());
} else {
addNhcIBridge(nhcDiscover.getAddr(), nhcDiscover.getNhcBridgeId());
}
} catch (IOException e) {
logger.debug("Niko Home Control: no bridge found.");
logger.debug("no bridge found.");
}
}

private void addNhcIBridge(InetAddress addr, String bridgeId) {
logger.debug("Niko Home Control: NHC I bridge found at {}", addr);
logger.debug("NHC I bridge found at {}", addr);

String bridgeName = "Niko Home Control Bridge";
ThingUID uid = new ThingUID(BINDING_ID, "bridge", bridgeId);
Expand All @@ -92,7 +92,7 @@ private void addNhcIBridge(InetAddress addr, String bridgeId) {
}

private void addNhcIIBridge(InetAddress addr, String bridgeId) {
logger.debug("Niko Home Control: NHC II bridge found at {}", addr);
logger.debug("NHC II bridge found at {}", addr);

String bridgeName = "Niko Home Control II Bridge";
ThingUID uid = new ThingUID(BINDING_ID, "bridge2", bridgeId);
Expand All @@ -115,7 +115,7 @@ protected synchronized void stopScan() {

@Override
protected void startBackgroundDiscovery() {
logger.debug("Niko Home Control: Start background bridge discovery");
logger.debug("Start background bridge discovery");
ScheduledFuture<?> job = nhcDiscoveryJob;
if (job == null || job.isCancelled()) {
nhcDiscoveryJob = scheduler.scheduleWithFixedDelay(this::discoverBridge, 0, REFRESH_INTERVAL,
Expand All @@ -125,7 +125,7 @@ protected void startBackgroundDiscovery() {

@Override
protected void stopBackgroundDiscovery() {
logger.debug("Niko Home Control: Stop bridge background discovery");
logger.debug("Stop bridge background discovery");
ScheduledFuture<?> job = nhcDiscoveryJob;
if (job != null && !job.isCancelled()) {
job.cancel(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class NikoHomeControlDiscoveryService extends AbstractDiscoveryService {

public NikoHomeControlDiscoveryService(NikoHomeControlBridgeHandler handler) {
super(SUPPORTED_THING_TYPES_UIDS, TIMEOUT, false);
logger.debug("Niko Home Control: discovery service {}", handler);
logger.debug("discovery service {}", handler);
bridgeUID = handler.getThing().getUID();
this.handler = handler;
}
Expand All @@ -70,10 +70,10 @@ public void discoverDevices() {
NikoHomeControlCommunication nhcComm = handler.getCommunication();

if ((nhcComm == null) || !nhcComm.communicationActive()) {
logger.warn("Niko Home Control: not connected.");
logger.warn("not connected");
return;
}
logger.debug("Niko Home Control: getting devices on {}", handler.getThing().getUID().getId());
logger.debug("getting devices on {}", handler.getThing().getUID().getId());

Map<String, NhcAction> actions = nhcComm.getActions();

Expand All @@ -99,8 +99,7 @@ public void discoverDevices() {
thingName, thingLocation);
break;
default:
logger.debug("Niko Home Control: unrecognized action type {} for {} {}", nhcAction.getType(),
actionId, thingName);
logger.debug("unrecognized action type {} for {} {}", nhcAction.getType(), actionId, thingName);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@

import java.util.List;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* {@link NhcJwtToken2} represents the Niko Home Control II hobby API token payload.
*
* @author Mark Herwege - Initial Contribution
*/
@NonNullByDefault
class NhcJwtToken2 {
String sub;
String iat;
String exp;
String aud;
String iss;
String jti;
List<String> role;
String sub = "";
String iat = "";
String exp = "";
String aud = "";
String iss = "";
String jti = "";
List<String> role = List.of();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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.nikohomecontrol.internal.handler;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* {@link NikoHomeControlActionBlindConfig} is the config class for Niko Home Control Blind Actions.
*
* @author Mark Herwege - Initial Contribution
*/
@NonNullByDefault
public class NikoHomeControlActionBlindConfig extends NikoHomeControlActionConfig {
public boolean invert;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
*/
package org.openhab.binding.nikohomecontrol.internal.handler;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* {@link NikoHomeControlActionConfig} is the general config class for Niko Home Control Actions.
*
* @author Mark Herwege - Initial Contribution
*/
@NonNullByDefault
public class NikoHomeControlActionConfig {
public String actionId;
public String actionId = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
*/
package org.openhab.binding.nikohomecontrol.internal.handler;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* {@link NikoHomeControlActionDimmerConfig} is the config class for Niko Home Control Dimmer Actions.
*
* @author Mark Herwege - Initial Contribution
*/
@NonNullByDefault
public class NikoHomeControlActionDimmerConfig extends NikoHomeControlActionConfig {
public int step;
public int step = 10;
}
Loading