diff --git a/docs/api/zones.http b/docs/api/zones.http new file mode 100644 index 0000000..22b3d1a --- /dev/null +++ b/docs/api/zones.http @@ -0,0 +1,26 @@ +// @no-cookie-jar +GET {{host}}/api/v1/apartment/zones +Authorization: Bearer {{api-key}} + +### + +// @no-cookie-jar +GET {{host}}/api/v1/apartment/zones/status +Authorization: Bearer {{api-key}} + + +### +// @no-cookie-jar +PATCH {{host}}/api/v1/apartment/zones/5/status +Authorization: Bearer {{api-key}} +Content-Type: application/json + +[ + { + "op": "replace", + "path": "/applications/temperature/setpoint", + "value": 20 + } +] + + diff --git a/pkg/mqtt/client.go b/pkg/mqtt/client.go index 65d6cb8..69f0cde 100644 --- a/pkg/mqtt/client.go +++ b/pkg/mqtt/client.go @@ -55,7 +55,11 @@ func NewClient(options *ClientOptions) Client { SetClientID("digitalstrom-mqtt-" + uuid.New().String()). SetOrderMatters(false). SetUsername(options.Username). - SetPassword(options.Password) + SetPassword(options.Password). + SetAutoReconnect(true). + SetReconnectingHandler(func(client mqtt.Client, options *mqtt.ClientOptions) { + log.Info().Msg("Reconnecting to MQTT server.") + }) return &client{ mqttClient: mqtt.NewClient(mqttOptions), @@ -64,6 +68,7 @@ func NewClient(options *ClientOptions) Client { } func (c *client) Connect() error { + t := c.mqttClient.Connect() <-t.Done() if t.Error() != nil {