Skip to content

Discovery ​

Inherits: RefCounted

Description ​

Finds Home Assistant installs on the local network using mDNS (zeroconf).

Home Assistant announces itself as _home-assistant._tcp.local. Queries are sent from a random port, which makes them "legacy unicast" queries (RFC 6762, section 6.7): responders answer straight to that port. So no multicast group has to be joined, which would need a multicast lock on Android.

Methods ​

ReturnsName
Variant_append_u16 ( packet: PackedByteArray, value: int )
PackedByteArray_build_query ( questions: Array )
Array[Dictionary]_collect_installs ( records: Array[Dictionary] )
Array[Dictionary]_find ( records: Array[Dictionary], type: int, name: String = "" )
Array_missing_questions ( records: Array[Dictionary] )
Array[Dictionary]_parse_packet ( data: PackedByteArray )
Dictionary_read_name ( data: PackedByteArray, offset: int )
Dictionary_read_txt ( data: PackedByteArray )
int_read_u16 ( data: PackedByteArray, offset: int )
Array[Dictionary]discover ( tree: SceneTree, timeout: float = 2.0 )

Constants ​

CLASS_IN = 1 ​

No description provided yet.

MDNS_ADDRESS = "224.0.0.251" ​

No description provided yet.

MDNS_PORT = 5353 ​

No description provided yet.

QUERY_INTERVAL = 600 ​

Milliseconds between repeated queries, as UDP packets can get lost.

SERVICE = "_home-assistant._tcp.local" ​

No description provided yet.

SetupCode = <Object> ​

No description provided yet.

TYPE_A = 1 ​

No description provided yet.

TYPE_PTR = 12 ​

No description provided yet.

TYPE_SRV = 33 ​

No description provided yet.

TYPE_TXT = 16 ​

No description provided yet.

Method Descriptions ​

static _append_u16 (packet: PackedByteArray , value: int ) -> Variant ​

No description provided yet.

static _build_query (questions: Array ) -> PackedByteArray ​

No description provided yet.

static _collect_installs (records: Array[Dictionary] ) -> Array[Dictionary] ​

No description provided yet.

static _find (records: Array[Dictionary] , type: int , name: String = "" ) -> Array[Dictionary] ​

No description provided yet.

static _missing_questions (records: Array[Dictionary] ) -> Array ​

Asks for the service first, then for the records of found instances that were not included in the answers so far.

static _parse_packet (data: PackedByteArray ) -> Array[Dictionary] ​

No description provided yet.

static _read_name (data: PackedByteArray , offset: int ) -> Dictionary ​

Reads a (possibly compressed) domain name. Returns {"name": String, "end": int} where end is the offset right after the name, or an empty dictionary if it's malformed.

static _read_txt (data: PackedByteArray ) -> Dictionary ​

No description provided yet.

static _read_u16 (data: PackedByteArray , offset: int ) -> int ​

No description provided yet.

static discover (tree: SceneTree , timeout: float = 2.0 ) -> Array[Dictionary] ​

Searches the network for timeout seconds and returns the installs found as {"name": String, "url": String, "version": String, "uuid": String}, where url is the websocket URL expected by the hass_ws adapter.