I have my yaml file up for editing and have entered the wifi ssid and password.
Under that I have this:
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Lounge Fallback Hotspot"
password: "xxxxxxx"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
Where do I add the sensor lines, is it under api??
Thanks
Olivier1974
(Olivier Toussaint)
January 20, 2023, 8:48pm
2
Wherever you want as it is a root yaml tag (means it is at the left border of the editor, no space)
sensor:
- platform: dht
pin: D7
model: dht22
... <to be continued> ...
1 Like
@Olivier1974
No because I entered under wifi section and threw up an error
Olivier1974
(Olivier Toussaint)
January 20, 2023, 8:50pm
5
Same level as api: or ota:
1 Like
The order of where you put sensor: doesn’t matter.
It just needs to be “at level 1” indentation like api: etc.
Typically people put it below the basic config you have there. So after ota:
Olivier1974
(Olivier Toussaint)
January 20, 2023, 8:52pm
7
yaml is very forgiving except with indentations.
it must be at the very beginning of a line
sensor:
1 Like
Ok thanks but just got this error:
Failed config
sensor.bh1750: [source /config/esphome/lounge .yaml:11]
Component sensor.bh1750 requires component i2c.
platform: bh1750
name: BH1750 Illuminance
address: 35
update_interval: 60s
ap: [source /config/esphome/lounge .yaml:18]
I know what I2C is but how do I enter it in the file??
I copied the lines direct from the sensor page / part.
nickrout
(Nick Rout)
January 20, 2023, 9:21pm
11
@Rob_Heselwood I commend you to the example code found here and here
@Arh
Thanks but the pin numbers are invalid, but according to the config variables then said pin numbers are correct for my Esp32, but in the file it says
esphome:
name: lounge
platform: ESP8266
board: esp01_1m
JulianDH
(Julian Hall)
January 20, 2023, 11:10pm
13
Why did you specify ESP8266 if it is ESP32 board. Take a look at following which helps with code to specify the correct board.
@JulianDH
Thanks, but I must have had a senior moment…doh!
Anyway I have now changed it to ESP32 and nodemcu-32s as per the link you gave.
Now it’s saying:
NFO Reading configuration /config/esphome/esphome.yaml…
ERROR Error while reading config: Invalid YAML syntax:
Duplicate key "platform"
in "/config/esphome/esphome.yaml", line 17, column 3:
platform: bme280
^
NOTE: Previous declaration here:
in "/config/esphome/esphome.yaml", line 11, column 3:
platform: bh1750
^
Arh
January 21, 2023, 9:46am
15
Try this after all you wifi and board stuff. After ota:
i2c:
- id: bus_a
sda: GPIO4
scl: GPIO5
scan: true
sensor:
- platform: bh1750
i2c_id: bus_a
name: "Illuminance"
address: 0x23
update_interval: 60s
may be worth reading this (disclaimer I have not read it all to confirm it is correct or useful)
What is YAML? A beginner's guide | CircleCI .
nickrout
(Nick Rout)
January 21, 2023, 10:30am
16
How about posting your complete yaml file.
2 Likes
esphome:
name: lounge
platform: ESP32
board: esp32s
wifi:
ssid: "xxxxxxxx "
password: "xxxxxxxx"
sensor:
platform: bh1750
name: "BH1750 Illuminance"
address: 0x23
update_interval: 60s
platform: bme280
temperature:
name: "BME280 Temperature"
oversampling: 16x
pressure:
humidity:
address: 0x77
update_interval: 60s
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esphome Fallback Hotspot"
password: "xxxxxxxxxxx"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "xxxxxxxxx"
ota:
password: "xxxxxxxxx"
This yaml should generate this error
Rob_Heselwood:
NFO Reading configuration /config/esphome/esphome.yaml…
ERROR Error while reading config: Invalid YAML syntax :
Duplicate key "platform"
in "/config/esphome/esphome.yaml", line 17, column 3:
platform: bme280
^
NOTE: Previous declaration here:
in "/config/esphome/esphome.yaml", line 11, column 3:
platform: bh1750
^
So all good I would say.
Best for you @Rob_Heselwood would be to spend like 5 or 10 minutes reading what YAML is and how it “works”, some link was already posted earlier but feel free to use a search engine of your choice to gather more information
Beside if you need further help this post explains how to ask good questions
Arh
January 21, 2023, 1:50pm
19
Its really not going to work without knowing where the pins its connected to are, it doesn’t matter how much you struggle with platforms and indentations.
And then try putting a - in front of platform. See my post above.
@orange-assistant
I copied and pasted the lines from the cofigs given for the said sensors. Then I had to remove indentations and duplicate lines like sensor: and others according to any error message I got when validating the yaml file.