My configuration scripts for esp and similar devices within my home network, including multiple sensors, switches.
This repository contains YAML scripts for configuration of ESP devices (includes esp8266, esp32, bk7231n).
For inventory of components and particular configurations see Inventory.md.
Author: Pawel Golawski, pawel.golawski@2com.pl
- This is modular repository, which means that sensors, manipulators, ... are embedded into particular device script via
!include <file>statements. Usually those are single line includes. - Those includes may define or override variables, which make particular configuration. For example for
i2c.yamlvariables given define GPIO pins (SDA, SCL) which are serve as I2C interface. - Always available components:
- Wifi
- OTA (Over The Air) updates
- MQTT publish sensor values, like
esp-xx/temperature - Additional MQTT topic for sensors with friendly structure, like
home/office/temperature - Logger via MQTT
- Prometheus, exposing
/metricsweb interface endpoint - HomeAssistant API
- Web server
- Time (via SNTP)
- Logger with
I(INFO) level via API, web, MQTT - No USB logs output by default (as most devices are not connected to any USB)
- Optional components:
- Sun (to provide elevation, azimuth and sunrise sunset times)
- RTTTL - to play RTTTL melody via passive buzzer; melody can be received via MQTT (
esp-xx/play_rtttltopic) - Logger LEVEL + USB output
- Other WiFi networks credentials
- API services
Script filenames reflect what sensors, switches and manipulators are included in particular one. The naming convention is board_MMmm_SSss__PP.yaml, where:
boardis the type of ESP board/device, likeesp12foresp32c3, ...MMare the MEASURES provided, like temperature, humidity, ...mmare the manipulators used, like diode, rtttl, ...SSare the SENSORS used, like SHT30, BH1750, ...ssare the switches used, like buzzer, AVT5713 board, ...PPis PURPOSE of the device, like fan or gate;
Info: Scripts which ends
_devdo contain many sensors/includes - if you need any other configuration you can see there how to build it with!include <file>statements.
For example: esp12f_THIddb_STr.yaml script is for:
- board:
esp12f- ESP12-F board
- measures:
T- TemperatureH- HumidityI- Illuminance
- manipulators:
d- dioded- diode (2nd one)b- buzzer
- sensors:
S- SHT30 - temperature and humidityT- TCS3472 - illuminance and temperature color
- switches:
r- RTTTL
All available measures
T- TemperatureH- HumidityP- PressureG- Gas ResistanceI- IlluminanceU- UVC- CO2 (Carbon Dioxide)E- eCO2 (Equivalent Carbon Dioxide)D- DistanceO- TVOC (Total Volatile Organic Compounds)W- Water MeterP- Presence (human)R- Current (DC)V- Voltage (DC)W- Power (DC)M- MotionA- GesturesB- RGB Color
All available manipulators
1r- Single Switch/Relay2l- Double Light Switchb- Buzzerd- Diodei- IR Transmitters- Switch
All available sensors
A- APDS9660 - Illuminance, Color(s), Gesture and MotionB- BH1750 - IlluminanceC- SCD40 - CO2, Temperature, HumidityD- DS18B20 (Dallas) - TemperatureE- INA226 - DC Current, Power, VoltageF- INA3221 - 3-channel DC Current, Power, VoltageG- BME680 - Temperature, Humidity, Pressure, Gas ResistanceH- AHTx21 - Temperature and HuźmidityI- (generic) IR ReceiverL- LD2410 - Radar sensor 24GHzM- INMP441 - I2S microphoneN- ENS160 - TVOC and eCO2O- SGP30 - TVOC and eCO2P- BME280 - Temperature, Humidity, PressureS- SHTx30 - Temperature and HumidityT- TCS3472 - Illuminance and Color(s)U- LTR390 - UV and IlluminanceV- VL53L0x - Distance (laser)W- HC-SR04 - Distance (acoustic)Y- YF-B10 G1 - Water Pulse sensor
All available switches boards
a- AVT5713 - Double Light Switch Boardx- Single Relay Board (generic from Aliexpress)b- 9032A/9025A - Active Buzzer 9mm diameter x 3.2/2.5mm heightr- 9032/9025 - Passive Buzzer 9mm diameter x 3.2/2.5mm heighti- IR Transmitter (Open-Smart)m- Max98357 - I2S mono amplifier
All available purposes. Those are changing the names of the manipulators to reflect their particular purpose.
F- FanG- Gate
You need to have
python3installed, in minimum version3.10esphomecommand installed, in minimum version2023.02.
Short instruction:
- To install please use following:
pip3 install esphome - To install upgrade use following:
pip3 install -U esphome
To see full installation procedure please follow esp_setup.sh file and run specific commands. DO NOT RUN this script at once. The file includes:
- MQTT configuration, especially ACL
- Prometheus configuration
- Example Grafana dashboard to display data from Prometheus is in
Home Sensors-Grafana4Prometheus_dashboard.jsonfile
- Example Grafana dashboard to display data from Prometheus is in
esphomecommands to flash specific configurations
Before running it please:
- Copy
secrets_example.yamlscript intosecrets.yamland modify values for secret variables, like WiFi password - Review the script actions. See
0_DEV/esp12_dev.yamlas example as it contains almost all available configurations with!include <file>files parameters. For full list of include file parameters please see inside specific include file.
esphome -s devicename esp12f_office -s updates 30s -s room Office -s mqtt_room office run 0_PROD/esp12f-10_Office.yaml
To trigger only OTA update for particular IP please add --device 192.168.x.x at the end of above command.
The parameters are following -s argument. Those are:
devicename- the name of the device,esp-xxis defaultupdates- how frequently sensors are updated,30sis defaultroom- friendly name of the room,Roomis defaultmqtt_location- name of the location for MQTT,homeis defaultmqtt_room- name of the room for MQTT,roomis default
Some scripts which have sensors or manipulators in 2 areas have the parameters for 2nd area passed as:
room2- friendly name of the room,noneis defaultmqtt_location2- name of the location for MQTT,noneis defaultmqtt_room2- name of the room for MQTT,noneis default
Those are primary folders to look for full device configurations.
0_DEV- folder contain development scripts (esp*.yaml) which are working but there is no physical device using them1_UAT- folder contain scripts for devices not yet deployed on production2_PROD- folder contain scripts for devices which are deployed on production
Remaining folder contain partial YAML configurations for single elements or sets which are used by above Device script folders.
buttons- list of buttons intended to include them underbutton:section;- folder contains also
set_of_...files which contain multiple buttons (like for IR remote controls), but those should be included inpackages:section
- folder contains also
deprecated- contain all old versions (not modular usually)examples- example configurations, how to use set of scriptsfans- list of switches intended to include them underfan:sectionfonts- list of fonts to draw on displays intended to include them underfont:sectioni2s- scripts for i2s sound devices (mic, speaker, ...)includes- basic scripts for ESP boards, wifi, mqtt, ota, ...board_...scripts may contain wiring instructions - please READ those
interfaces- list of separate interfaces to include likei2c,uart,dallaslights- list of switches intended to include them underlight:sectionoutputs- list of outputs intended to include them underoutput:sectionpinouts- images of pinouts, boards, displays referenced by Inventory.mdsensors- list of sensors intended to include them under:binary_senor:section, those with filenames starting asbinary_text_senor:section, those with filenames starting astext_sensor:section, all remaining files
switches- list of switches intended to include them underswitch:section