I've been working on a smart shutoff valve for my water tank. I have a motorized valve with 4 input wires. If you apply 12v to one set, the valve turns until it's closed. At that position, a micro switch is triggered and the 12v supply to the motor is cut, regardless of if 12v is still on the wires. This prevents the motor from trying to turn past the position. When you apply 12v to the other set, the same thing happens for the reverse for opening.
I'm using a konnected board with the switchable output for 2 zones. I've timed the opening and closing delay and set the switch activation to be about 9 seconds (the time it takes to open or close).
My question is, how can I make an entity/card/value to display in HA that says if the valve is opened or closed based on the last switch that was pressed? Basically. If you press the close button, you can assume that the valve was closed and the water is off. And if the last button you pressed was open, then you can assume the valve opened and the water is on.
Or should I think bigger and try to wrap it all up together in a virtual switch that for the "on" press, it calls the corresponding konnected switch activation and for the "off" setting, it's calling the other one?
Thanks in advance.