Skip to content

Commit 028dd42

Browse files
authored
Release 0.2.0 (#32)
* Bump version numbers * Print the http server host/port * update known issues * document the http server
1 parent 5431b53 commit 028dd42

File tree

6 files changed

+501
-19
lines changed

6 files changed

+501
-19
lines changed

.idea/dbnavigator.xml

Lines changed: 461 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
## Next
2+
3+
## 0.2.0
24
- Add HTTP server running on port 3000. You can toggle stuff on it!
35
- Crash when the message queue is full, in the hopes that the supervisor restarts us. rumqttc seems to have issues reconnecting sometimes.
46
- Broadcast discovery info every time we connect to the mqtt server.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cargo-features = ["strip"]
22

33
[package]
44
name = "wink-mqtt-rs"
5-
version = "0.2.0-prerelease"
5+
version = "0.2.0"
66
authors = ["Mike Kaplinskiy <[email protected]>"]
77
edition = "2018"
88
license = "CC-BY-4.0"

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ You can configure more options by editing the `/opt/wink-mqtt-rs/config` file af
2020

2121
## Usage
2222
```bash
23-
wink-mqtt-rs 0.1.5
23+
wink-mqtt-rs 0.2.0
2424
Mike Kaplinskiy <[email protected]>
2525
wink hub v1 mqtt bridge
2626

2727
USAGE:
28-
wink-mqtt-rs [FLAGS] [OPTIONS] -s <mqtt-uri>
28+
wink-mqtt-rs [FLAGS] [OPTIONS]
2929

3030
FLAGS:
3131
-h, --help Prints help information
@@ -34,16 +34,23 @@ FLAGS:
3434

3535
OPTIONS:
3636
--discovery-listen-topic <discovery-listen-topic>
37-
Topic to listen to in order to (re)broadcast discovery information. Only applies if --discovery-prefix is
38-
set. [default: homeassistant/status]
37+
Topic to listen to in order to (re)broadcast discovery information. Only applies if
38+
--discovery-prefix is set. [default: homeassistant/status]
39+
3940
-d <discovery-prefix>
40-
Prefix (applied independently of --topic-prefix) to broadcast mqtt discovery information (see
41-
https://www.home-assistant.io/docs/mqtt/discovery/)
41+
Prefix (applied independently of --topic-prefix) to broadcast mqtt discovery information
42+
(see https://www.home-assistant.io/docs/mqtt/discovery/)
43+
44+
--http-port <http-port>
45+
If you'd like an http server, this is the port on which to start it [default: 3000]
46+
4247
-s <mqtt-uri>
4348
mqtt server to connect to. Should be of the form
4449
mqtt[s]://[username:password@]host:port/[?connection_options]
50+
4551
-i <resync-interval>
46-
how frequently to check if the light changed state (e.g. via Wink or other external means) [default: 10000]
52+
how frequently to check if the light changed state (e.g. via Wink or other external
53+
means) [default: 10000]
4754
4855
-t <topic-prefix>
4956
Prefix for the mqtt topic used for device status/control [default: home/wink/]
@@ -64,13 +71,23 @@ If you have a topic prefix of `home/wink/`, and a device id with `1` named `Fan`
6471
6572
Messages on the discovery topic follow a format that works with home assistant MQTT discovery. For details, see [converter.rs](https://github.com/mikekap/wink-mqtt-rs/blob/master/src/converter.rs).
6673
74+
### HTTP Server
75+
76+
An HTTP server is started (by default on port 3000) to let you see a quick UI of what your wink sees. Visit `http://192.168.1.123:3000/` in your browser to see it (replacing `192.168.1.123` with however you reach your wink).
77+
78+
In addition, there's an (unstable) REST API to control the wink exposed via this server. The endpoints are:
79+
```
80+
# List of devices, as well as current attribute values
81+
curl http://wink:3000/api/devices
82+
83+
# Set device id 2's attribute id 3 to 255.
84+
curl http://wink:3000/api/devices/2/3 -d '{"value": 255}' -H "Content-Type: application/json"
85+
```
86+
6787
## Known Issues
6888
- Groups are not exposed.
69-
- This has only been tested with Z-Wave devices. It may not work in other scenarios.
70-
This is very easy to fix, so please file issues with the output of `aprontest -l` and `aprontest -l -m <device_id>` from your Wink!
7189
- Does not send device details to Home Assistant, even though the data exists. PRs welcome!
7290
- `mqtts` support is untested.
73-
- Could be smarter about tailing log files (like wink-mqtt), but a resync every 10 seconds seems fine.
7491
- Don't publish status if nothing changed. Easy fix, if necessary.
7592
7693
## Uninstalling

src/http.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,21 @@ impl HttpServer {
5656
}
5757
});
5858

59-
info!(slog_scope::logger(), "starting_http_server"; "port" => config.http_port.unwrap());
60-
6159
let server = Server::bind(&SocketAddr::from(([0, 0, 0, 0], config.http_port.unwrap())))
6260
.tcp_nodelay(true)
6361
.http1_only(true)
6462
.http1_keepalive(false)
65-
.serve(handler)
66-
.with_graceful_shutdown(async move {
67-
rx.await.ok();
68-
});
63+
.serve(handler);
64+
65+
info!(slog_scope::logger(), "started_http_server"; "listen_addr" => server.local_addr());
6966

7067
tokio::task::spawn(async move {
71-
server.await.log_failing_result("http_server_failed");
68+
server
69+
.with_graceful_shutdown(async move {
70+
rx.await.ok();
71+
})
72+
.await
73+
.log_failing_result("http_server_failed");
7274
});
7375

7476
this

0 commit comments

Comments
 (0)