Skip to content

Commit

Permalink
WIP pubnub
Browse files Browse the repository at this point in the history
  • Loading branch information
seime committed Feb 5, 2023
1 parent ba99038 commit 0020450
Show file tree
Hide file tree
Showing 47 changed files with 1,024 additions and 243 deletions.
6 changes: 2 additions & 4 deletions bundles/org.openhab.binding.august/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ To find the `lockId`, add the bridge and let it discover your locks
* `phone` = Mobile number used in the mobile app. Use full number with country code, ie `+4712345678`
* `password` = Same as you use in the mobile app
* `refreshInterval` = number of seconds between refresh calls to the server. This applies to the bridge itself, not the
locks. They can be configured individually.
locks. Defaults to once every hour
* `validationCode` = one time code requested from the service after authenticating with email + phone + password.

### Lock

* `lockId` = id of lock, typically a long string of numbers and letters
* `refreshInterval` = number of seconds between refresh calls to the server

## TODO

* Support for push messages via PubSub.
* Support 2-factor code via SMS

## Tested devices
Expand Down Expand Up @@ -73,7 +71,7 @@ status. This may take 10-20 seconds to complete, but you get the latest and most
august.things:

```
Bridge august:account:accountName "Yale Access account" [ email="[email protected]", phone="+4712345678", password="XXXXXXX", refreshInterval="120", validationCode="REPLACE" ] {
Bridge august:account:accountName "Yale Access account" [ email="[email protected]", phone="+4712345678", password="XXXXXXX", refreshInterval="3600", validationCode="REPLACE" ] {
Thing lock frontdoor "Front door" [ lockId="344KJLK32KJ234LKJ234JLKJK34" ]
}
```
Expand Down
34 changes: 34 additions & 0 deletions bundles/org.openhab.binding.august/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
2023-01-10 05:42:50.022 [WARN ] [t.internal.handler.AugustLockHandler] - 92968A1940BEEC48B9F99C6FA898A6B9 Error
contacting lock
org.openhab.binding.august.internal.RestCommunicationException: Error sending request to server. Server responded with
531
and payload {"code":31,"message":"Mechanical Position"}
at org.openhab.binding.august.internal.ApiBridge.sendRequestInternal(ApiBridge.java:132) ~[bundleFile:?]
at org.openhab.binding.august.internal.ApiBridge.sendRequest(ApiBridge.java:97) ~[bundleFile:?]
at org.openhab.binding.august.internal.handler.AugustLockHandler.handleLockStateCommand(AugustLockHandler.java:

196) [bundleFile:?]
at org.openhab.binding.august.internal.handler.AugustLockHandler.handleCommandInternal(AugustLockHandler.java:
167) [bundleFile:?]
at org.openhab.binding.august.internal.handler.AugustLockHandler.handleCommand(AugustLockHandler.java:
158) [bundleFile:?]
at jdk.internal.reflect.GeneratedMethodAccessor154.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:
154) [bundleFile:?]
at org.openhab.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [bundleFile:?]
at com.sun.proxy.$Proxy8590.handleCommand(Unknown Source) [?:?]
at org.openhab.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:
80) [bundleFile:?]
at org.openhab.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:
48) [bundleFile:?]
at jdk.internal.reflect.GeneratedMethodAccessor153.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
at org.openhab.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:
154) [bundleFile:?]
at org.openhab.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]

130 changes: 130 additions & 0 deletions bundles/org.openhab.binding.august/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,143 @@

<name>openHAB Add-ons :: Bundles :: August Binding</name>

<properties>
<bnd.importpackage>
kotlin.internal.jdk7;resolution:=optional,kotlin.internal.jdk8;resolution:=optional,android.*;resolution:=optional,org.bouncycastle.*;resolution:=optional,org.openjsse.javax.net.ssl.*;resolution:=optional,org.openjsse.net.ssl.*;resolution:=optional,com.android.org.*;resolution:=optional,dalvik.*;resolution:=optional,javax.annotation.meta.*;resolution:=optional,org.apache.harmony.*;resolution:=optional,org.conscrypt.*;resolution:=optional,sun.security.*;resolution:=optional,org.apache.http.*;resolution:=optional
</bnd.importpackage>
</properties>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
</dependency>

<dependency>
<groupId>com.pubnub</groupId>
<artifactId>pubnub-gson</artifactId>
<version>6.3.1</version>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-common</artifactId>
<version>1.5.31</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.6.20</version>
</dependency>


<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-cbor</artifactId>
<version>2.14.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.14.2</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.14.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.14.2</version>
</dependency>

<!-- <dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.7.20</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk7</artifactId>
<version>1.6.10</version>
<scope>compile</scope>
</dependency> -->
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
<version>1.6.4</version>
</dependency>

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.6.10</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.squareup.retrofit2/converter-gson -->
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>2.6.2</version>
</dependency>

<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.6.2</version>
</dependency>


<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.okhttp</artifactId>
<version>4.10.0_3</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.okio</artifactId>
<version>3.2.0_2</version>
<scope>compile</scope>
</dependency>


<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.28</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>2.23.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>


<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<scope>test</scope>
</dependency>



</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

<feature name="openhab-binding-august" description="August Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okhttp/4.10.0_3</bundle>
<bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.okio/3.2.0_2</bundle>
<bundle dependency="true">mvn:org.json/json/20200518</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.august/${project.version}</bundle>

</feature>
</features>
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public abstract class AugustException extends Exception {

private static final long serialVersionUID = 1L;

public AugustException(String message) {
protected AugustException(String message) {
super(message);
}

public AugustException(String message, Throwable cause) {
protected AugustException(String message, Throwable cause) {
super(message, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.august.internal.handler;
package org.openhab.binding.august.internal.comm;

/**
* The {@link AccessTokenUpdatedListener} is a callback interface if the access token returned from the service changes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2010-2022 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.august.internal.comm;

import org.eclipse.jdt.annotation.NonNullByDefault;

import com.google.gson.JsonElement;

/**
* The {@link PubNubListener} interface is for handling connects and disconects from PubNub
*
* @author Arne Seime - Initial contribution
*/
@NonNullByDefault
public interface PubNubListener {

void onPushMessage(String channelName, JsonElement message);

void onDisconnect(String channelName);

void onConnect(String channelName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2010-2022 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.august.internal.comm;

import org.openhab.binding.august.internal.AugustException;

/**
* The {@link PubNubMessageException} class wraps exceptions raised when communicating with the PubNub async
* message api
*
* @author Arne Seime - Initial contribution
*/
public class PubNubMessageException extends AugustException {
public PubNubMessageException(String message, Throwable cause) {
super(message, cause);
}
}
Loading

0 comments on commit 0020450

Please sign in to comment.