Skip to content

Commit e116b67

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents 67db7f1 + ad0110e commit e116b67

51 files changed

Lines changed: 2128 additions & 347 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.build_web.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def is_tool(name):
1515
except:
1616
return False;
1717

18-
def pre_build(source, target, env):
18+
def build_web():
1919
if is_tool("npm"):
2020
os.chdir("web")
2121
print("Attempting to build webpage...")
@@ -31,4 +31,4 @@ def pre_build(source, target, env):
3131
finally:
3232
os.chdir("..");
3333

34-
env.Execute(pre_build)
34+
build_web()

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ env:
1010
before_install:
1111
- nvm install $NODE_VERSION
1212
install:
13-
- pip install -U platformio
13+
- pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
1414
- platformio lib install
1515
- cd web && npm install && cd ..
1616
script:

PROTOCOL.md

Lines changed: 0 additions & 51 deletions
This file was deleted.

README.md

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
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):
23

34

45
# esp8266_milight_hub
@@ -60,7 +61,13 @@ platformio run -e $ESP_BOARD --target upload
6061

6162
Of course make sure to substitute `nodemcuv2` with the board that you're using.
6263

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:
65+
66+
```
67+
pip install -U https://github.com/platformio/platformio-core/archive/develop.zip
68+
```
69+
70+
You can find pre-compiled firmware images on the [releases](https://github.com/bombcheck/esp8266_milight_hub/releases).
6471

6572
#### Configure WiFi
6673

@@ -95,6 +102,7 @@ The HTTP endpoints (shown below) will be fully functional at this point. You sho
95102
1. `GET /radio_configs`. Get a list of supported radio configs (aka `device_type`s).
96103
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.
97104
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.
98106
1. `POST /raw_commands/:device_type`. Sends a raw RF packet with radio configs associated with `:device_type`. Example body:
99107
```
100108
{"packet": "01 02 03 04 05 06 07 08 09", "num_repeats": 10}
@@ -161,11 +169,15 @@ To configure your ESP to integrate with MQTT, fill out the following settings:
161169
162170
#### More detail on `mqtt_topic_pattern`
163171
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.
165177
166178
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.
167179
168-
##### Example:
180+
#### Example:
169181
170182
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):
171183
@@ -180,26 +192,41 @@ This will instruct the ESP to send messages to RGB+CCT bulbs with device ID `0x1
180192

181193
#### Updates
182194

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.
184199

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
186201

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.
188203

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.
193205

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:
195207

196208
```ruby
197209
irb(main):005:0> client.subscribe('milight/updates/+/+/+')
198210
=> 27
199211
irb(main):006:0> puts client.get.inspect
200-
["lights/updates/0x1C8E/rgb_cct/1", "{\"device_id\":7310,\"group_id\":1,\"device_type\":\"rgb_cct\",\"status\":\"on\"}"]
212+
["lights/updates/0x1C8E/rgb_cct/1", "{\"status\":\"on\"}"]
213+
```
214+
215+
##### Full state updates
216+
217+
For this mode, `mqtt_state_topic_pattern` should be set to something like `milight/states/:hex_device_id/:device_type/:group_id`. As an example:
218+
219+
```ruby
220+
irb(main):005:0> client.subscribe('milight/states/+/+/+')
221+
=> 27
222+
irb(main):006:0> puts client.get.inspect
223+
["lights/states/0x1C8E/rgb_cct/1", "{\"state\":\"ON\",\"brightness\":255,\"color_temp\":370,\"bulb_mode\":\"white\"}"]
224+
irb(main):007:0> puts client.get.inspect
225+
["lights/states/0x1C8E/rgb_cct/1", "{\"state\":\"ON\",\"brightness\":100,\"color_temp\":370,\"bulb_mode\":\"white\"}"]
201226
```
202227

228+
**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+
203230
## UDP Gateways
204231

205232
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.).

dist/index.html.gz.h

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)