Class IpAddonFinder

java.lang.Object
org.openhab.core.config.discovery.addon.BaseAddonFinder
org.openhab.core.config.discovery.addon.ip.IpAddonFinder
All Implemented Interfaces:
AddonFinder, NetworkAddressChangeListener

@NonNullByDefault public class IpAddonFinder extends BaseAddonFinder implements NetworkAddressChangeListener
This is a IpAddonFinder for finding suggested add-ons by sending IP packets to the network and collecting responses. This finder is intended to detect devices on the network which do not announce via UPnP or mDNS. Some devices respond to queries to defined multicast addresses and ports and thus can be detected by sending a single frame on the IP network.

Be aware of possible side effects of sending packets to unknown devices in the network! This is why the IP finder is not intended for large scale network scanning, e.g. using large port or IP ranges.

Configuration

The following parameters can be used to configure frames to be sent to the network:

discovery-parameter values comment
type ipMulticast no other options implemented
destIp destination IP address
destPort destination port
listenPort port to use for listening to responses (optional) privileged ports (<1024) not allowed
request description of request frame as hex bytes separated by spaces (e.g. 0x01 0x02 ...) dynamic replacement of variables $srcIp, $srcPort and $uuid, no others implemented yet
requestPlain description of request frame as plaintext string dynamic replacement of variables $srcIp, $srcPort and $uuid, no others implemented yet; standard backslash sequences will be translated, and in addition to \, there are five XML special characters which need to be escaped:

 & - &amp;
 < - &lt;
 > - &gt;
 " - &quot;
 ' - &apos;
 
timeoutMs timeout to wait for a answers

dynamic replacement (in request*) value
$srcIp source IP address
$srcPort source port
$uuid String returned by java.util.UUID.randomUUID()

Packets are sent out on every available network interface.

There is currently only one match-property defined: response. It allows a regex match, but currently only ".*" is supported.

Limitations

The IpAddonFinder is still under active development. There are limitations:

  • Currently every returned frame is considered as success, regex matching is not implemented.
  • Frames are sent only on startup (or if an AddonInfoProvider calls setAddonCandidates(List)), no background scanning.
    Author:
    Holger Friedrich - Initial contribution, Jacob Laursen - Added support for broadcast-based scanning
    API note:
    The IpAddonFinder is still under active development, it has initially been developed to detect KNX installations and will be extended. Configuration parameters and supported features may still change.
    Implementation note:
    On activation, a thread is spawned which handles the detection. Scan runs once, no continuous background scanning.
    • Field Details

    • Constructor Details

    • Method Details

      • deactivate

        public void deactivate()
      • setAddonCandidates

        public void setAddonCandidates(List<AddonInfo> candidates)
        Description copied from interface: AddonFinder
        The framework calls this method to provide a list of AddonInfo elements which contain potential candidates that this finder can iterate over in order to detect which ones to return via the getSuggestedAddons() method.
        Specified by:
        setAddonCandidates in interface AddonFinder
        Overrides:
        setAddonCandidates in class BaseAddonFinder
        Parameters:
        candidates - a list of AddonInfo candidates.
      • addAddonService

        protected void addAddonService(AddonService featureService)
      • removeAddonService

        protected void removeAddonService(AddonService featureService)
      • onChanged

        public void onChanged(List<CidrAddress> added, List<CidrAddress> removed)
        Description copied from interface: NetworkAddressChangeListener
        When network address is changed, listeners will be notified by this method. When a network interface changes from "up" to "down", it is considered as "removed". When a "loopback" or "down" interface is added, the listeners are not notified.
        Specified by:
        onChanged in interface NetworkAddressChangeListener
        Parameters:
        added - Unmodifiable list of recently added network addresses
        removed - Unmodifiable list of recently removed network addresses
      • onPrimaryAddressChanged

        public void onPrimaryAddressChanged(@Nullable String oldPrimaryAddress, @Nullable String newPrimaryAddress)
        Description copied from interface: NetworkAddressChangeListener
        When the primary address is changed, listeners will be notified by this method. The primary address will be in the form of a subnet ("xxx.xxx.xxx.xxx/yyy").
        Specified by:
        onPrimaryAddressChanged in interface NetworkAddressChangeListener
        Parameters:
        oldPrimaryAddress - The old primary address (may be null if none specified)
        newPrimaryAddress - The new primary address (may be null if none specified)
      • getSuggestedAddons

        public Set<AddonInfo> getSuggestedAddons()
        Description copied from interface: AddonFinder
        The framework calls this method to scan through the candidate list of AddonInfo and return a subset of those that it suggests to be installed.
        Specified by:
        getSuggestedAddons in interface AddonFinder
      • getServiceName

        public String getServiceName()
        Specified by:
        getServiceName in class BaseAddonFinder