Skip to content

Commit

Permalink
[linktap] Initial contribution (openhab#17235)
Browse files Browse the repository at this point in the history
* [linkTap] Initial Code Commit

[Signed-off-by: dag81 <david.goodyear@gmail.com>
  • Loading branch information
dag81 authored and matchews committed Oct 18, 2024
1 parent 24bb53a commit 795d99e
Show file tree
Hide file tree
Showing 78 changed files with 8,376 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,11 @@
<artifactId>org.openhab.binding.lifx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.linktap</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.linky</artifactId>
Expand Down
20 changes: 20 additions & 0 deletions bundles/org.openhab.binding.linktap/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
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
234 changes: 234 additions & 0 deletions bundles/org.openhab.binding.linktap/README.md

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions bundles/org.openhab.binding.linktap/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>4.3.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.binding.linktap</artifactId>

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

<properties>
<jsoup.version>1.15.4</jsoup.version>
</properties>

<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>${jsoup.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
10 changes: 10 additions & 0 deletions bundles/org.openhab.binding.linktap/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.linktap-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository>

<feature name="openhab-binding-linktap" description="LinkTap Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle dependency="true">mvn:org.jsoup/jsoup/1.15.4</bundle>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.linktap/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2010-2024 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.linktap.configuration;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link LinkTapBridgeConfiguration} class contains fields mapping bridge configuration parameters.
*
* @author David Goodyear - Initial contribution
*/
@NonNullByDefault
public class LinkTapBridgeConfiguration {

public String host = "";
public String username = "";
public String password = "";
public boolean enableMDNS = true;
public boolean enableJSONComms = false;
public boolean enforceProtocolLimits = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2010-2024 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.linktap.configuration;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link LinkTapDeviceConfiguration} class contains fields mapping the configuration parameters for a LinkTap
* device's configuration.
*
* @author David Goodyear - Initial contribution
*/
@NonNullByDefault
public class LinkTapDeviceConfiguration {

/**
* The clear text device name as reported by the API.
*/
public String name = "";

/**
* The device id as stored by the gateway to address the device.
*/
public String id = "";

/**
* If enabled the device, will enable all alerts during device initialization.
*/
public boolean enableAlerts = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2010-2024 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.linktap.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link DeviceMetaDataUpdatedHandler} enables call-backs for when the device meta-data is updated from a bridge.
*
* @author David Goodyear - Initial contribution
*/
@NonNullByDefault
public interface DeviceMetaDataUpdatedHandler {
/**
* Any registered metadata handlers, will have this
* invoked after new configuration data has been retrieved from the GW.
*
* An example use is for the discovery service to refresh its data based on received
* new configuration data of devices attached to a GW.
*/
void handleMetadataRetrieved(LinkTapBridgeHandler handler);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Copyright (c) 2010-2024 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.linktap.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* The {@link Firmware} class defines the firmware version.
*
* @author David Goodyear - Initial contribution
*/
@NonNullByDefault
public class Firmware {
String raw;
int buildVer;
int hwVer;

public Firmware(final @Nullable String fwVersion) {
raw = "S00000000";
hwVer = 0;
buildVer = 0;

if (fwVersion == null || fwVersion.length() < 7) {
return;
} else {
raw = fwVersion;
buildVer = Integer.parseInt(raw.substring(1, 7));
}

switch (fwVersion.charAt(0)) {
case 'G':
hwVer = 2;
break;
case 'S':
hwVer = 1;
break;
default:
break;
}
}

public boolean supportsLocalConfig() {
return buildVer >= 60883;
}

public boolean supportsMDNS() {
return buildVer >= 60880;
}

public String generateTestedRevisionForHw(final int versionNo) {
return String.format("%c%05d", raw.charAt(0), versionNo);
}

public String getRecommendedMinVer() {
return generateTestedRevisionForHw(60883);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2010-2024 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.linktap.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* Defines a interface that Things under the Bridge can implement to receive
* callbacks, when the bridges configuration data has been updated.
*
* @author David Goodyear - Initial contribution
*/
@NonNullByDefault
public interface IBridgeData {

/**
* Any things under a Bridge that implement this interface, will have this
* invoked after new configuration data has been retrieved from the GW.
*/
void handleBridgeDataUpdated();
}
Loading

0 comments on commit 795d99e

Please sign in to comment.