mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 05:06:44 +00:00
Faster statusupdate check
This commit is contained in:
parent
5b3a7b6140
commit
3991647597
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
dispatch_conf_t dispatch_setings = {.teleperiod = 300};
|
dispatch_conf_t dispatch_setings = {.teleperiod = 300};
|
||||||
|
|
||||||
uint32_t dispatchLastMillis = -3000000; // force discovery
|
uint16_t dispatchSecondsToNextTeleperiod = 0;
|
||||||
uint8_t nCommands = 0;
|
uint8_t nCommands = 0;
|
||||||
haspCommand_t commands[21];
|
haspCommand_t commands[21];
|
||||||
|
|
||||||
@ -912,7 +912,7 @@ void dispatch_statusupdate(const char*, const char*)
|
|||||||
|
|
||||||
memcpy_P(topic, PSTR("statusupdate"), 13);
|
memcpy_P(topic, PSTR("statusupdate"), 13);
|
||||||
dispatch_state_subtopic(topic, data);
|
dispatch_state_subtopic(topic, data);
|
||||||
dispatchLastMillis = millis();
|
dispatchSecondsToNextTeleperiod = dispatch_setings.teleperiod;
|
||||||
|
|
||||||
/* if(updateEspAvailable) {
|
/* if(updateEspAvailable) {
|
||||||
mqttStatusPayload += F("\"updateEspAvailable\":true,");
|
mqttStatusPayload += F("\"updateEspAvailable\":true,");
|
||||||
@ -1037,11 +1037,13 @@ IRAM_ATTR void dispatchLoop()
|
|||||||
#if 1 || ARDUINO
|
#if 1 || ARDUINO
|
||||||
void dispatchEverySecond()
|
void dispatchEverySecond()
|
||||||
{
|
{
|
||||||
if(mqttIsConnected() && dispatch_setings.teleperiod > 0 &&
|
if(dispatchSecondsToNextTeleperiod > 1) {
|
||||||
(millis() - dispatchLastMillis) >= dispatch_setings.teleperiod * 1000) {
|
dispatchSecondsToNextTeleperiod--;
|
||||||
dispatchLastMillis += dispatch_setings.teleperiod * 1000;
|
|
||||||
|
} else if(dispatch_setings.teleperiod > 0 && mqttIsConnected()) {
|
||||||
dispatch_statusupdate(NULL, NULL);
|
dispatch_statusupdate(NULL, NULL);
|
||||||
dispatch_send_discovery(NULL, NULL);
|
dispatch_send_discovery(NULL, NULL);
|
||||||
|
dispatchSecondsToNextTeleperiod = dispatch_setings.teleperiod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user