Changes
Commits
Differences
v1.5.0 | v2.0.0 | ||||
---|---|---|---|---|---|
n | 2 | path: https://github.com/homieiot/convention/tree/v1.5.0 | n | 2 | path: https://github.com/homieiot/convention/tree/v2.0.0 |
n | 4 | version: v1.5.0 | n | 4 | version: v2.0.0 |
5 | releasedate: 19. June 2016 | 5 | releasedate: 28. April 2017 | ||
n | 11 | Homie devices communicate through MQTT. | n | 11 | 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. |
n | 13 | To 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. | n | 13 | * `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 `-`. | ||||
n | 19 | * `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: | n | 17 | * `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: |
n | n | 25 | <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> | ||||
n | 31 | <td><code>true</code> when the device is online, <code>false</code> when the device is offline (through LWT)</td> | n | 37 | <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> | ||||
n | n | 46 | <td>Yes</td> | ||
n | 45 | </tr> | n | 53 | <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> | ||
n | 51 | </tr> | n | 67 | <td>Yes</td> |
52 | <tr> | 68 | </tr> | ||
69 | <tr> | ||||
53 | <td>$signal</td> | 70 | <td>$stats/signal</td> | ||
n | 57 | </tr> | n | 74 | <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> | ||
n | 61 | <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> | n | 86 | <td>Name of the firmware running on the device. Allowed characters are the same as the device ID</td> |
n | 63 | </tr> | n | 88 | <td>Yes</td> |
64 | <tr> | 89 | </tr> | ||
90 | <tr> | ||||
65 | <td>$fwversion</td> | 91 | <td>$fw/version</td> | ||
n | 69 | </tr> | n | 95 | <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> | ||||
n | 81 | </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> | ||
n | 99 | devices/686f6d6965/$online → true | n | 123 | homie/686f6d6965/$online → true |
100 | devices/686f6d6965/$name → Bedroom temperature sensor | 124 | homie/686f6d6965/$name → Bedroom temperature sensor | ||
101 | devices/686f6d6965/$localip → 192.168.0.10 | 125 | homie/686f6d6965/$localip → 192.168.0.10 | ||
102 | devices/686f6d6965/$signal → 72 | 126 | homie/686f6d6965/$signal → 72 | ||
103 | devices/686f6d6965/$fwname → 1.0.0 | 127 | homie/686f6d6965/$fw/name → 1.0.0 | ||
104 | devices/686f6d6965/$fwversion → 1.0.0 | 128 | homie/686f6d6965/$fw/version → 1.0.0 | ||
105 | devices/686f6d6965/$nodes → temperature:temperature,humidity:humidity | ||||
n | 107 | n | |||
108 | And it would receive: | ||||
109 | |||||
110 | ``` | ||||
111 | devices/686f6d6965/$ota ← 1.0.1 | ||||
112 | devices/686f6d6965/$reset ← false | ||||
113 | ``` | ||||
114 | |||||
115 | At this point, your device would understand there is an OTA update available, as `$ota` is different from `$version`. | ||||
n | 119 | * `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. | n | 133 | * `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 | |||||
135 | Properties 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> | ||||
n | n | 164 | homie/686f6d6965/temperature/$type → temperature | ||
165 | homie/686f6d6965/temperature/$properties → degrees,unit | ||||
166 | homie/686f6d6965/temperature/unit → c | ||||
124 | devices/686f6d6965/temperature/temperature → 12.07 | 167 | homie/686f6d6965/temperature/degrees → 12.07 | ||
125 | devices/686f6d6965/humidity/humidity → 79 | ||||
126 | ``` | ||||
n | n | 169 | homie/686f6d6965/humidity/$type → humidity | ||
170 | homie/686f6d6965/humidity/$properties → percentage | ||||
171 | homie/686f6d6965/humidity/percentage → 79 | ||||
172 | ``` | ||||
173 | |||||
174 | 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: | ||||
175 | |||||
176 | ``` | ||||
177 | homie/ledstrip-device/ledstrip/$type → ledstrip | ||||
178 | homie/ledstrip-device/ledstrip/$properties → led[1-3]:settable | ||||
179 | homie/ledstrip-device/ledstrip/led_1 → on | ||||
180 | homie/ledstrip-device/ledstrip/led_2 → off | ||||
181 | homie/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. | ||
n | 130 | Homie 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. | n | 186 | 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. |
n | 132 | For example, an `homielight` device exposing a `light` node would subscribe to `devices/homielight/light/on/set` and it would receive: | n | 188 | For example, a `kitchen-light` device exposing a `light` node would subscribe to `homie/kitchen-light/light/on/set` and it would receive: |
n | 135 | devices/homielight/light/on/set ← true | n | 191 | homie/kitchen-light/light/on/set ← true |
t | 141 | devices/homielight/light/on → true | t | 197 | homie/kitchen-light/light/on → true |
198 | ``` | ||||
199 | |||||
200 | ### Broadcast channel | ||||
201 | |||||
202 | Homie 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 | |||||
206 | 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. | ||||
207 | |||||
208 | ``` | ||||
209 | homie/$broadcast/alert ← Intruder detected |