npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

homie-home-assistant-discovery

v1.0.5

Published

Core library and CLI for publishing Home Assistant MQTT discovery from Homie MQTT metadata.

Readme

Homie Home Assistant Discovery

npm npm downloads CI Node.js Latest Release License

works with MQTT Homie

Use this package to publish Home Assistant MQTT discovery for Homie MQTT devices.

Homie already describes devices, nodes and properties on MQTT. Home Assistant already knows how to discover MQTT entities. This package connects those conventions: it listens to Homie metadata, builds stable Home Assistant discovery payloads and publishes them as retained MQTT configuration messages.

You can run it as a standalone service, embed it in your own JavaScript or TypeScript application, or use the separate Node-RED package if you prefer visual MQTT wiring.

Pick Your Path

If you want to try it quickly, run the CLI against your broker:

npx homie-home-assistant-discovery --broker mqtt://localhost:1883

If you want to keep it running as a service, install it and pass the same options from your service manager, container or process supervisor:

npm install -g homie-home-assistant-discovery

homie-home-assistant-discovery \
  --broker mqtt://192.168.1.10:1883 \
  --username homie \
  --password homie

If you want the mapper inside your own code, use HomieHaDiscoveryBridge. It accepts MQTT-like messages and returns MQTT messages ready to publish.

import { HomieHaDiscoveryBridge } from "homie-home-assistant-discovery";

const bridge = new HomieHaDiscoveryBridge();

const result = bridge.ingest({
  topic: "homie/5/kitchen-board/$description",
  payload: JSON.stringify({
    homie: "5.0",
    version: 1,
    name: "Kitchen board",
    nodes: {
      ceiling: {
        name: "Ceiling light",
        properties: {
          state: { datatype: "boolean", settable: true },
        },
      },
    },
  }),
  retain: true,
});

for (const message of result.messages) {
  // Publish message.topic and message.payload to MQTT with message.retain=true.
}

What It Does Automatically

The default mapping is designed to be useful without configuration:

  • Homie v3.0.1 and v4.0.0 retained topic metadata is collected safely, even when the broker replays topics out of order.
  • Homie v5.x $description documents are parsed directly.
  • Stable Home Assistant unique_id, default_entity_id, availability and MQTT topics are generated.
  • Read-only booleans become binary_sensor.
  • Commandable booleans become switch, unless Homie names/types clearly look like a light or a fan, or you override them.
  • Numbers, enums, strings, colors, datetimes, durations and JSON properties map to the most conservative supported Home Assistant MQTT platform.
  • Homie lifecycle and observed v5 $... attributes can become diagnostic entities.

The mapper is conservative by design. It will not invent a cover, climate, lock, alarm_control_panel or similar domain from a generic Homie datatype, because Homie core does not provide enough semantics to do that reliably. When you know what a property really means, use overrides.

A Small Override Example

Overrides are optional. Start without them, then add only the things Home Assistant cannot infer from Homie metadata.

The example below does three things: named state properties become lights, the extractor stays a fan, and Home Assistant gets readable IDs.

{
  // Shared Home Assistant identity for every discovered device.
  "deviceDefaults": {
    // Builds device discovery topics such as homeassistant/device/home_kitchen-board/config.
    "objectId": "home_{deviceId}",

    // Keeps Home Assistant device identifiers stable across restarts.
    "identifiers": ["homie:{baseTopic}"],

    // Optional fallback metadata when Homie does not provide a richer model.
    "manufacturer": "Homie",
    "model": "MQTT device",
  },

  // Shortcut for the common pattern: node/state is the useful entity.
  "namedNodeState": {
    // Every named commandable boolean state becomes a light by default.
    "platform": "light",

    // Entity IDs become light.home_kitchen-board_ceiling, etc.
    "objectId": "home_{deviceId}_{nodeId}",
  },

  // Device-specific naming and exceptions.
  "devices": {
    "homie/5/kitchen-board": {
      // Friendly Home Assistant device name.
      "name": "Kitchen board",

      // Only nodes listed here get the namedNodeState shortcut.
      "nodeNames": {
        // Simple string: name this state entity "Ceiling light".
        "ceiling": "Ceiling light",

        // Object form: same shortcut, but with one local exception.
        "extractor": {
          "name": "Extractor fan",
          "platform": "fan",
          "icon": "mdi:fan",
        },
      },
    },
  },
}

The override file you load must be valid JSON, so remove the comments before putting it in --overrides or in the Node-RED editor. The full override guide includes copyable JSON snippets: Discovery overrides.

CLI Essentials

Default behavior:

homie-home-assistant-discovery --broker mqtt://localhost:1883

This subscribes to Homie metadata under homie/# and publishes discovery under homeassistant/.

Common production options:

homie-home-assistant-discovery \
  --broker mqtt://broker.example.local:1883 \
  --homie-domain homie \
  --legacy-root homie \
  --discovery-prefix homeassistant \
  --id-prefix homie \
  --boolean-platform auto \
  --subscription-qos 1 \
  --overrides ./discovery-overrides.json

Secure brokers are supported through MQTT.js options exposed by the CLI:

homie-home-assistant-discovery \
  --broker mqtts://broker.example.local:8883 \
  --mqtt-version 5 \
  --ca ./certs/ca.pem \
  --cert ./certs/client.pem \
  --key ./certs/client.key

Use --no-attribute-diagnostics when you only want entities declared by Homie device metadata and do not want observed v5 $... attributes exposed as diagnostic entities.

Documentation

The full documentation map lives in DOCS.md. Start there for CLI usage, library embedding, discovery mapping, overrides and Homie compatibility.

Node-RED

For a visual Node-RED flow, use node-red-contrib-homie-home-assistant-discovery. It wraps this package with a Node-RED editor UI, status handling, diagnostics and normal MQTT node wiring.

Local Quality Gate

npm ci
npm run check

npm run check typechecks, lints, formats, builds, validates packaged documentation links, installs the local tarball in a temporary consumer project and runs the Jest suite with coverage.

License

Apache-2.0. See LICENSE.