Template binary sensor based on 2 GPIO ports' status

I’d like to make a binary sensor on my Wemos D1 Mini, which is based on state of 2 GPIO port (D6 and D7). If both of them are FALSE then the template sensor has to be TRUE, in any other case it has to be FALSE. Can anybody help how to code this?

To be more accurate I have these 2 binary sensors:


  - platform: gpio
    name: "Gate totally opened"
    id: "gate_totally_opened"
    pin: 
      number: D6
      inverted: true
      mode:
        input: true
        pullup: true
  - platform: gpio
    name: "Gate totally closed"
    id: "gate_totally_closed"
    pin: 
      number: D7
      inverted: true
      mode:
        input: true
        pullup: true

And I’d like to have a third binary sensor which is ON (TRUE) it is not “totally open” or “totally closed”. This binary sensor would be “partially open”.

Maybe something like this using XOR?

binary_sensor:
  - platform: template
    name: "Gate partially opened"
    id: "gate_partially_opened"
    lambda: "return id(gate_totally_opened).state ^ id(gate_totally_closed).state;"

Thanks, it seems good, but it gives the opposit. Can I invert it somehow?

    lambda: "return !(id(gate_totally_opened).state || id(gate_totally_closed).state);"

Logic on a Monday morning… :woozy_face:

Yeah, that’s so embarassing :frowning:
But finally the NOT (!) is the solution. Anyway thanks for helping me!