Please note this v2 branch is a work-in-progress. It might change before the final release.
Version: 2.1.0.
Homie is a lightweight MQTT convention for the IoT.
You can find an implementation of the Homie convention:
- An Arduino library built for the ESP8266: marvinroger/homie-esp8266
- WIP - An opinionated Web UI built with Node.js: marvinroger/homie-server
- WIP - Some Node-RED nodes for automation: marvinroger/node-red-contrib-homie
- A Python-implementation for Raspberry Pi & Co.: jalmeroth/homie-python.
- A Ruby-implementation including a command-line-client with OTA-Support for easy adminstration of multiple Homie-devices: rttools/hodmin
An instance of a physical piece of hardware (an Arduino, an ESP8266...) is called a device. A device has attributes, like the current local IP, the Wi-Fi signal, etc. A device can expose multiple nodes. For example, a weather station with two wireless sensors might expose a temperature
node and an humidity
node. A node can have multiple properties. The temperature
node might for example expose a degrees
property containing the actual temperature, and an battery
property containing the battery level of the temperature sensor. Node properties can be ranges. For example, if you have a LED strip, you can have a node property led
ranging from 1
to 10
, to control LEDs independently. Node properties can be settable. For example, you don't want your degrees
property to be settable in case of a temperature sensor: this depends on the environment and it would not make sense to change it. However, you will want the degrees
property to be settable in case of a thermostat.
Homie devices communicate through MQTT.
The nature of the Homie convention makes it safe about duplicate messages, so the recommended QoS for reliability is QoS 1. All messages MUST be sent as retained, UNLESS stated otherwise.
An ID MAY contain only lowercase letters from a
to z
, numbers from 0
to 9
, and it MAY contain -
, but MUST NOT start or end with a -
.
To efficiently parse messages, Homie defines a few rules related to topic names. The base topic you will see in the following convention will be homie/
. You can however choose whatever base topic you want.
homie
/device ID
: this is the base topic of a device. Each device must have a unique device ID which adhere to the ID format.- Attributes are topics that are prefixed with a
$
. These sub-topics add meta-data to Devices, Nodes and Properties describing their parent topic.
homie
/device ID
/$
device attribute
: a topic starting with a$
after the base topic of a device represents a device attribute. A device attribute MUST be one of these:
Topic | Direction | Description | Retained | Required |
---|---|---|---|---|
$homie | Device β Controller | Version of the Homie convention the device conforms to | Yes | Yes |
$online | Device β Controller | true when the device is online, false when the device is offline (through LWT). When sending the device is online, this message must be sent last, to indicate every other required messages are sent and the device is ready |
Yes | Yes |
$name | Device β Controller | Friendly name of the device | Yes | Yes |
$localip | Device β Controller | IP of the device on the local network | Yes | Yes |
$mac | Device β Controller | Mac address of the device network interface. The format MUST be of the type A1:B2:C3:D4:E5:F6 |
Yes | Yes |
$stats/uptime | Device β Controller | Time elapsed in seconds since the boot of the device | Yes | Yes |
$stats/signal | Device β Controller | Integer representing the Wi-Fi signal quality in percentage if applicable | Yes | No, this is not applicable to an Ethernet connected device for example |
$stats/interval | Device β Controller | Interval in seconds at which the $stats/uptime and $stats/signal are refreshed |
Yes | Yes |
$fw/name | Device β Controller | Name of the firmware running on the device. Allowed characters are the same as the device ID | Yes | Yes |
$fw/version | Device β Controller | Version of the firmware running on the device | Yes | Yes |
$fw/checksum | Device β Controller | MD5 checksum of the firmware running on the device | Yes | No, depending of your implementation |
$implementation | Device β Controller | An identifier for the Homie implementation (example esp8266 ) |
Yes | Yes |
$implementation/# | Controller β Device or Device β Controller | You can use any subtopics of $implementation for anything related to your specific Homie implementation. |
Yes or No, depending of your implementation | No |
$nodes | Device β Controller | Nodes the device exposes, with format id separated by a , if there are multiple nodes. For ranges, define the range after the id , within [] and separated by a - . |
Yes | Yes |
For example, a device with an ID of 686f6d6965
with a temperature and an humidity sensor would send:
homie/686f6d6965/$online β true
homie/686f6d6965/$name β Bedroom temperature sensor
homie/686f6d6965/$localip β 192.168.0.10
homie/686f6d6965/$signal β 72
homie/686f6d6965/$fw/name β 1.0.0
homie/686f6d6965/$fw/version β 1.0.0
homie
/device ID
/node ID
/node attribute
:node ID
is the ID of the node, which must be unique on a per-device basis, and which adhere to the ID format.- A node is made discoverable via its node attributes. It must be one of the following:
Topic | Direction | Description | Retained | Required |
---|---|---|---|---|
$type | Device β Controller | Type of the node | Yes | Yes |
$name | Device β Controller | Friendly name of the Node | Yes | Yes |
$properties | Device β Controller | Properties the node exposes, with format id separated by a , if there are multiple nodes. For ranges, define the range after the id , within [] and separated by a - . |
Yes | Yes |
homie
/device ID
/node ID
/property
/property attribute
:property
is the property of the node that is getting updated, which must be unique on a per-node basis, and which adhere to the ID format.- A property is made discoverable via its property attributes. It must be one of the following:
Topic | Direction | Description | Valid values | Retained | Required |
---|---|---|---|---|---|
$settable | Device β Controller | Specifies whether the property is settable (true ) or readonly (false ) |
true ,false |
Yes | Yes |
$unit | Device β Controller | A string containing the unit of this property. You are not limited to the recommended values, although they are the only well known ones that will have to be recognized by any Homie consumer. |
Recommended: Β°C Degree CelsiusΒ°F Degree FahrenheitΒ° DegreeL Litergal GalonV VoltsW WattA Ampere% Percentm Meterft FeetPa Pascalpsi PSI# Count or Amount
|
Yes | Yes, if applicable. If $unit is omitted, it is assumed that the property is unit-less, e.g. a discrete state. |
$datatype | Device β Controller | Describes the format of data. | integer , float , boolean (true or false ), string , enum |
Yes | Yes |
$name | Device β Controller | Friendly name of the property. | Any String | Yes | Yes |
$format | Device β Controller | Describes what are valid values for this property. |
|
Yes | Yes |
For example, our 686f6d6965
above would send:
homie/686f6d6965/temperature/$type β temperature
homie/686f6d6965/temperature/$properties β degrees,unit
homie/686f6d6965/temperature/degrees/$settable β false
homie/686f6d6965/temperature/degrees/$unit β C
homie/686f6d6965/temperature/degrees/$datatype β float
homie/686f6d6965/temperature/degrees/$format β -20.0:60
homie/686f6d6965/temperature/degrees β 12.07
homie/686f6d6965/humidity/$type β humidity
homie/686f6d6965/humidity/$properties β percentage
homie/686f6d6965/humidity/percentage/$settable β false
homie/686f6d6965/humidity/percentage/$unit β %
homie/686f6d6965/humidity/percentage/$datatype β integer
homie/686f6d6965/humidity/percentage/$format β 0:100
homie/686f6d6965/humidity/percentage β 79
A LED strip would look like this. Note that the topic for a range properties is the name of the property followed by a _
and the index getting updated:
homie/ledstrip-device/ledstrip/$type β ledstrip
homie/ledstrip-device/ledstrip/$properties β led[1-3]
homie/ledstrip-device/ledstrip/led_1/$settable β true
homie/ledstrip-device/ledstrip/led_1/$unit β
homie/ledstrip-device/ledstrip/led_1/$name β Red LEDs
homie/ledstrip-device/ledstrip/led_1/$datatype β enum
homie/ledstrip-device/ledstrip/led_1/$format β on,off
homie/ledstrip-device/ledstrip/led_1 β on
homie/ledstrip-device/ledstrip/led_2/$settable β true
homie/ledstrip-device/ledstrip/led_2/$unit β
homie/ledstrip-device/ledstrip/led_1/$name β Green LEDs
homie/ledstrip-device/ledstrip/led_2/$datatype β enum
homie/ledstrip-device/ledstrip/led_2/$format β on,off
homie/ledstrip-device/ledstrip/led_2 β off
homie/ledstrip-device/ledstrip/led_3/$settable β true
homie/ledstrip-device/ledstrip/led_3/$unit β
homie/ledstrip-device/ledstrip/led_1/$name β Blue LEDs
homie/ledstrip-device/ledstrip/led_3/$datatype β enum
homie/ledstrip-device/ledstrip/led_3/$format β on,off
homie/ledstrip-device/ledstrip/led_3 β on
homie
/device ID
/node ID
/property
/set
: the device can subscribe to this topic if the property is settable from the controller, in case of actuators.
Homie is state-based. You don't tell your smartlight to turn on
, but you tell it to put it's on
state to true
. This especially fits well with MQTT, because of retained message.
For example, a kitchen-light
device exposing a light
node would subscribe to homie/kitchen-light/light/power/set
and it would receive:
homie/kitchen-light/light/power/set β on
The device would then turn on the light, and update its power
state. This provides pessimistic feedback, which is important for home automation.
homie/kitchen-light/light/power β true
Homie defines a broadcast channel, so a controller is able to broadcast a message to every Homie devices:
homie
/$broadcast
/level
:level
is an arbitrary broadcast identifier. It must adhere to the ID format.
For example, you might want to broadcast an alert
event with the alert reason as the payload. Devices are then free to react or not. In our case, every buzzer of your home automation system would start buzzing.
homie/$broadcast/alert β Intruder detected
Any other topic is not part of the Homie convention.