Skip to content

Commit

Permalink
change MyQ binding to use now required oAuth for authentication
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan committed Aug 31, 2021
1 parent 6c3e937 commit d92e9fc
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 83 deletions.
7 changes: 7 additions & 0 deletions bundles/org.openhab.binding.myq/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ https://www.eclipse.org/legal/epl-2.0/.
== Source Code

https://github.com/openhab/openhab-addons

== Third-party Content

jsoup
* License: MIT License
* Project: https://jsoup.org/
* Source: https://github.com/jhy/jsoup
8 changes: 8 additions & 0 deletions bundles/org.openhab.binding.myq/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@

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

<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.8.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<feature name="openhab-binding-myq" description="MyQ Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle dependency="true">mvn:org.jsoup/jsoup/1.8.3</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.myq/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.openhab.binding.myq.internal.handler.MyQAccountHandler;
import org.openhab.binding.myq.internal.handler.MyQGarageDoorHandler;
import org.openhab.binding.myq.internal.handler.MyQLampHandler;
import org.openhab.core.auth.client.oauth2.OAuthFactory;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.openhab.core.thing.Bridge;
import org.openhab.core.thing.Thing;
Expand All @@ -41,10 +42,13 @@
@Component(configurationPid = "binding.myq", service = ThingHandlerFactory.class)
public class MyQHandlerFactory extends BaseThingHandlerFactory {
private final HttpClient httpClient;
private OAuthFactory oAuthFactory;

@Activate
public MyQHandlerFactory(final @Reference HttpClientFactory httpClientFactory) {
public MyQHandlerFactory(final @Reference HttpClientFactory httpClientFactory,
final @Reference OAuthFactory oAuthFactory) {
this.httpClient = httpClientFactory.getCommonHttpClient();
this.oAuthFactory = oAuthFactory;
}

@Override
Expand All @@ -57,7 +61,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();

if (THING_TYPE_ACCOUNT.equals(thingTypeUID)) {
return new MyQAccountHandler((Bridge) thing, httpClient);
return new MyQAccountHandler((Bridge) thing, httpClient, oAuthFactory);
}

if (THING_TYPE_GARAGEDOOR.equals(thingTypeUID)) {
Expand Down
Loading

0 comments on commit d92e9fc

Please sign in to comment.