Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tr064] Initial Contribution #6678

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
/bundles/org.openhab.binding.tesla/ @kgoderis
/bundles/org.openhab.binding.toon/ @jongj
/bundles/org.openhab.binding.tplinksmarthome/ @Hilbrand
/bundles/org.openhab.binding.tr064/ @J-N-K
/bundles/org.openhab.binding.tradfri/ @cweitkamp @kaikreuzer
/bundles/org.openhab.binding.unifi/ @mgbowman
/bundles/org.openhab.binding.urtsi/ @OLibutzki
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<artifactId>org.openhab.binding.nest</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.tr064</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.persistence.dynamodb</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.tr064/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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/openhab2-addons
117 changes: 117 additions & 0 deletions bundles/org.openhab.binding.tr064/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# TR-064 Binding

This binding brings support for internet gateway devices that support the TR-064 protocol.
It can be used to gather information from the device and/or re-configure it.

## Supported Things

Four thing types are supported:

- `generic`: the internet gateway device itself (generic device)
- `fritzbox`: similar to `generic` with extensions for AVM FritzBox devices
- `subDevice`: a sub-device of a `rootDevice` (e.g. a WAN interface)
- `subDeviceLan`: a special type of sub-device that supports MAC-detection

## Discovery

The gateway device needs to be added manually.
After that, sub-devices are detected automatically.

## Thing Configuration

All thing types have a `refresh` parameter.
It sets the refresh-interval in seconds for each device channel.
The default value is 60.

### `generic`, `fritzbox`

The `host` parameter is required to communicate with the device.
It can be a hostname or an IP address.

For accessing the device you need to supply credentials.
If you only configured password authentication for your device, the `user` parameter must be skipped and it will default to `dslf-config`.
The second credential parameter is `password`, which is mandatory.
For security reasons it is highly recommended to set both, username and password.


### `fritzbox`

All additional parameters for `fritzbox` devices (i.e. except those that are shared with `generic`) are advanced parameters.

One or more TAM (telephone answering machines) are supported by most devices.
By setting the `tamIndices` parameter you can instruct the binding to add channels for these devices to the thing.
Values start with `0`.
This is an optional parameter and multiple values are allowed.

Most devices allow to configure call deflections.
If the `callDeflectionIndices` parameter is set, channels for the status of the pre-configured call deflections are added.
Values start with `0`, including the number of "Call Blocks" (two configured call-blocks -> first deflection is `2`).
This is an optional parameter and multiple values are allowed.

Most devices support call lists.
The binding can analyze these call lists and provide channels for the number of missed calls, inbound calls, outbound calls and rejected (blocked) calls.
The days for which this analysis takes place can be controlled with the `missedCallDays`, `rejectedCallDays`, `inboundCallDays` and `outboundCallDays`
This is an optional parameter and multiple values are allowed.

If the `PHONEBOOK` transformation shall be used, it is necessary to retrieve the phonebooks from the FritzBox.
The `phonebookInterval` is uses to set the refresh cycle for phonebooks.

### `subdevice`, `subdeviceLan`

Besides the bridge that the thing is attached to, sub-devices have a `uuid` parameter.
This is the UUID/UDN of the device and a mandatory parameter.
Since the value can only be determined by examining the SCPD of the root device, the simplest way to get hold of them is through auto-discovery.

For `subdeviceLan` devices (type is detected automatically during discovery) the parameter `macOnline` can be defined.
It adds a channel for each MAC (format 11:11:11:11:11:11) that shows the online status of the respective device.
This is an optional parameter and multiple values are allowed.

## Channels

| channel | item-type | advanced | description |
|----------------------------|---------------------------|:--------:|----------------------------------------------------------------|
| `callDeflectionEnable` | `Switch` | | Enable/Disable the call deflection setup with the given index. |
| `deviceLog` | `String` | x | A string containing the last log messages. |
| `dslCRCErrors` | `Number:Dimensionless` | x | DSL CRC Errors |
| `dslDownstreamNoiseMargin` | `Number:Dimensionless` | x | DSL Downstream Noise Margin |
| `dslDownstreamNoiseMargin` | `Number:Dimensionless` | x | DSL Downstream Attenuation |
| `dslEnable` | `Switch` | | DSL Enable |
| `dslFECErrors` | `Number:Dimensionless` | x | DSL FEC Errors |
| `dslHECErrors` | `Number:Dimensionless` | x | DSL HEC Errors |
| `dslStatus` | `Switch` | | DSL Status |
| `dslUpstreamNoiseMargin` | `Number:Dimensionless` | x | DSL Upstream Noise Margin |
| `dslUpstreamNoiseMargin` | `Number:Dimensionless` | x | DSL Upstream Attenuation |
| `inboundCalls` | `Number` | x | Number of inbound calls within the given number of days. |
| `macOnline` | `Switch` | x | Online status of the device with the given MAC |
| `missedCalls` | `Number` | | Number of missed calls within the given number of days. |
| `outboundCalls` | `Number` | x | Number of outbound calls within the given number of days. |
| `reboot` | `Switch` | | Reboot |
| `rejectedCalls` | `Number` | x | Number of rejected calls within the given number of days. |
| `securityPort` | `Number` | x | The port for connecting via HTTPS to the TR-064 service. |
| `tamEnable` | `Switch` | | Enable/Disable the answering machine with the given index. |
| `tamNewMessages` | `Number` | | The number of new messages of the given answering machine. |
| `uptime` | `Number:Time` | | Uptime |
| `wanAccessType` | `String` | x | Access Type |
| `wanConnectionStatus` | `String` | | Connection Status |
| `wanIpAddress` | `String` | x | WAN IP Address |
| `wanMaxDownstreamRate` | `Number:DataTransferRate` | x | Max. Downstream Rate |
| `wanMaxUpstreamRate` | `Number:DataTransferRate` | x | Max. Upstream Rate |
| `wanPhysicalLinkStatus` | `String` | x | Link Status |
| `wanTotalBytesReceived` | `Number:DataAmount` | x | Total Bytes Received |
| `wanTotalBytesSent` | `Number:DataAmount` | x | Total Bytes Send |
| `wifi24GHzEnable` | `Switch` | | Enable/Disable the 2.4 GHz WiFi device. |
| `wifi5GHzEnable` | `Switch` | | Enable/Disable the 5.0 GHz WiFi device. |
| `wifiGuestEnable` | `Switch` | | Enable/Disable the guest WiFi. |

## `PHONEBOOK` Profile

The binding provides a profile for using the FritzBox phonebooks for resolving numbers to names.
The `PHONEBOOK` profile takes strings containing the number as input and provides strings with the caller's name, if found.

The parameter `thingUid` with the UID of the phonebook providing thing is a mandatory parameter.
If only a specific phonebook from the device should be used, this can be specified with the `phonebookName` parameter.
The default is to use all available phonebooks from the specified thing.
In case the format of the number in the phonebook and the format of the number from the channel are different (e.g. regarding country prefixes), the `matchCount` parameter can be used.
The configured `matchCount` is counted from the right end and denotes the number of matching characters needed to consider this number as matching.

## Full Example
55 changes: 55 additions & 0 deletions bundles/org.openhab.binding.tr064/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

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

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

<name>openHAB Add-ons :: Bundles :: TR-064 Binding</name>

<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<id>generate-jaxb-sources</id>
<phase>none</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
<generateDirectory>src/main/java</generateDirectory>
<markGenerated>false</markGenerated>
<noFileHeader>true</noFileHeader>
<locale>en</locale>
<episode>false</episode>
<extension>true</extension>
<args>
<arg>-Xxew</arg>
<arg>-Xxew:instantiate early</arg>
</args>
<plugins>
<plugin>
<groupId>com.github.jaxb-xew-plugin</groupId>
<artifactId>jaxb-xew-plugin</artifactId>
<version>1.10</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
</build>
</project>
11 changes: 11 additions & 0 deletions bundles/org.openhab.binding.tr064/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.tr064-${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-tr064" description="TR-064 Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<feature>openhab.tp-jaxb</feature>
<feature>openhab.tp-jaxws</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.tr064/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2010-2020 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.tr064.internal;

import javax.net.ssl.X509ExtendedTrustManager;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.io.net.http.TlsTrustManagerProvider;
import org.openhab.core.io.net.http.TrustAllTrustMananger;
import org.osgi.service.component.annotations.Component;

/**
* Provides a TrustManager to allow secure connections to any FRITZ!Box
*
* @author Chritoph Weitkamp - Initial Contribution
*/
@Component
@NonNullByDefault
public class AvmFritzTlsTrustManagerProvider implements TlsTrustManagerProvider {

@Override
public String getHostName() {
return "fritz.box";
}

@Override
public X509ExtendedTrustManager getTrustManager() {
return TrustAllTrustMananger.getInstance();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2010-2020 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.tr064.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
*
* The{@link ChannelConfigException} is a catched Exception that is thrown during channel configuration
*
* @author Jan N. Klug - Initial contribution
*/
@NonNullByDefault
public class ChannelConfigException extends Exception {
private static final long serialVersionUID = 1L;

public ChannelConfigException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2010-2020 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.tr064.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
*
* The{@link PostProcessingException} is a catched Exception that is thrown in case of conversion errors during post
* processing
*
* @author Jan N. Klug - Initial contribution
*/
@NonNullByDefault
public class PostProcessingException extends Exception {
private static final long serialVersionUID = 1L;

public PostProcessingException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Copyright (c) 2010-2020 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.tr064.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
*
* The{@link SCPDException} is a catched Exception that is thrown in case of errors during SCPD processing
*
* @author Jan N. Klug - Initial contribution
*/
@NonNullByDefault
public class SCPDException extends Exception {
private static final long serialVersionUID = 1L;

public SCPDException(String message) {
super(message);
}
}
Loading