adding mqtt sleep time before doing disconnect

This commit is contained in:
Tobias Lindberg
2021-03-16 15:19:23 +01:00
parent 9cbb2fa244
commit a5bda76a93
2 changed files with 5 additions and 2 deletions

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

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)