In simple terms, I guess you want
If D0 and D1 are BOTH on SET FLAG
If D0 and D1 are BOTH off RESET FLAG
Dont change FLAG at any other time
Correct?
This should get you close...
[{"id":"20fb0cee8ea2a2ef","type":"inject","z":"ccdc4f1f78201a08","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"D1","payload":"true","payloadType":"bool","x":1190,"y":80,"wires":[["8f4edbe65aa91e82"]]},{"id":"6e90f6c6cac202aa","type":"inject","z":"ccdc4f1f78201a08","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"D1","payload":"false","payloadType":"bool","x":1200,"y":120,"wires":[["8f4edbe65aa91e82"]]},{"id":"e78180a864673fb8","type":"inject","z":"ccdc4f1f78201a08","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"D2","payload":"true","payloadType":"bool","x":1190,"y":180,"wires":[["8f4edbe65aa91e82"]]},{"id":"049bfceb212465ed","type":"inject","z":"ccdc4f1f78201a08","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"D2","payload":"false","payloadType":"bool","x":1200,"y":220,"wires":[["8f4edbe65aa91e82"]]},{"id":"8f4edbe65aa91e82","type":"join","z":"ccdc4f1f78201a08","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1390,"y":140,"wires":[["1f15ccceeb177a3c"]]},{"id":"e6780c198ec5ae2a","type":"debug","z":"ccdc4f1f78201a08","name":"Outputs when changes from true->false->true only","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2030,"y":180,"wires":[]},{"id":"1f15ccceeb177a3c","type":"change","z":"ccdc4f1f78201a08","name":"both same?","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.D1 = payload.D2 ? payload.D1 : null","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"result","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1430,"y":220,"wires":[["5767a98b344e8ffd"]]},{"id":"5767a98b344e8ffd","type":"switch","z":"ccdc4f1f78201a08","name":"both on \\n both off \\n different","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":1600,"y":220,"wires":[["3a5ad5e34599d71e"],["3a5ad5e34599d71e"],["b92fc579cc8d19b1"]]},{"id":"b92fc579cc8d19b1","type":"debug","z":"ccdc4f1f78201a08","name":"no match / not valid","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1830,"y":240,"wires":[]},{"id":"3a5ad5e34599d71e","type":"rbe","z":"ccdc4f1f78201a08","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1770,"y":180,"wires":[["e6780c198ec5ae2a"]]}]
NOTE: I used boolean (true/false) but it can easily be changed to 1/0