You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-12Lines changed: 39 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,5 @@
1
1
Fork of [sidoh's great work](https://github.com/sidoh/esp8266_milight_hub) to fix some things and hopefully pushing the boundaries of MiLights possibilities.
2
+
The following text is his original README (just replaced some links for consistency):
2
3
3
4
4
5
# esp8266_milight_hub
@@ -60,7 +61,13 @@ platformio run -e $ESP_BOARD --target upload
60
61
61
62
Of course make sure to substitute `nodemcuv2` with the board that you're using.
62
63
63
-
You can find pre-compiled firmware images on the [releases](https://github.com/sidoh/esp8266_milight_hub/releases).
64
+
**Note that currently you'll need to use the beta version of PlatformIO.** To install with pip:
You can find pre-compiled firmware images on the [releases](https://github.com/bombcheck/esp8266_milight_hub/releases).
64
71
65
72
#### Configure WiFi
66
73
@@ -95,6 +102,7 @@ The HTTP endpoints (shown below) will be fully functional at this point. You sho
95
102
1.`GET /radio_configs`. Get a list of supported radio configs (aka `device_type`s).
96
103
1.`GET /gateway_traffic(/:device_type)?`. Starts an HTTP long poll. Returns any Milight traffic it hears. Useful if you need to know what your Milight gateway/remote ID is. Since protocols for RGBW/CCT are different, specify one of `rgbw`, `cct`, or `rgb_cct` as `:device_type. The path `/gateway_traffic` without a `:device_type` will sniff for all protocols simultaneously.
97
104
1.`PUT /gateways/:device_id/:device_type/:group_id`. Controls or sends commands to `:group_id` from `:device_id`. Accepts a JSON blob. The schema is documented below in the _Bulb commands_ section.
105
+
1.`GET /gateways/:device_id/:device_type/:group_id`. Returns a JSON blob describing the state of the the provided group.
98
106
1.`POST /raw_commands/:device_type`. Sends a raw RF packet with radio configs associated with `:device_type`. Example body:
@@ -161,11 +169,15 @@ To configure your ESP to integrate with MQTT, fill out the following settings:
161
169
162
170
#### More detail on `mqtt_topic_pattern`
163
171
164
-
`mqtt_topic_pattern` leverages single-level wildcards (documented [here](https://mosquitto.org/man/mqtt-7.html)). For example, specifying `milight/:device_id/:device_type/:group_id` will cause the ESP to subscribe to the topic `milight/+/+/+`. It will then interpret the second, third, and fourth tokens in topics it receives messages on as `:device_id`, `:device_type`, and `:group_id`, respectively.
172
+
`mqtt_topic_pattern` leverages single-level wildcards (documented [here](https://mosquitto.org/man/mqtt-7.html)). For example, specifying `milight/:device_id/:device_type/:group_id` will cause the ESP to subscribe to the topic `milight/+/+/+`. It will then interpret the second, third, and fourth tokens in topics it receives messages on as `:device_id`, `:device_type`, and `:group_id`, respectively. The following tokens are available:
173
+
174
+
1. `:device_id` - Device ID. Can be hexadecimal (e.g. `0x1234`) or decimal (e.g. `4660`).
175
+
1. `:device_type` - Remote type. `rgbw`, `fut089`, etc.
176
+
1. `:group_id` - Group. 0-4 for most remotes. The "All" group is group 0.
165
177
166
178
Messages should be JSON objects using exactly the same schema that the REST gateway uses for the `/gateways/:device_id/:device_type/:group_id` endpoint. Documented above in the _Bulb commands_ section.
167
179
168
-
##### Example:
180
+
#### Example:
169
181
170
182
If `mqtt_topic_pattern` is set to `milight/:device_id/:device_type/:group_id`, you could send the following message to it (the below example uses a ruby MQTT client):
171
183
@@ -180,26 +192,41 @@ This will instruct the ESP to send messages to RGB+CCT bulbs with device ID `0x1
180
192
181
193
#### Updates
182
194
183
-
To enable passive listening, make sure that `listen_repeats` is set to something larger than 0 (the default value of 3 is a good choice).
195
+
ESPMH is capable of providing two types of updates:
196
+
197
+
1. Delta: as packets are received, they are translated into the corresponding command (e.g., "set brightness to 50"). The translated command is sent as an update.
198
+
2. State: When an update is received, the corresponding command is applied to known group state, and the whole state for the group is transmitted.
184
199
185
-
To publish data from intercepted packets to an MQTT topic, configure MQTT server settings, and set the `mqtt_update_topic_pattern` to something of your choice. As with `mqtt_topic_pattern`, the tokens `:device_id`, `:device_type`, and `:group_id` will be substituted with the values from the relevant packet.
200
+
##### Delta updates
186
201
187
-
The published message is a JSON blob containing the following keys:
202
+
To publish data from intercepted packets to an MQTT topic, configure MQTT server settings, and set the `mqtt_update_topic_pattern` to something of your choice. As with `mqtt_topic_pattern`, the tokens `:device_id`, `:device_type`, and `:group_id` will be substituted with the values from the relevant packet. `:device_id` will always be substituted with the hexadecimal value of the ID. You can also use `:hex_device_id`, or `:dec_device_id` if you prefer decimal.
188
203
189
-
*`device_id`
190
-
*`device_type` (rgb_cct, rgbw, etc.)
191
-
*`group_id`
192
-
* Any number of: `status`, `level`, `hue`, `saturation`, `kelvin`
204
+
The published message is a JSON blob containing the state that was changed.
193
205
194
-
As an example, if `mqtt_update_topic_pattern` is set to `milight/updates/:device_id/:device_type/:group_id`, and the group 1 on button of a Milight remote is pressed, the following update will be dispatched:
206
+
As an example, if `mqtt_update_topic_pattern` is set to `milight/updates/:hex_device_id/:device_type/:group_id`, and the group 1 on button of a Milight remote is pressed, the following update will be dispatched:
**Make sure that `mqtt_topic_pattern`, `mqtt_state_topic_pattern`, and `matt_update_topic_pattern` are all different!** If they are they same you can put your ESP in a loop where its own updates trigger an infinite command loop.
229
+
203
230
## UDP Gateways
204
231
205
232
You can add an arbitrary number of UDP gateways through the REST API or through the web UI. Each gateway server listens on a port and responds to the standard set of commands supported by the Milight protocol. This should allow you to use one of these with standard Milight integrations (SmartThings, Home Assistant, OpenHAB, etc.).
0 commit comments