Hello,
I have a ESPHome with :
binary_sensor:
- platform: status
id: "esp_carte_relais_status"
name: "ESP Carte Relais Status"
switch:
- platform: gpio
pin: GPIO32
name: "Arrosage - Arrière - GAG"
id: "relais_1"
icon: mdi:sprout
on_turn_on:
then:
- switch.turn_off: relais_2
- switch.turn_off: relais_3
- switch.turn_off: relais_4
- delay: 5s
- platform: gpio
pin: GPIO33
name: "Arrosage - Arrière 1"
icon: mdi:sprinkler-variant
id: "relais_2"
on_turn_on:
then:
- switch.turn_off: relais_1
- switch.turn_off: relais_3
- switch.turn_off: relais_4
- delay: 5s
- platform: gpio
pin: GPIO25
name: "Arrosage - Arrière 2"
id: "relais_3"
icon: mdi:sprinkler-variant
on_turn_on:
then:
- switch.turn_off: relais_1
- switch.turn_off: relais_2
- switch.turn_off: relais_4
- delay: 5s
- platform: gpio
pin: GPIO26
name: "Arrosage - Avant 1"
id: "relais_4"
icon: mdi:sprinkler-variant
on_turn_on:
then:
- switch.turn_off: relais_1
- switch.turn_off: relais_2
- switch.turn_off: relais_3
- delay: 5s
interval:
- interval: 5s
startup_delay: 10s
then:
- lambda: |-
if (id(esp_carte_relais_status).state) return;
if (!id(esp_carte_relais_status).state) {
if (id(relais_1).state) id(relais_1).turn_off;
if (id(relais_2).state) id(relais_2).turn_off;
if (id(relais_3).state) id(relais_3).turn_off;
if (id(relais_4).state) id(relais_4).turn_off;
};
But i go error with my lambda in interval key :
/config/esphome/esp-carte-relais.yaml: In lambda function:
/config/esphome/esp-carte-relais.yaml:184:40: error: invalid use of non-static member function 'void esphome::switch_::Switch::turn_off()'
if (id(relais_1).state) id(relais_1).turn_off;
~~~~~~~~~~^~~~~~~~
In file included from src/esphome/core/controller.h:23,
from src/esphome/components/api/api_server.h:9,
from src/esphome/components/api/api_connection.h:6,
from src/esphome.h:3,
from src/main.cpp:3:
src/esphome/components/switch/switch.h:67:8: note: declared here
void turn_off();
^~~~~~~~
/config/esphome/esp-carte-relais.yaml:185:40: error: invalid use of non-static member function 'void esphome::switch_::Switch::turn_off()'
if (id(relais_2).state) id(relais_2).turn_off;
~~~~~~~~~~^~~~~~~~
In file included from src/esphome/core/controller.h:23,
from src/esphome/components/api/api_server.h:9,
from src/esphome/components/api/api_connection.h:6,
from src/esphome.h:3,
from src/main.cpp:3:
src/esphome/components/switch/switch.h:67:8: note: declared here
void turn_off();
^~~~~~~~
/config/esphome/esp-carte-relais.yaml:186:40: error: invalid use of non-static member function 'void esphome::switch_::Switch::turn_off()'
if (id(relais_3).state) id(relais_3).turn_off;
~~~~~~~~~~^~~~~~~~
In file included from src/esphome/core/controller.h:23,
from src/esphome/components/api/api_server.h:9,
from src/esphome/components/api/api_connection.h:6,
from src/esphome.h:3,
from src/main.cpp:3:
src/esphome/components/switch/switch.h:67:8: note: declared here
void turn_off();
^~~~~~~~
/config/esphome/esp-carte-relais.yaml:187:40: error: invalid use of non-static member function 'void esphome::switch_::Switch::turn_off()'
if (id(relais_4).state) id(relais_4).turn_off;
~~~~~~~~~~^~~~~~~~
In file included from src/esphome/core/controller.h:23,
from src/esphome/components/api/api_server.h:9,
from src/esphome/components/api/api_connection.h:6,
from src/esphome.h:3,
from src/main.cpp:3:
src/esphome/components/switch/switch.h:67:8: note: declared here
void turn_off();
^~~~~~~~
What i need to do is if binary_status tell me ESP isn’t logged to HA from API, then turn off all switch.
I don’t know how i can do it .
Thanks