diff options
| -rw-r--r-- | README.md | 28 | ||||
| -rw-r--r-- | main.go | 4 | ||||
| -rw-r--r-- | shelly.go | 6 | ||||
| -rw-r--r-- | tplink.go | 6 |
4 files changed, 38 insertions, 6 deletions
@@ -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 @@ -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) } @@ -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 { @@ -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 { |
