diff --git a/README.md b/README.md
index 783dbd0..dcc1540 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,7 @@ in [lock details response](src/test/resources/get_lock_response.json) and report
| battery | R | Number:Dimensionless | Remaining battery percentage |
| changedByUser | R | String | User last locking/unlocking the door. `Manual` if door knob used |
| unlockedByUser | R | String | User last unlocking the door. `Manual` if door knob used |
+| batteryKeypad | R | String | Remaining battery level of keypad (if installed) |
## Requesting latest status from lock
diff --git a/pom.xml b/pom.xml
index 82d673e..99e8d95 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
org.openhab.addons.bundles
org.openhab.addons.reactor.bundles
- 4.0.1
+ 4.0.4
no.seime.openhab.binding.august
diff --git a/src/main/java/no/seime/openhab/binding/august/internal/BindingConstants.java b/src/main/java/no/seime/openhab/binding/august/internal/BindingConstants.java
index 0ba1214..ca27b18 100644
--- a/src/main/java/no/seime/openhab/binding/august/internal/BindingConstants.java
+++ b/src/main/java/no/seime/openhab/binding/august/internal/BindingConstants.java
@@ -31,5 +31,6 @@ public class BindingConstants {
public static final String CHANNEL_LOCK_STATE = "lockState";
public static final String CHANNEL_DOOR_STATE = "doorState";
public static final String CHANNEL_BATTERY = "battery";
+ public static final String CHANNEL_BATTERY_KEYPAD = "batteryKeypad";
public static final String CHANNEL_UNLOCKED_BY_USER = "unlockedByUser";
}
diff --git a/src/main/java/no/seime/openhab/binding/august/internal/dto/GetLockResponse.java b/src/main/java/no/seime/openhab/binding/august/internal/dto/GetLockResponse.java
index 3df7b09..caa110d 100644
--- a/src/main/java/no/seime/openhab/binding/august/internal/dto/GetLockResponse.java
+++ b/src/main/java/no/seime/openhab/binding/august/internal/dto/GetLockResponse.java
@@ -56,4 +56,6 @@ public class GetLockResponse {
@SerializedName("pins")
public UserListDTO userList;
+
+ public KeypadDTO keypad;
}
diff --git a/src/main/java/no/seime/openhab/binding/august/internal/dto/KeypadDTO.java b/src/main/java/no/seime/openhab/binding/august/internal/dto/KeypadDTO.java
new file mode 100644
index 0000000..44c9b50
--- /dev/null
+++ b/src/main/java/no/seime/openhab/binding/august/internal/dto/KeypadDTO.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2023 Contributors to the Seime Openhab Addons 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 no.seime.openhab.binding.august.internal.dto;
+
+import com.google.gson.annotations.SerializedName;
+
+/**
+ * All classes in the .dto are data transfer classes used by the GSON mapper. This class reflects a
+ * part of a request/response data structure.
+ *
+ * @author Arne Seime - Initial contribution.
+ */
+
+public class KeypadDTO {
+
+ @SerializedName("_id")
+ public String id;
+
+ @SerializedName("LockID")
+ public String lockId;
+
+ @SerializedName("batteryLevel")
+ public String batteryLevel;
+
+ public String serialNumber;
+
+ @SerializedName("currentFirmwareVersion")
+ public String firmwareVersion;
+}
diff --git a/src/main/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandler.java b/src/main/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandler.java
index fe5f9ce..64e7eb9 100644
--- a/src/main/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandler.java
+++ b/src/main/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandler.java
@@ -189,6 +189,12 @@ private void updateThingProperties(GetLockResponse lockResponse) {
properties.put("lockSerialNumber", lockResponse.serialNumber);
properties.put("lockType", getLockName("" + lockResponse.type));
+ if (lockResponse.keypad != null) {
+ properties.put("keypadFirmwareVersion", lockResponse.keypad.firmwareVersion);
+ properties.put("keypadSerialNumber", lockResponse.keypad.serialNumber);
+ properties.put("keypadId", lockResponse.keypad.id);
+ }
+
updateThing(editThing().withProperties(properties).build());
}
@@ -222,6 +228,9 @@ private void handleCommandInternal(final ChannelUID channelUID, final Command co
case BindingConstants.CHANNEL_BATTERY:
handleBatteryCommand(channelUID, command);
break;
+ case BindingConstants.CHANNEL_BATTERY_KEYPAD:
+ handleBatteryKeypadCommand(channelUID, command);
+ break;
case BindingConstants.CHANNEL_LOCK_STATE:
handleLockStateCommand(channelUID, command);
break;
@@ -278,6 +287,18 @@ private void handleBatteryCommand(ChannelUID channelUID, Command command) {
}
}
+ private void handleBatteryKeypadCommand(ChannelUID channelUID, Command command) {
+ if (command instanceof RefreshType || command == null) {
+ if (lock.keypad != null) {
+ updateState(channelUID, new StringType(lock.keypad.batteryLevel));
+ } else {
+ updateState(channelUID, UnDefType.UNDEF);
+ }
+ } else {
+ logger.debug(ERROR_MESSAGE_UNSUPPORTED_COMMAND, command, channelUID);
+ }
+ }
+
private RemoteOperateLockRequest.Operation getOperationFromCommand(Command command) {
if (command instanceof RefreshType) {
return RemoteOperateLockRequest.Operation.STATUS;
diff --git a/src/main/resources/OH-INF/thing/channels.xml b/src/main/resources/OH-INF/thing/channels.xml
index 7ac6b89..4d934e5 100644
--- a/src/main/resources/OH-INF/thing/channels.xml
+++ b/src/main/resources/OH-INF/thing/channels.xml
@@ -29,4 +29,10 @@
Motion
+
+ String
+
+ BatteryLevel
+
+
diff --git a/src/main/resources/OH-INF/thing/lock.xml b/src/main/resources/OH-INF/thing/lock.xml
index 033dac3..6a58837 100644
--- a/src/main/resources/OH-INF/thing/lock.xml
+++ b/src/main/resources/OH-INF/thing/lock.xml
@@ -17,6 +17,7 @@
+
diff --git a/src/test/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandlerTest.java b/src/test/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandlerTest.java
index b3f19a5..e1047c5 100644
--- a/src/test/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandlerTest.java
+++ b/src/test/java/no/seime/openhab/binding/august/internal/handler/AugustLockHandlerTest.java
@@ -156,6 +156,8 @@ void testInitialize() throws IOException, InterruptedException {
verify(thingHandlerCallback).stateUpdated(new ChannelUID(thing.getUID(), BindingConstants.CHANNEL_BATTERY),
new QuantityType<>(47.75072124321014, Units.PERCENT));
+ verify(thingHandlerCallback).stateUpdated(
+ new ChannelUID(thing.getUID(), BindingConstants.CHANNEL_BATTERY_KEYPAD), new StringType("Full"));
verify(thingHandlerCallback).stateUpdated(new ChannelUID(thing.getUID(), BindingConstants.CHANNEL_LOCK_STATE),
OnOffType.ON);
verify(thingHandlerCallback).stateUpdated(new ChannelUID(thing.getUID(), BindingConstants.CHANNEL_DOOR_STATE),
@@ -320,6 +322,8 @@ private ThingImpl createLockThing() {
ChannelBuilder.create(new ChannelUID(lockThing.getUID(), BindingConstants.CHANNEL_DOOR_STATE)).build());
lockThing.addChannel(
ChannelBuilder.create(new ChannelUID(lockThing.getUID(), BindingConstants.CHANNEL_BATTERY)).build());
+ lockThing.addChannel(ChannelBuilder
+ .create(new ChannelUID(lockThing.getUID(), BindingConstants.CHANNEL_BATTERY_KEYPAD)).build());
lockThing.addChannel(ChannelBuilder
.create(new ChannelUID(lockThing.getUID(), BindingConstants.CHANNEL_UNLOCKED_BY_USER)).build());
lockThing.setConfiguration(configuration);
diff --git a/src/test/resources/mock_responses/get_lock_response.json b/src/test/resources/mock_responses/get_lock_response.json
index 9a5bf6e..b64bf95 100644
--- a/src/test/resources/mock_responses/get_lock_response.json
+++ b/src/test/resources/mock_responses/get_lock_response.json
@@ -157,5 +157,14 @@
"enabling": [],
"deleting": [],
"updating": []
+ },
+ "keypad": {
+ "_id": "KEYPAD_ID",
+ "serialNumber": "K2IC007",
+ "lockID": "LockId",
+ "currentFirmwareVersion": "2.27.0",
+ "battery": null,
+ "batteryLevel": "Full",
+ "batteryRaw": 189
}
}
\ No newline at end of file