Merge pull request #17 from tobiasehlert/bug-14

adding mqtt sleep time before doing disconnect
resolves #14
This commit is contained in:
Tobias Lindberg
2021-03-17 08:23:40 +01:00
committed by GitHub
2 changed files with 5 additions and 2 deletions
+1
View File
@@ -105,6 +105,7 @@ Basically the same environment variables for the database, mqqt and timezone nee
- **MQTT_USERNAME** string *(default: )*
- **MQTT_PASSWORD** string *(default: )*
- **MQTT_NAMESPACE** string *(default: )*
- **MQTT_SLEEPTIME** integer *(default: 100)*
## API documentation
+4 -2
View File
@@ -450,8 +450,10 @@ func TeslaMateAPICarsStatusV1(c *gin.Context) {
// run SubscribeMultiple on MQTTAllTopics map[string]byte
m.SubscribeMultiple(MQTTAllTopics, nil)
// adding some short sleep before disconnecting
time.Sleep(100 * time.Millisecond)
// getting sleep tim before disconnecting
MQTTSleepTime := getEnvAsInt("MQTT_SLEEPTIME", 100)
// adding some short sleep before disconnecting (based on MQTTSleepTimer)
time.Sleep(time.Duration(MQTTSleepTime) * time.Millisecond)
// disconnecting from MQTT
m.Disconnect(250)