Everything was just working good untill last week as the relay/button state automatically changed like the ON state was to OFF Condition and the other is the opposite.
So if I turn the Relay on in app, Physically relay would turned off and when I turn off in the App/pc the Relay will be turned on.
I changed the state in Data stream but that doesn’t reflect or work here. It was working fine the before day Night and no one Has done anything. By next day morning when I tried to turn on it doesn’t on and the relay energised after I turned off.
Personally, I don’t solve this type of problem by flipping the min/max values for the widget. Instead, I’ll do something like this…
If you have a relay that is active LOW (it is energised when the pin is pulled LOW rather than HIGH) and you want to control it via a widget switch attached to pin V0 then I’ll do this…
int widget_state - param.asInt();
the exclamation mark symbol (!) before widget_state tells the code to do a logical NOT operation on the value. That sounds complicated, but basically it just flips the value, turning a 1 into a 0 and a 0 into a 1.
So, when the switch widget sends a 1 value when the button is pressed and in the on position, you send a 0 to the relay, which will energise it.