Below is a picture of my two PLCs (x410 and x310). I can read the coil (relays) states no problem but when I create a switch, how do I get the initial state? I created a switch called X410Relay1 switch, but how can I get it to keep state?
After viewing some other examples online, I am trying to get the output state of relay 1 and run it through change to mimic a toggle switch when x410_relay_switch is pressed…
but debug1 and 2 never turn true as they remain always false. Am I missing something here?
Basically, I would like to create a switch for the UI lovelace that has the initial state of the PLC relays correct and as the state changes it updates the value as well. I have tried SNMP, XML, and now giving Modbus a try.
Your change node will make a mess, because each of the changes are done in sequence, so first you change all to one value and then you change all those that were changed and all those that had the value from the beginning back to the first value.
You need an extra step.
Wally, thanks for your tip. I thought the change node changes were done similarly to an IF statement. Now it works exactly as the toggle switch I had wanted.
At this point, how do I incorporate this to an actual switch. When I run this I get an infinite loop of the relay turning on and off.