zeroconf#

class platypush.plugins.zeroconf.ZeroconfListener(*args: Any, **kwargs: Any)[source]#

Bases: ServiceListener

__init__(evt_queue: Queue)[source]#
class platypush.plugins.zeroconf.ZeroconfPlugin(**kwargs)[source]#

Bases: Plugin

Plugin for Zeroconf services discovery.

Triggers:

Requires:

  • zeroconf (pip install zeroconf)

__init__(**kwargs)[source]#
discover_service(service: str | list, timeout: int | None = 5) Dict[str, Any][source]#

Find all the services matching the specified type.

Parameters:
  • service – Service type (e.g. _http._tcp.local.) or list of service types.

  • timeout – Browser timeout in seconds (default: 5). Specify None for no timeout - in such case the discovery will loop forever and generate events upon service changes.

Returns:

A service_type -> [service_names] mapping. Example:

{
    "host1._platypush-http._tcp.local.": {
        "type": "_platypush-http._tcp.local.",
        "name": "host1._platypush-http._tcp.local.",
        "info": {
            "addresses": ["192.168.1.11"],
            "port": 8008,
            "host_ttl": 120,
            "other_ttl": 4500,
            "priority": 0,
            "properties": {
                "name": "Platypush",
                "vendor": "Platypush",
                "version": "0.13.2"
            },
            "server": "host1._platypush-http._tcp.local.",
            "weight": 0
        }
    }
}

get_services(timeout: int = 5) List[str][source]#

Get the full list of services found on the network.

Parameters:

timeout – Discovery timeout in seconds (default: 5).

Returns:

List of the services as strings.