Interface PublishInfo

interface PublishInfo {
    addIdentifyingMaterial?: boolean;
    advertiser?: MDNSAdvertiser;
    bind?: string | string[];
    category?: Categories;
    mdns?: MulticastOptions;
    pincode: string;
    port?: number;
    setupID?: string;
    useLegacyAdvertiser?: boolean;
    username: string;
}

Properties

addIdentifyingMaterial?: boolean

If this option is set to true, HAP-NodeJS will add identifying material (based on username) to the end of the accessory display name (and bonjour instance name). Default: true

advertiser?: MDNSAdvertiser

Defines the advertiser used with the published Accessory.

bind?: string | string[]

Defines the host where the HAP server will be bound to. When undefined the HAP server will bind to all available interfaces (see https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback).

This property accepts a mixture of IPAddresses and network interface names. Depending on the mixture of supplied addresses/names hap-nodejs will bind differently.

It is advised to not just bind to a specific address, but specifying the interface name in oder to bind on all address records (and ip version) available.

HAP-NodeJS (or the underlying ciao library) will not report about misspelled interface names, as it could be that the interface is currently just down and will come up later.

Here are a few examples:

  • bind: "::" Pretty much identical to not specifying anything, as most systems (with ipv6 support) will default to the unspecified ipv6 address (with dual stack support).

  • bind: "0.0.0.0" Binding TCP socket to the unspecified ipv4 address. The mdns advertisement will exclude any ipv6 address records.

  • bind: ["en0", "lo0"] The mdns advertising will advertise all records of the en0 and loopback interface (if available) and will also react to address changes on those interfaces. In order for the HAP server to accept all those address records (which may contain ipv6 records) it will bind on the unspecified ipv6 address "::" (assuming dual stack is supported).

  • bind: ["en0", "lo0", "0.0.0.0"] Same as above, only that the HAP server will bind on the unspecified ipv4 address "0.0.0.0". The mdns advertisement will not advertise any ipv6 records.

  • bind: "169.254.104.90" This will bind the HAP server to the address 0.0.0.0. The mdns advertisement will only advertise the A record 169.254.104.90. If the given network interface of that address encounters an ip address change (to a different address), the mdns advertisement will result in not advertising an address at all. So it is advised to specify an interface name instead of a specific address. This is identical with ipv6 addresses.

  • bind: ["169.254.104.90", "192.168.1.4"] As the HAP TCP socket can only bind to a single address, when specifying multiple ip addresses the HAP server will bind to the unspecified ip address (0.0.0.0 if only ipv4 addresses are supplied, :: if a mixture or only ipv6 addresses are supplied). The mdns advertisement will only advertise the specified ip addresses. If the given network interface of that address encounters an ip address change (to different addresses), the mdns advertisement will result in not advertising an address at all. So it is advised to specify an interface name instead of a specific address.

category?: Categories

Specify the category for the HomeKit accessory. The category is used only in the mdns advertisement and specifies the devices type for the HomeKit controller. Currently, this only affects the icon shown in the pairing screen. For the Television and Smart Speaker service it also affects the icon shown in the Home app when paired.

mdns?: MulticastOptions

Used to define custom MDNS options. Is not used anymore.

Deprecated

pincode: string
port?: number

Defines the port where the HAP server will be bound to. When undefined port 0 will be used resulting in a random port.

setupID?: string
useLegacyAdvertiser?: boolean

Use the legacy bonjour-hap as advertiser.

Deprecated

username: string