The following code will complie and load ok into ESP32 without the ‘-if: condition:’ .
But adding - if: condition. causes it to fail to compile.
I can’t make out if the ‘- if’ should be after the ‘then:’ or if it’s just indentation issues…
I’ve tried many variations; the error results are always ambiguous.
(It’s right at the bottom).
Can anyone see what is wrong?
esphome:
name: "ktype-sensors-x2"
friendly_name: Ktype Sensors X2
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "LcIvLu1HrLivYJJ8k0H3b907Nb20DaG0x7g7fxt30P8="
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome-Web-3938A0"
password: "1WEPrZWpvBth"
# i²c bus DFRobot
i2c:
sda: 21
scl: 22
scan: true
frequency: 10khz
globals:
- id: pump_timer_int
type: int
restore_value: no
initial_value: '0'
sensor:
- platform: mcp9600
hot_junction:
name: "Sensor 1"
#cold_junction:
#name: "Ambient 1"
thermocouple_type: K
address: 0x63
update_interval: 10s
- platform: mcp9600
hot_junction:
name: "Sensor 2"
#cold_junction:
#name: "Ambient 1"
thermocouple_type: K
address: 0x67
update_interval: 10s
# WiFi Signal sensor.
- platform: wifi_signal
name: WiFi Signal
update_interval: 60s
switch:
- platform: gpio
pin: GPIO16
inverted: true
name: "Heater Supply"
id: heat_output
- platform: gpio
pin: GPIO17
inverted: true
name: "Circ Pump"
id: pump_output
# ++ Heat Control ++
binary_sensor:
- platform: gpio
pin:
number: 27
mode:
input: true
pullup: true
inverted: true
name: "Heat Demand"
id: heat_demand
filters:
# - delayed_on: 200ms
- delayed_off: 3s
# ++++
on_press:
then:
- switch.turn_on: pump_output
- delay: 2s
- switch.turn_on: heat_output
on_release:
then:
- switch.turn_off: heat_output
- globals.set:
id: pump_timer_int
value: '0'
interval:
- interval: 1s
-if:
condition:
-switch.is_off: heat_output
then:
- lambda: |-
if (id(pump_timer_int) < 10) {
id(pump_timer_int) += 1;
} else {
id(pump_timer_int) = 0;
id(pump_output).turn_off();
}
captive_portal: