ESP Home Binary Sensor IF

Hi Guys

I’m new to ESPHome and its a stupid question. but how do i get this to run?

It should the sensor 1 on if all the others are off.

image

Thank you for your help!

Hi and welcome to the forum.

Could you please paste the actual configuration text rather than an image of the text. This helps us help you as we can copy/edit/paste easily. Instructions on formatting your pasted text are outlined in point 11 here.

my bad.

binary_sensor:
  - platform: gpio
    pin: GPIO13
    name: "Lüftungsschalter Wohnzimmer 0"
    

  - platform: template
    name: "Lüftungsschalter Wohnzimmer 1"
    lambda: |-
      if (id("Lüftungsschalter Wohnzimmer 0").state) {
        return true;
      } else {
        return false;
      }

  - platform: gpio
    pin: GPIO14
    name: "Lüftungsschalter Wohnzimmer 2"
    
  
  - platform: gpio
    pin: GPIO26
    name: "Lüftungsschalter Wohnzimmer 3"

Did you mean sensor 1?

Sensor 1 has the template, sensor 2 is a GPIO binary sensor.

binary_sensor:
  - platform: gpio
    pin: GPIO13
    name: "Lüftungsschalter Wohnzimmer 0"
    id: "LW0"
    
  - platform: template
    name: "Lüftungsschalter Wohnzimmer 1"
    lambda: |-
      if (id("LW0").state) && (id("LW2").state) && (id("LW3").state) {
        return true;
      } else {
        return false;
      }

  - platform: gpio
    pin: GPIO14
    name: "Lüftungsschalter Wohnzimmer 2"
    id: "LW2"
  
  - platform: gpio
    pin: GPIO26
    name: "Lüftungsschalter Wohnzimmer 3"
    id: "LW3"

Sorry yes sensor 1.

if not sensor 0 & sensor 2 & sensor 3
then sensor 1 true
else
sensor 1 false

  - platform: template
    name: "Lüftungsschalter Wohnzimmer 1"
    lambda: |-
      if !(id("LW0").state) && (id("LW2").state) && (id("LW3").state) {
        return true;
      } else {
        return false;
      }

Thanks for helping.

But I’m getting this error while compiling.

What is the problem?

Remove the quotes from around the ids.


  - platform: template
    name: "Lüftungsschalter Wohnzimmer 1"
    lambda: |-
      if !(id(LW0).state) && (id(LW2).state) && (id(LW3).state) {
        return true;
      } else {
        return false;
      }
1 Like

Thanks alot

1 Like