hello
im trying to used this code to control the humidity in the bath but i got this error
any help please ?
Thanks
esphome:
name: esp32-wifi
friendly_name: ESP32-WIFI
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "jqo2W1M5OO7/SsRJ0QV7SB7A0mGA1ZXFrhIEh03wI+E="
ota:
- platform: esphome
password: "25ace7e66682783f65c589deeebea095"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-Wifi Fallback Hotspot"
password: "89oOnSnN1Qg5"
captive_portal:
i2c:
sda: 21
scl: 22
scan: true
id: bus_a
light:
- platform: binary
name: "Fan On/Off"
output: on_off
id: power
restore_mode: ALWAYS_OFF
output:
- platform: gpio
pin: 33
id: on_off
binary_sensor:
- platform: gpio
pin:
number: 32
mode:
input: true
pullup: true
name: "Fan Button"
device_class: power
on_press:
then:
- homeassistant.service:
service: script.BreadboardFanDemo
filters:
- delayed_on: 100ms
sensor:
- platform: bme280_i2c
temperature:
name: "WorkBench Temperature"
oversampling: 16x
filters:
- lambda: return x * (9.0/5.0) + 29.0;
unit_of_measurement: "°F"
humidity:
name: "WorkBench Humidity"
filters:
- lambda: return x + 6;
address: 0x76
update_interval: 5s
zoogara
(Daryl)
June 29, 2025, 8:13am
2
In YAML indentation is everything. Your indentation (assuming you just copy/pasted) will not work.
As an example:
light:
- platform: binary
name: "Fan On/Off"
output: on_off
id: power
restore_mode: ALWAYS_OFF
output:
- platform: gpio
pin: 33
id: on_off
And so forth.
try again fixing the rest of the code - the indentation you see in the documentation is not just to make it pretty - it is part of the syntax.
thanks alot i fixed the code and i got now this one any idea ?
esphome:
name: esp32-wifi
friendly_name: ESP32-WIFI
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "jqo2W1M5OO7/SsRJ0QV7SB7A0mGA1ZXFrhIEh03wI+E="
ota:
- platform: esphome
password: "25ace7e66682783f65c589deeebea095"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-Wifi Fallback Hotspot"
password: "89oOnSnN1Qg5"
captive_portal:
i2c:
sda: 21
scl: 22
scan: true
id: bus_a
light:
- platform: binary
name: "Fan On/Off"
output: on_off
id: power
restore_mode: ALWAYS_OFF
output:
- platform: gpio
pin: 33
id: on_off
binary_sensor:
- platform: gpio
pin:
number: 32
mode:
input: true
pullup: true
name: "Fan Button"
device_class: power
on_press:
then:
- homeassistant.service:
service: script.BreadboardFanDemo
filters:
- delayed_on: 100ms
sensor:
- platform: bme280_i2c
temperature:
name: "WorkBench Temperature"
oversampling: 16x
filters:
- lambda: return x * (9.0/5.0) + 29.0;
unit_of_measurement: "°F"
humidity:
name: "WorkBench Humidity"
filters:
- lambda: return x + 6;
address: 0x76
update_interval: 5s
zoogara
(Daryl)
June 29, 2025, 8:55am
4
Again - indentation…
binary_sensor:
- platform: gpio
pin:
number: 32
mode:
input: true
pullup: true
name: "Fan Button"
device_class: power
filters:
- delayed_on: 100ms
on_press:
then:
- homeassistant.service:
service: script.BreadboardFanDemo
Look at the the docs. The first example on this page shows you the correct indentations.
zoogara
(Daryl)
June 29, 2025, 8:59am
5
Also - home assistant.service:
is depreciated - use home assistant.action:
instead.
zoogara:
home assistant.action
thanks alot much appreciate ur help
hi
im sorry to bother you again i got stuck here whenever i change the code im getting different error i dont know how to fixed this i went through the doc and i didnt get it ??
esphome:
name: esp32-wifi
friendly_name: ESP32-WIFI
esp32:
board: esp32dev
framework:
type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "jqo2W1M5OO7/SsRJ0QV7SB7A0mGA1ZXFrhIEh03wI+E="
ota:
- platform: esphome
password: "25ace7e66682783f65c589deeebea095"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-Wifi Fallback Hotspot"
password: "89oOnSnN1Qg5"
captive_portal:
i2c:
sda: 21
scl: 22
scan: true
id: bus_a
light:
- platform: binary
name: "Fan On/Off"
output: on_off
id: power
restore_mode: ALWAYS_OFF
output:
- platform: gpio
pin: 33
id: on_off
binary_sensor:
- platform: gpio
pin:
number: 32
mode:
input: true
pullup: true
name: "Fan Button"
device_class: power
filters:
- delayed_on: 100ms
on_press:
then:
- homeassistant.action:
service: script.BreadboardFanDemo
sensor:
- platform: bme280_i2c
temperature:
name: "WorkBench Temperature"
oversampling: 16x
filters:
- lambda: return x * (9.0/5.0) + 29.0;
unit_of_measurement: "°F"
humidity:
name: "WorkBench Humidity"
filters:
- lambda: return x + 6;
address: 0x76
update_interval: 5s
Karosm
(Karosm)
June 29, 2025, 4:34pm
8
Something like this. Indentations are PITA, but documentation gives examples…
sensor:
- platform: bme280_i2c
temperature:
name: "WorkBench Temperature"
oversampling: 16x
filters:
- lambda: return x * (9.0/5.0) + 29.0;
unit_of_measurement: "°F"
humidity:
name: "WorkBench Humidity"
filters:
- lambda: return x + 6;
address: 0x76
update_interval: 5s