diff --git a/src/bin/calaos_server/IO/Mqtt/MqttOutputLightRGB.cpp b/src/bin/calaos_server/IO/Mqtt/MqttOutputLightRGB.cpp index 33540457..6c3404b2 100644 --- a/src/bin/calaos_server/IO/Mqtt/MqttOutputLightRGB.cpp +++ b/src/bin/calaos_server/IO/Mqtt/MqttOutputLightRGB.cpp @@ -30,7 +30,7 @@ MqttOutputLightRGB::MqttOutputLightRGB(Params &p): OutputLightRGB(p) { // We use real state for this IO: only emit change when the value really changes - useRealState = true; + //useRealState = true; // Define IO documentation ioDoc->friendlyNameSet("MqttOutputLightRGB"); @@ -58,12 +58,11 @@ void MqttOutputLightRGB::readValue() bool err; auto c = ctrl->getValueColor(get_params(), err); - if (!err) - { - color = c; - EmitSignalIO(); - emitChange(); - } + //TODO: it does not work for now. We need to refactor the way it handle color+state in all + //RGB class and also add better state/color/brightness control in calaos + + //if (!err) + //stateUpdated(c, c != ColorValue(0, 0, 0)); } void MqttOutputLightRGB::setColorReal(const ColorValue &c, bool _state) diff --git a/src/bin/calaos_server/IO/OutputLightRGB.cpp b/src/bin/calaos_server/IO/OutputLightRGB.cpp index 3b7a23e3..57854a81 100644 --- a/src/bin/calaos_server/IO/OutputLightRGB.cpp +++ b/src/bin/calaos_server/IO/OutputLightRGB.cpp @@ -318,12 +318,17 @@ void OutputLightRGB::TimerAutoChange() void OutputLightRGB::stateUpdated(const ColorValue &c, bool s) { - color = c; + bool hasChanged = false; + if (s != state || c != color) + hasChanged = true; + state = s; + color = c; cmd_state = "set " + get_value_string(); EmitSignalIO(); - emitChange(); + if (hasChanged) + emitChange(); } bool OutputLightRGB::check_condition_value(std::string cvalue, bool equal) diff --git a/src/bin/calaos_server/IO/Wago/WODaliRVB.cpp b/src/bin/calaos_server/IO/Wago/WODaliRVB.cpp index 92b11467..9a83a277 100644 --- a/src/bin/calaos_server/IO/Wago/WODaliRVB.cpp +++ b/src/bin/calaos_server/IO/Wago/WODaliRVB.cpp @@ -155,7 +155,7 @@ void WODaliRVB::checkReadState() double(green) * 255. / 100., double(blue) * 255. / 1000.); - stateUpdated(c, red != 0 || green != 0 || blue != 0); + stateUpdated(c, red != 0 && green != 0 && blue != 0); } void WODaliRVB::WagoUDPCommand_cb(bool status, string command, string)