[nuki] Disabled warning for things created from textual config (#13331)

* Removed warning shown when thing is created with hexadecimal warning for read-only things
* Added missing configuration parameters into documentation

Signed-off-by: Jan Vybíral <jan.vybiral1@gmail.com>
This commit is contained in:
Jan Vybíral 2022-10-02 18:10:40 +02:00 committed by GitHub
parent 5c7eaa33ac
commit c9decdbe49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 98 additions and 84 deletions

View File

@ -28,7 +28,7 @@ This binding supports just one bridge type: The Nuki Bridge (`nuki:bridge`). Cre
The following configuration options are available:
| Parameter | Description | Comment |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ |
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|
| ip | The IP address of the Nuki Bridge. Look it up on your router. It is recommended to set a static IP address lease for the Nuki Bridge (and for your openHAB server too) on your router. | Required |
| port | The Port which you configured during [Initial Bridge setup](https://nuki.io/en/support/bridge/bridge-setup/initial-bridge-setup/). | Default 8080 |
| apiToken | The API Token which you configured during [Initial Bridge setup](https://nuki.io/en/support/bridge/bridge-setup/initial-bridge-setup/). | Required |
@ -59,106 +59,110 @@ connected to is configured and online.
This is a common thing for all Nuki smart lock products - Nuki Smart Lock 1.0/2.0/3.0 (Pro) and Nuki Smart Door. The following configuration options are available:
| Parameter | Description | Comment |
|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
| unlatch | If set to `true` the Nuki Smart Lock will unlock the door but then also automatically pull the latch of the door lock. Usually, if the door hinges are correctly adjusted, the door will then swing open. | Default false |
| Parameter | Description | Comment |
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|
| nukiId | The decimal or hexadecimal string that identifies the Nuki Smartlock. | Only available in textual configuration, cannot be edited in UI. |
| deviceType | Numeric device type as specified by bridge HTTP API - 0 = Nuki Smart Lock 1.0/2.0, 3 = Nuki Smart Door, 4 = Nuki Smart Lock 3.0 (Pro). | Only available in textual configuration, cannot be edited in UI. |
| unlatch | If set to `true` the Nuki Smart Lock will unlock the door but then also automatically pull the latch of the door lock. Usually, if the door hinges are correctly adjusted, the door will then swing open. | Default false |
#### Supported Channels
| Channel | Type | Description |
|------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| lock | Switch | Switch to lock and unlock doors. If `unlatch` configuration parameter is set, unlocking will also unlatch the door. |
| lockState | Number | Channel which accepts [Supported commands](#supported-lockstate-commands) for performing actions, and produces [supported values](#supported-lockstate-values) when lock state changes. |
| lowBattery | Switch | Low battery warning channel |
| keypadLowBattery | Switch | Indicates if keypad connected to Nuki Lock has low battery |
| batteryLevel | Number | Current battery level |
| batteryCharging | Swtich | Flag indicating if the batteries of the Nuki device are charging at the moment |
| doorsensorState | Number | Read only channel for monitoring door sensor state, see [supported values](#supported-doorsensorstate-values) |
| Channel | Type | Description |
|------------------|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| lock | Switch | Switch to lock and unlock doors. If `unlatch` configuration parameter is set, unlocking will also unlatch the door. |
| lockState | Number | Channel which accepts [Supported commands](#supported-lockstate-commands) for performing actions, and produces [supported values](#supported-lockstate-values) when lock state changes. |
| lowBattery | Switch | Low battery warning channel |
| keypadLowBattery | Switch | Indicates if keypad connected to Nuki Lock has low battery |
| batteryLevel | Number | Current battery level |
| batteryCharging | Swtich | Flag indicating if the batteries of the Nuki device are charging at the moment |
| doorsensorState | Number | Read only channel for monitoring door sensor state, see [supported values](#supported-doorsensorstate-values) |
##### Supported lockState commands
These values can be sent to _lockState_ channel as a commands:
| Command | Name |
|---------|--------------------------|
| 1 | Unlock |
| 2 | Lock |
| 3 | Unlatch |
| 4 | Lock 'n' Go |
| 5 | Lock 'n' Go with Unlatch |
| Command | Name |
|---------|--------------------------|
| 1 | Unlock |
| 2 | Lock |
| 3 | Unlatch |
| 4 | Lock 'n' Go |
| 5 | Lock 'n' Go with Unlatch |
##### Supported lockState values
| State | Name |
|--------|--------------------------|
| 0 | Uncalibrated |
| 1 | Locked |
| 2 | Unlocking |
| 3 | Unlocked |
| 4 | Locking |
| 5 | Unlatched |
| 6 | Unlatched (Lock 'n' Go) |
| 7 | Unlatching |
| 254 | Motor blocked |
| 255 | Undefined |
| State | Name |
|--------|--------------------------|
| 0 | Uncalibrated |
| 1 | Locked |
| 2 | Unlocking |
| 3 | Unlocked |
| 4 | Locking |
| 5 | Unlatched |
| 6 | Unlatched (Lock 'n' Go) |
| 7 | Unlatching |
| 254 | Motor blocked |
| 255 | Undefined |
Unfortunately the Nuki Bridge is not reporting any transition states (e.g. for Lock 'n' Go).
##### Supported doorSensorState values
| State | Name |
|-------|---------------------|
| 1 | Deactivated |
| 2 | Closed |
| 3 | Open |
| 4 | Door state unknonwn |
| 5 | Calibrating |
| 16 | Uncalibrated |
| 240 | Removed |
| 255 | Unknown |
| State | Name |
|-------|---------------------|
| 1 | Deactivated |
| 2 | Closed |
| 3 | Open |
| 4 | Door state unknonwn |
| 5 | Calibrating |
| 16 | Uncalibrated |
| 240 | Removed |
| 255 | Unknown |
### Nuki Opener
Nuki Opener has no configuration properties.
| Parameter | Description | Comment |
|-----------|--------------------------------------------------------------------|------------------------------------------------------------------|
| nukiId | The decimal or hexadecimal string that identifies the Nuki Opener. | Only available in textual configuration, cannot be edited in UI. |
#### Supported channels
| Channel | Type | Description |
|---------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| openerState | Number | Channel for sending [supported commands](#supported-openerstate-commands) to Opener, produces one of [supported values](#supported-openerstate-values) when Opener state changes |
| openerMode | Number | Id of current Opener mode, see [Supported values](#supported-openermode-values) |
| openerLowBattery | Switch | Low battery warning channel |
| ringActionState | Trigger | Channel triggers 'RINGING' event when the doorbell is being rung. This can trigger at most once every 30s |
| ringActionTimestamp | DateTime | Timestamp of last time doorbell was rung. |
| Channel | Type | Description |
|---------------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| openerState | Number | Channel for sending [supported commands](#supported-openerstate-commands) to Opener, produces one of [supported values](#supported-openerstate-values) when Opener state changes |
| openerMode | Number | Id of current Opener mode, see [Supported values](#supported-openermode-values) |
| openerLowBattery | Switch | Low battery warning channel |
| ringActionState | Trigger | Channel triggers 'RINGING' event when the doorbell is being rung. This can trigger at most once every 30s |
| ringActionTimestamp | DateTime | Timestamp of last time doorbell was rung. |
##### Supported openerState commands
| Command | Name |
|---------|----------------------------|
| 1 | Activate ring to open |
| 2 | Deactivate ring to open |
| 3 | Electric strike actuation |
| 4 | Activate continuous mode |
| 5 | Deactivate continuous mode |
| Command | Name |
|---------|----------------------------|
| 1 | Activate ring to open |
| 2 | Deactivate ring to open |
| 3 | Electric strike actuation |
| 4 | Activate continuous mode |
| 5 | Deactivate continuous mode |
##### Supported openerState values
| State | Name |
|--------|---------------------|
| 0 | Untrained |
| 1 | Online |
| 3 | Ring to open active |
| 5 | Open |
| 7 | Opening |
| 253 | Boot run |
| 255 | Undefined |
| State | Name |
|--------|---------------------|
| 0 | Untrained |
| 1 | Online |
| 3 | Ring to open active |
| 5 | Open |
| 7 | Opening |
| 253 | Boot run |
| 255 | Undefined |
##### Supported openerMode values
| Mode | Name |
|--------|-----------------|
| 2 | Door mode |
| 3 | Continuous mode |
| Mode | Name |
|--------|-----------------|
| 2 | Door mode |
| 3 | Continuous mode |
## Troubleshooting
@ -185,8 +189,9 @@ A manual setup through files could look like this:
### things/nuki.things
```
Bridge nuki:bridge:NB1 [ ip="192.168.0.50", port=8080, apiToken="myS3cr3t!", manageCallbacks=true ] {
Thing smartlock SL1 [ nukiId="12AB89EF", deviceType=0, unlatch=false ]
Bridge nuki:bridge:NB1 "Bridge Name" [ ip="192.168.0.50", port=8080, apiToken="myS3cr3t!", manageCallbacks=true, secureToken=true ] {
Thing smartlock SL1 "Nuki Smartlock Name" [ nukiId="12AB89EF", deviceType=0, unlatch=false ]
Thing opener OP1 "Nuki Opener Name" [ nukiId="254CF45A" ]
}
```
@ -195,7 +200,7 @@ Bridge nuki:bridge:NB1 [ ip="192.168.0.50", port=8080, apiToken="myS3cr3t!", man
```
Switch Frontdoor_Lock "Frontdoor (Unlock / Lock)" <nukiwhite> { channel="nuki:smartlock:NB1:SL1:lock" }
Number Frontdoor_LockState "Frontdoor (Lock State)" <nukisl> { channel="nuki:smartlock:NB1:SL1:lockState" }
Switch Frontdoor_LowBattery "Frontdoor Low Battery" <nukibattery> { channel="nuki:smartlock:NB1:SL1:lowBattery" }
Switch Frontdoor_LowBattery "Frontdoor Low Battery" <nukibattery> { channel="nuki:smartlock:NB1:SL1:lowBattery" }
Number Frontdoor_DoorState "Frontdoor (Door State)" <door> { channel="nuki:smartlock:NB1:SL1:doorsensorState" }
```

View File

@ -26,6 +26,7 @@ import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.net.HttpServiceUtil;
import org.openhab.core.net.NetworkAddressService;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.ManagedThingProvider;
import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
@ -54,14 +55,17 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
private final HttpClient httpClient;
private final NetworkAddressService networkAddressService;
private final ManagedThingProvider managedThingProvider;
private NukiApiServlet nukiApiServlet;
@Activate
public NukiHandlerFactory(@Reference HttpService httpService, @Reference final HttpClientFactory httpClientFactory,
@Reference NetworkAddressService networkAddressService) {
@Reference NetworkAddressService networkAddressService,
@Reference ManagedThingProvider managedThingProvider) {
this.httpClient = httpClientFactory.getCommonHttpClient();
this.networkAddressService = networkAddressService;
this.nukiApiServlet = new NukiApiServlet(httpService);
this.managedThingProvider = managedThingProvider;
}
@Override
@ -72,6 +76,7 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
boolean readOnly = managedThingProvider.get(thing.getUID()) == null;
if (NukiBindingConstants.THING_TYPE_BRIDGE_UIDS.contains(thingTypeUID)) {
String callbackUrl = createCallbackUrl(InstanceUUID.get());
@ -79,9 +84,9 @@ public class NukiHandlerFactory extends BaseThingHandlerFactory {
nukiApiServlet.add(nukiBridgeHandler);
return nukiBridgeHandler;
} else if (NukiBindingConstants.THING_TYPE_SMARTLOCK_UIDS.contains(thingTypeUID)) {
return new NukiSmartLockHandler(thing);
return new NukiSmartLockHandler(thing, readOnly);
} else if (NukiBindingConstants.THING_TYPE_OPENER_UIDS.contains(thingTypeUID)) {
return new NukiOpenerHandler(thing);
return new NukiOpenerHandler(thing, readOnly);
}
logger.warn("No valid Handler found for Thing[{}]!", thingTypeUID);
return null;

View File

@ -71,9 +71,11 @@ public abstract class AbstractNukiDeviceHandler<T extends NukiDeviceConfiguratio
protected T configuration;
@Nullable
private NukiHttpClient nukiHttpClient;
protected final boolean readOnly;
public AbstractNukiDeviceHandler(Thing thing) {
public AbstractNukiDeviceHandler(Thing thing, boolean readOnly) {
super(thing);
this.readOnly = readOnly;
this.configuration = getConfigAs(getConfigurationClass());
}
@ -109,9 +111,11 @@ public abstract class AbstractNukiDeviceHandler<T extends NukiDeviceConfiguratio
// legacy support - check if nukiId is hexadecimal (which might have been set by previous binding version)
// and convert it to decimal
if (NUKI_ID_HEX_PATTERN.matcher(nukiId).matches()) {
logger.warn(
"SmartLock '{}' was created by old version of binding. It is recommended to delete it and discover again",
thing.getUID());
if (!readOnly) {
logger.warn(
"SmartLock '{}' was created by old version of binding. It is recommended to delete it and discover again",
thing.getUID());
}
Configuration newConfig = editConfiguration();
newConfig.put(NukiBindingConstants.PROPERTY_NUKI_ID, hexToDecimal(nukiId));
updateConfiguration(newConfig);

View File

@ -36,8 +36,8 @@ import org.openhab.core.types.Command;
@NonNullByDefault
public class NukiOpenerHandler extends AbstractNukiDeviceHandler<NukiDeviceConfiguration> {
public NukiOpenerHandler(Thing thing) {
super(thing);
public NukiOpenerHandler(Thing thing, boolean readOnly) {
super(thing, readOnly);
}
private volatile Instant lastRingAction = Instant.EPOCH;

View File

@ -35,8 +35,8 @@ import org.openhab.core.types.Command;
@NonNullByDefault
public class NukiSmartLockHandler extends AbstractNukiDeviceHandler<NukiSmartLockConfiguration> {
public NukiSmartLockHandler(Thing thing) {
super(thing);
public NukiSmartLockHandler(Thing thing, boolean readOnly) {
super(thing, readOnly);
}
@Override