summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md28
-rw-r--r--main.go4
-rw-r--r--shelly.go6
-rw-r--r--tplink.go6
4 files changed, 38 insertions, 6 deletions
diff --git a/README.md b/README.md
index cb3be93..e0555a0 100644
--- a/README.md
+++ b/README.md
@@ -118,9 +118,21 @@ For all terms not explained here see the [MQTT version 3.1.1 documentation][9].
- `open`: contact is open
- `closed`: contact is closed
+### `/cover/<id>`
+
+- description: Discovery of Shelly 2PM Gen3 covers
+- direction: Sia server to client
+- Quality of Service: QoS 1 (at least once)
+- retained: yes
+- receives will message: no
+- topic parameters:
+ - `id`: ID of the Shelly 2PM Gen3 cover
+- payloads:
+ - `exists`: a device with the given ID exists
+
### `/cover/<id>/movement`
-- description: Allows control of Shelly 2PM Gen3 covers
+- description: Control of Shelly 2PM Gen3 covers
- direction: client to Sia server
- Quality of Service: QoS 2 (exactly once)
- retained: no
@@ -132,9 +144,21 @@ For all terms not explained here see the [MQTT version 3.1.1 documentation][9].
- `retract`: cover decreases the covering surface
- `stop`: cover stops current motion if given
+### `/plug/<id>`
+
+- description: Discovery of TP-Link HS100 Wi-Fi plugs
+- direction: Sia server to client
+- Quality of Service: QoS 1 (at least once)
+- retained: yes
+- receives will message: no
+- topic parameters:
+ - `id`: ID of the TP-Link HS100 Wi-Fi plug
+- payloads:
+ - `exists`: a device with the given ID exists
+
### `/plug/<id>/action`
-- description: Implements control of tp-link HS100 Wi-Fi plugs
+- description: Control of TP-Link HS100 Wi-Fi plugs
- direction: client to Sia server
- Quality of Service: QoS 2 (exactly once)
- retained: no
diff --git a/main.go b/main.go
index 3194359..ef59574 100644
--- a/main.go
+++ b/main.go
@@ -24,8 +24,8 @@ func main() {
go MQTTRun(config.MQTT, tx, coverMovement, plugAction)
go HomematicRun(config.Homematic, tx)
- go ShellyRun(config.Shelly, coverMovement)
- go TPLinkRun(config.TPLink, plugAction)
+ go ShellyRun(config.Shelly, tx, coverMovement)
+ go TPLinkRun(config.TPLink, tx, plugAction)
Await(syscall.SIGTERM, syscall.SIGINT)
}
diff --git a/shelly.go b/shelly.go
index 508b393..2fa2fa6 100644
--- a/shelly.go
+++ b/shelly.go
@@ -9,7 +9,11 @@ import (
"github.com/gorilla/websocket"
)
-func ShellyRun(config ShellyConfigs, route Route) {
+func ShellyRun(config ShellyConfigs, tx chan MQTTMessage, route Route) {
+ for _, shelly := range config {
+ tx <- MQTTMessage{fmt.Sprintf("cover/%s", shelly.ID), []byte("exists"), true}
+ }
+
for message := range route.Destination {
ip, command, err := parseMessage(config, message)
if err != nil {
diff --git a/tplink.go b/tplink.go
index 11d8ab1..a256e71 100644
--- a/tplink.go
+++ b/tplink.go
@@ -16,7 +16,11 @@ const (
TPLink_HS100_OFF = false
)
-func TPLinkRun(config TPLinkConfigs, route Route) {
+func TPLinkRun(config TPLinkConfigs, tx chan MQTTMessage, route Route) {
+ for _, tplink := range config {
+ tx <- MQTTMessage{fmt.Sprintf("plug/%s", tplink.ID), []byte("exists"), true}
+ }
+
for message := range route.Destination {
ip, action, err := tplinkParseMessage(config, message)
if err != nil {