Ensure MQTT messages are only set if state actually changed
This commit is contained in:
@ -327,8 +327,10 @@ void channel_override_set(int idx) {
|
||||
match = timespec_match_now(s_channels[idx].timespec);
|
||||
if (match != s_channels[idx].relay_state) {
|
||||
LOG(LL_INFO, ("User state disagrees with timespec, setting override"));
|
||||
if (!s_channels[idx].channel_override) {
|
||||
s_channels[idx].channel_override = true;
|
||||
mqtt_publish_stat("override", "{idx: %d, relay_state: %d, override: %B}", idx, s_channels[idx].relay_state, s_channels[idx].channel_override);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (s_channels[idx].channel_override && (match == s_channels[idx].relay_state)) {
|
||||
@ -345,8 +347,10 @@ void channel_override_clear(int idx) {
|
||||
return;
|
||||
}
|
||||
|
||||
s_channels[idx].channel_override = false;
|
||||
if (s_channels[idx].channel_override) {
|
||||
mqtt_publish_stat("override", "{idx: %d, relay_state: %d, override: %B}", idx, s_channels[idx].relay_state, s_channels[idx].channel_override);
|
||||
s_channels[idx].channel_override = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user