Skip to main content

Presence detection for HiveMind mesh network

Project description

HiveMind-presence

Local-network presence and discovery for HiveMind nodes. A node announces itself on the LAN so satellites can find the hub without being told its IP address, and a satellite scans the LAN to discover reachable hubs.

It sits next to hivemind-core (the hub) and the client libraries: the hub advertises its WebSocket address with hivemind-presence announce, and a client uses hivemind-presence scan (or the LocalDiscovery API) to locate it and open a connection.

Discovery transports

  • mDNS / Zeroconf — multicast DNS service discovery. Optional dependency (zeroconf is LGPL and imported lazily); install it to enable mDNS.
  • UPnP / SSDP — an SSDP server advertises a UPnP device descriptor; the scanner discovers it over SSDP.

The roadmap moves the default to HiveBeacon — a zero-dependency UDP broadcast beacon absorbed from the archived HiveBeacon project — with mDNS kept as an optional transport. UPnP is being retired. Until the beacon transport ships, mDNS and UPnP are the available transports.

Prerequisites

  • Python 3.10+
  • A HiveMind hub (hivemind-core) reachable on the LAN for scan to find anything.
  • For mDNS: the optional zeroconf package (pip install zeroconf). Without it, announce/scan silently fall back to UPnP only.

Install

pip install hivemind-presence

From source:

git clone https://github.com/JarbasHiveMind/HiveMind-presence
cd HiveMind-presence
pip install -e .

To include mDNS support:

pip install hivemind-presence zeroconf

Quickstart

On the hub (advertise the node):

hivemind-presence announce --port 5678 --name living_room

On a satellite (discover hubs on the LAN):

hivemind-presence scan
            HiveMind Nodes
┏━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━┓
┃ Friendly Name ┃ Host         ┃ Port ┃
┡━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━┩
│   living_room │ 192.168.1.9  │ 5678 │
│       kitchen │ 192.168.1.13 │ 5678 │
└───────────────┴──────────────┴──────┘

Both announce and scan use mDNS by default (--zeroconf true --upnp false). Pass --upnp true to add the UPnP/SSDP transport.

Programmatic use

Announce from a hub process:

from hivemind_presence import LocalPresence

presence = LocalPresence(port=5678, name="living_room")
presence.start()
# ... run your hub ...
presence.stop()

Discover and connect from a client:

from hivemind_presence import LocalDiscovery

disc = LocalDiscovery()
for node in disc.scan(timeout=25):
    bus = node.connect(key="my-access-key", crypto_key="my-crypto-key")
    break

HiveMindNode.connect() returns a running HiveMessageBusClient connected to the discovered hub.

Configuration

announce and scan options:

Option Default Description
--port 5678 HiveMind WebSocket port to advertise (announce only).
--name HiveMind-Node Friendly device name (announce only).
--service-type HiveMind-websocket Service identifier matched between announce and scan.
--zeroconf true Use the mDNS/Zeroconf transport.
--upnp false Use the UPnP/SSDP transport.
--ssl false Advertise SSL support (announce only).

At least one transport must be enabled for scan; LocalDiscovery raises if both are disabled.

Documentation

See docs/:

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hivemind_presence-0.0.3a4.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hivemind_presence-0.0.3a4-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file hivemind_presence-0.0.3a4.tar.gz.

File metadata

  • Download URL: hivemind_presence-0.0.3a4.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hivemind_presence-0.0.3a4.tar.gz
Algorithm Hash digest
SHA256 72aa733153e9ae8e7c320963b87036f202e705a5f16e70de1ef56264552971fc
MD5 a139a63e8f35d334d762acb3ffd07fea
BLAKE2b-256 8efa4c5b87d911bf9da32b6f7fb9cb084de9a840078326b1df8cad9f60841c17

See more details on using hashes here.

File details

Details for the file hivemind_presence-0.0.3a4-py3-none-any.whl.

File metadata

File hashes

Hashes for hivemind_presence-0.0.3a4-py3-none-any.whl
Algorithm Hash digest
SHA256 ffd7d364dd1498175c42465637af47ca73d8940fac859fe275ca998c9782923f
MD5 263f960cb053422a2f26030fa3b30fb1
BLAKE2b-256 c18d1a575245cce0e6d5f97dcca5b1c3370fdfd85c2c89d009940e65e48a62d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page