homieiot/convention

Changes

Changes from v1.5.0 to v2.0.0

Commits

Differences


v1.5.0
v2.0.0
n2path: https://github.com/homieiot/convention/tree/v1.5.0n2path: https://github.com/homieiot/convention/tree/v2.0.0
n4version: v1.5.0n4version: v2.0.0
5releasedate: 19. June 20165releasedate: 28. April 2017
n11Homie devices communicate through MQTT.n11To 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.
n13To efficiently parse messages, Homie defines a few rules related to topic names. The base topic you will see in the following lines will be `devices/`. You can customize this base topic if it fits better to your needs.n13* `homie` / **`device ID`**: this is the base topic of a device. Each device must have an unique device ID which adhere to the [ID format](#id-format).
14
15* `devices` / **`device ID`**: this is the base topic name. Each device must have a unique device ID. This ID MAY be composed of lowercase letters from `a` to `z`, numbers from `0` to `9`, and it MAY contain `-`, but MUST NOT start or end with a `-`.
n19* `devices` / **`device ID`** / `$` **`device property`**: a property starting with a `$` at the third level of the path is related to the device. The property MUST be one of these:n17* `homie` / **`device ID`** / `$` **`device property`**: a topic starting with a `$` after the base topic of a device represents a device property. A device property MUST be one of these:
nn25 <th>Required</th>
26 </tr>
27 <tr>
28 <td>$homie</td>
29 <td>Device → Controller</td>
30 <td>Version of the Homie convention the device conforms to</td>
31 <td>Yes</td>
32 <td>Yes</td>
n31 <td><code>true</code> when the device is online, <code>false</code> when the device is offline (through LWT)</td>n37 <td><code>true</code> when the device is online, <code>false</code> 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</td>
38 <td>Yes</td>
nn46 <td>Yes</td>
n45 </tr>n53 <td>Yes</td>
46 <tr>54 </tr>
55 <tr>
56 <td>$mac</td>
57 <td>Device → Controller</td>
58 <td>Mac address of the device network interface. The format MUST be of the type <code>A1:B2:C3:D4:E5:F6</code></td>
59 <td>Yes</td>
60 <td>Yes</td>
61 </tr>
62 <tr>
47 <td>$uptime</td>63 <td>$stats/uptime</td>
n51 </tr>n67 <td>Yes</td>
52 <tr>68 </tr>
69 <tr>
53 <td>$signal</td>70 <td>$stats/signal</td>
n57 </tr>n74 <td>No, this is not applicable to an Ethernet connected device for example</td>
58 <tr>75 </tr>
76 <tr>
77 <td>$stats/interval</td>
78 <td>Device → Controller</td>
79 <td>Interval in seconds at which the <code>$stats/uptime</code> and <code>$stats/signal</code> are refreshed</td>
80 <td>Yes</td>
81 <td>Yes</td>
82 </tr>
83 <tr>
59 <td>$fwname</td>84 <td>$fw/name</td>
n61 <td>Name of the firmware running on the device. This name MAY be composed of lowercase letters from <code>a</code> to <code>z</code>, numbers from <code>0</code> to <code>9</code>, and it MAY contain <code>-</code>, but MUST NOT start or end with a <code>-</code></td>n86 <td>Name of the firmware running on the device. Allowed characters are the same as the device ID</td>
n63 </tr>n88 <td>Yes</td>
64 <tr>89 </tr>
90 <tr>
65 <td>$fwversion</td>91 <td>$fw/version</td>
n69 </tr>n95 <td>Yes</td>
70 <tr>96 </tr>
71 <td>$nodes</td>
72 <td>Device → Controller</td>
73 <td>Nodes the device has, with format <code>id:type</code> separated by a <code>,</code> if there are multiple nodes</td>
74 <td>Yes</td>
75 </tr>97 <tr>
98 <td>$fw/checksum</td>
99 <td>Device → Controller</td>
100 <td>MD5 checksum of the firmware running on the device</td>
101 <td>Yes</td>
102 <td>No, depending of your implementation</td>
76 <tr>103 </tr>
104 <tr>
105 <td>$implementation</td>
106 <td>Device → Controller</td>
107 <td>An identifier for the Homie implementation (example <code>esp8266</code>)</td>
77 <td>$ota</td>108 <td>Yes</td>
78 <td>Controller → Device</td>109 <td>Yes</td>
79 <td>Latest OTA version available for the device</td>110 </tr>
111 <tr>
112 <td>$implementation/#</td>
113 <td>Controller → Device or Device → Controller</td>
114 <td>You can use any subtopics of <code>$implementation</code> for anything related to your specific Homie implementation.</td>
n81 </tr>n
82 <tr>
83 <td>$ota/+</td>
84 <td>Controller → Device or Device → Controller</td>
85 <td>You can use any subtopics of `$ota` for anything related to your specific OTA implementation.</td>
86 <td>Yes or No, depending of your implementation</td>
87 </tr>
88 <tr>
89 <td>$reset</td>
90 <td>Controller → Device</td>
91 <td><code>true</code> when the controller wants the device to reset its configuration. <code>false</code> otherwise. When the device receives a <code>true</code>, it should replace the retained message with a <code>false</code> before resetting</td>
92 <td>Yes</td>116 <td>No</td>
n99devices/686f6d6965/$online → truen123homie/686f6d6965/$online → true
100devices/686f6d6965/$name → Bedroom temperature sensor124homie/686f6d6965/$name → Bedroom temperature sensor
101devices/686f6d6965/$localip → 192.168.0.10125homie/686f6d6965/$localip → 192.168.0.10
102devices/686f6d6965/$signal → 72126homie/686f6d6965/$signal → 72
103devices/686f6d6965/$fwname → 1.0.0127homie/686f6d6965/$fw/name → 1.0.0
104devices/686f6d6965/$fwversion → 1.0.0128homie/686f6d6965/$fw/version → 1.0.0
105devices/686f6d6965/$nodes → temperature:temperature,humidity:humidity
n107 n
108And it would receive:
109
110```
111devices/686f6d6965/$ota ← 1.0.1
112devices/686f6d6965/$reset ← false
113```
114
115At this point, your device would understand there is an OTA update available, as `$ota` is different from `$version`.
n119* `devices` / **`device ID`** / **`node ID`** / **`property`**: `node ID` is the ID of the node, as defined in the `$nodes` device property. `property` is the property of the node that is getting updated.n133* `homie` / **`device ID`** / **`node ID`** / **`property`**: `node ID` is the ID of the node, which must be unique on a per-device basis, and which adhere to the [ID format](#id-format). `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](#id-format).
134
135Properties starting with a `$` are special properties. It must be one of the following:
136
137<table>
138 <tr>
139 <th>Property</th>
140 <th>Direction</th>
141 <th>Description</th>
142 <th>Retained</th>
143 <th>Required</th>
144 </tr>
145 <tr>
146 <td>$type</td>
147 <td>Device → Controller</td>
148 <td>Type of the node</td>
149 <td>Yes</td>
150 <td>Yes</td>
151 </tr>
152 <tr>
153 <td>$properties</td>
154 <td>Device → Controller</td>
155 <td>Properties the node exposes, with format <code>id</code> separated by a <code>,</code> if there are multiple nodes. For ranges, define the range after the <code>id</code>, within <code>[]</code> and separated by a <code>-</code>. For settable properties, add <code>:settable</code> to the <code>id</code></td>
156 <td>Yes</td>
157 <td>Yes</td>
158 </tr>
159</table>
nn164homie/686f6d6965/temperature/$type → temperature
165homie/686f6d6965/temperature/$properties → degrees,unit
166homie/686f6d6965/temperature/unit → c
124devices/686f6d6965/temperature/temperature → 12.07167homie/686f6d6965/temperature/degrees → 12.07
125devices/686f6d6965/humidity/humidity → 79
126```
nn169homie/686f6d6965/humidity/$type → humidity
170homie/686f6d6965/humidity/$properties → percentage
171homie/686f6d6965/humidity/percentage → 79
172```
173
174A 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:
175
176```
177homie/ledstrip-device/ledstrip/$type → ledstrip
178homie/ledstrip-device/ledstrip/$properties → led[1-3]:settable
179homie/ledstrip-device/ledstrip/led_1 → on
180homie/ledstrip-device/ledstrip/led_2 → off
181homie/ledstrip-device/ledstrip/led_3 → on
182```
183
128* `devices` / **`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.184* `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.
n130Homie is state-based. You don't tell your smarlight 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.n186Homie 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.
n132For example, an `homielight` device exposing a `light` node would subscribe to `devices/homielight/light/on/set` and it would receive:n188For example, a `kitchen-light` device exposing a `light` node would subscribe to `homie/kitchen-light/light/on/set` and it would receive:
n135devices/homielight/light/on/set ← truen191homie/kitchen-light/light/on/set ← true
t141devices/homielight/light/on → truet197homie/kitchen-light/light/on → true
198```
199
200### Broadcast channel
201
202Homie defines a broadcast channel, so a controller is able to broadcast a message to every Homie devices:
203
204* `homie` / `$broadcast` / **`level`**: `level` is an arbitrary broadcast identifier. It must adhere to the [ID format](#id-format).
205
206For 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.
207
208```
209homie/$broadcast/alert ← Intruder detected