Skip to content

Commit

Permalink
Merge branch 'master' into zigbee-mvn
Browse files Browse the repository at this point in the history
* master: (29 commits)
  removed background discovery code
  Adapted code to latest stable ESH release
  Improved default sitemap provider and demo files to make the Classic UI behave nice again. Also adapted AutoApproveService and removed ThingItemProvider as it was superceded by the ThingSetupManager of ESH.
  added info about Milight and Energenie
  updated information about rrd4j
  Implemented ItemRegistry, ItemUIRegistry and ChartProvider support for the compatibility layer. This fixes openhab#146.
  Added  InsteonPLM 1.7 binding
  Format start scripts and add check for not found equinox launcher
  Resource leak: 'socket' never closed
  Fix a bug in the implementation of DiscoveryListener of the ZonePlayerHandler
  classpath's JRE container and execution enviroment's one does not fit
  Add HABmin link to dashboard Signed-off-by: Chris Jackson <[email protected]> (github: cdjackson)
  stop add workspace plugins automatically to launch config
  updated launch config for new target platform
  upgraded Jetty to 9.2.9 and JAX-RS connector to 4.2.2 Fixes openhab#38
  Network Binding improvments -NetworkHealth renamed to Network -Retry for Mobile Devices which sometimes go to sleep -System Ping is now usable
  removed 2.0 alpha compat info
  Update compatability Add OW-Server, MySQL, Heatmiser, SNMP Signed-off-by: Chris Jackson <[email protected]> (github: cdjackson)
  changed comaptibility.md to reflect sucessful testing of openhab 1.6.0 bindings Fs20 and CUL on openhab2 snapshot
  Implementation of the playTrack functionality
  ...

Conflicts:
	addons/binding/pom.xml
  • Loading branch information
cdjackson committed Mar 23, 2015
2 parents b302ed5 + 63d70f8 commit 26e082a
Show file tree
Hide file tree
Showing 85 changed files with 3,347 additions and 903 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.binding.networkhealth</name>
<name>org.openhab.binding.network</name>
<comment></comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="networkhealth"
<binding:binding id="network"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="http://eclipse.org/smarthome/schemas/binding/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/binding/v1.0.0 http://eclipse.org/smarthome/schemas/binding-1.0.0.xsd">

<name>NetworkHealth Binding</name>
<description>The Network Health Binding checks if a Device is currently on the Network or not</description>
<name>Network Binding</name>
<description>The Network Binding checks if a Device is currently on the Network or not</description>
<author>Marc Mettke</author>

</binding:binding>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# binding
binding.network.name = Network Binding
binding.network.description = Das Network Binding überprüft, ob sich ein Geräte aktuell im Netzwerk befindet oder nicht.

# thing types
thing-type.network.device.label = Netzgerät
thing-type.network.device.description = Das Netzwerkgerät muss mit dem gleichen Netzwerk verbunden sein wie OpenHAB
thing-type.config.network.device.hostname.label = Hostname oder IP
thing-type.config.network.device.hostname.description = Hostname oder IP des Netzwerkgerätes
thing-type.config.network.device.port.label = Port
thing-type.config.network.device.port.description = Der Port an dem das Gerät erreichbar ist.
thing-type.config.network.device.retry.label = Wiederholen
thing-type.config.network.device.retry.description = Gibt an, wie oft der PING wiederholt werden soll, bevor das Gerät als offline markiert wird.
thing-type.config.network.device.timeout.label = Zeitlimit
thing-type.config.network.device.timeout.description = Gibt an, wie lange maximal gewartet werden soll (in ms), bis ein Gerät als nicht vorhanden gekenntzeichnet wird.
thing-type.config.network.device.refresh_interval.label = Aktualisierungsintervall
thing-type.config.network.device.refresh_interval.description = Spezifiziert den Aktualisierungsintervall (in ms)
thing-type.config.network.device.use_system_ping.label = System Ping
thing-type.config.network.device.use_system_ping.description = Nutzt das Ping Programm des Systems

# channel types
channel-type.network.online.label = Online
channel-type.network.online.description = Gibt an ob das Gerät aktuell Online oder Offline ist.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<thing:thing-descriptions bindingId="networkhealth"
<thing:thing-descriptions bindingId="network"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:thing="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0"
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd"><!--NetworkHealth Binding-->
xsi:schemaLocation="http://eclipse.org/smarthome/schemas/thing-description/v1.0.0 http://eclipse.org/smarthome/schemas/thing-description-1.0.0.xsd"><!--Network Binding-->
<thing-type id="device">
<label>Network Device</label>
<description>Device which must be connected to the same Network as OpenHAB</description>
Expand All @@ -11,10 +11,9 @@
<channel id="online" typeId="online"></channel>
</channels>
<config-description>
<parameter name="hostname" type="text">
<parameter name="hostname" type="text" required="true">
<label>Hostname or IP</label>
<description>Hostname or IP of the Device</description>
<required>true</required>
</parameter>

<parameter name="port" type="integer">
Expand All @@ -23,17 +22,29 @@
<default>0</default>
</parameter>

<parameter name="retry" type="integer">
<label>Retry</label>
<description>Defines how many times a ping shall occur, before the device is stated as offline</description>
<default>1</default>
</parameter>

<parameter name="timeout" type="integer">
<label>Timeout</label>
<description>States how long to wait, if a connection can not be established</description>
<description>States how long to wait (in ms), if a connection can not be established. If system ping is used, only full seconds are valid.</description>
<default>5000</default>
</parameter>

<parameter name="refresh_interval" type="integer">
<label>Refresh Interval</label>
<description>States how often a refresh shall occur</description>
<description>States how often a refresh shall occur (in ms)</description>
<default>60000</default>
</parameter>
</parameter>

<parameter name="use_system_ping" type="boolean">
<label>Use System Ping</label>
<description>Uses the Ping Program from the System</description>
<default>false</default>
</parameter>

</config-description>
</thing-type>
Expand All @@ -45,6 +56,7 @@
<tags>
<tag>Network Device</tag>
</tags>
<state readOnly="true"></state>
</channel-type>

</thing:thing-descriptions>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NetworkHealth Binding
Bundle-SymbolicName: org.openhab.binding.networkhealth;singleton:=true
Bundle-Name: Network Binding
Bundle-SymbolicName: org.openhab.binding.network;singleton:=true
Bundle-Vendor: openHAB
Bundle-Version: 2.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Expand All @@ -17,5 +17,6 @@ Import-Package: com.google.common.collect,
org.eclipse.smarthome.io.net.actions,
org.slf4j
Service-Component: OSGI-INF/*
Export-Package: org.openhab.binding.networkhealth,
org.openhab.binding.networkhealth.handler
Export-Package: org.openhab.binding.network,
org.openhab.binding.network.handler
Require-Bundle: org.apache.commons.lang
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" modified="modified" name="org.openhab.binding.networkhealth.discovery.NetworkHealthDiscoveryService">
<implementation class="org.openhab.binding.networkhealth.discovery.NetworkHealthDiscoveryService"/>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" modified="modified" name="org.openhab.binding.network.discovery.NetworkDiscoveryService">
<implementation class="org.openhab.binding.network.discovery.NetworkDiscoveryService"/>
<service>
<provide interface="org.eclipse.smarthome.config.discovery.DiscoveryService"/>
</service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
http://www.eclipse.org/legal/epl-v10.html
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.openhab.binding.networkhealth.internal.NetworkHealthHandlerFactory">
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.openhab.binding.network.internal.NetworkHandlerFactory">

<implementation class="org.openhab.binding.networkhealth.internal.NetworkHealthHandlerFactory"/>
<implementation class="org.openhab.binding.network.internal.NetworkHandlerFactory"/>

<service>
<provide interface="org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
</parent>

<properties>
<bundle.symbolicName>org.openhab.binding.networkhealth</bundle.symbolicName>
<bundle.namespace>org.openhab.binding.networkhealth</bundle.namespace>
<bundle.symbolicName>org.openhab.binding.network</bundle.symbolicName>
<bundle.namespace>org.openhab.binding.network</bundle.namespace>
</properties>

<groupId>org.openhab.binding</groupId>
<artifactId>org.openhab.binding.networkhealth</artifactId>
<artifactId>org.openhab.binding.network</artifactId>
<version>2.0.0-SNAPSHOT</version>

<name>NetworkHealth Binding</name>
<name>Network Binding</name>
<packaging>eclipse-plugin</packaging>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.binding.networkhealth;
package org.openhab.binding.network;

import java.util.Collections;
import java.util.Set;

import org.eclipse.smarthome.core.thing.ThingTypeUID;

/**
* The {@link NetworkHealthBindingConstants} class defines common constants, which are
* The {@link NetworkBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Marc Mettke - Initial contribution
*/
public class NetworkHealthBindingConstants {
public class NetworkBindingConstants {

public static final String BINDING_ID = "networkhealth";
public static final String BINDING_ID = "network";

// List of all Thing Type UIDs
public final static ThingTypeUID THING_TYPE_DEVICE = new ThingTypeUID(BINDING_ID, "device");
Expand All @@ -31,8 +31,10 @@ public class NetworkHealthBindingConstants {
// List of all Parameters
public final static String PARAMETER_HOSTNAME = "hostname";
public final static String PARAMETER_PORT = "port";
public final static String PARAMETER_RETRY = "retry";
public final static String PARAMETER_TIMEOUT = "timeout";
public final static String PARAMETER_REFRESH_INTERVAL = "refresh_interval";
public final static String PARAMETER_USE_SYSTEM_PING = "use_system_ping";

public final static Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_DEVICE);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* Copyright (c) 2014 openHAB UG (haftungsbeschraenkt) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.binding.network.discovery;

import static org.openhab.binding.network.NetworkBindingConstants.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.openhab.binding.network.service.DiscoveryCallback;
import org.eclipse.smarthome.core.thing.ThingTypeUID;
import org.eclipse.smarthome.core.thing.ThingUID;
import org.eclipse.smarthome.config.discovery.AbstractDiscoveryService;
import org.eclipse.smarthome.config.discovery.DiscoveryResult;
import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder;
import org.openhab.binding.network.service.NetworkService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The {@link NetworkDiscoveryService} is responsible for discovering devices on
* the current Network. It uses every Network Interface which is connect to a Network
*
* @author Marc Mettke - Initial contribution
*/
public class NetworkDiscoveryService extends AbstractDiscoveryService {
private final Logger logger = LoggerFactory.getLogger(NetworkDiscoveryService.class);

public NetworkDiscoveryService() {
super(SUPPORTED_THING_TYPES_UIDS, 300, false);
}

public Set<ThingTypeUID> getSupportedThingTypes() {
return SUPPORTED_THING_TYPES_UIDS;
}

@Override
protected void startScan() {
logger.debug("Starting Discovery");
NetworkService.discoverNetwork(new DiscoveryCallback() {
@Override
public void newDevice(String ip) {
submitDiscoveryResults(ip);
}
}, scheduler);
}

/**
* Submit the discovered Devices to the Smarthome inbox,
*
* @param ip The Device IP
*/
private void submitDiscoveryResults(String ip) {

// uid must not contains dots
ThingUID uid = new ThingUID(THING_TYPE_DEVICE, ip.replace('.', '_') );

if(uid!=null) {
Map<String, Object> properties = new HashMap<>(1);
properties.put(PARAMETER_HOSTNAME ,ip);
DiscoveryResult result = DiscoveryResultBuilder.create(uid)
.withProperties(properties)
.withLabel("Network Device (" + ip +")").build();
thingDiscovered(result);
}

}

}
Loading

0 comments on commit 26e082a

Please sign in to comment.