esphome: name: air-gradient project: name: ajfriesen.ESPHome-AirGradient version: "1.0" esp8266: board: d1_mini_pro # Enable logging logger: # Enable Home Assistant API api: ota: platform: esphome password: !secret ota_password # Create a switch for safe_mode in order to flash the device # Solution from this thread: # https://community.home-assistant.io/t/esphome-flashing-over-wifi-does-not-work/357352/1 switch: - platform: safe_mode name: "Flash Mode (Safe Mode)" id: safe_mode_switch button: - platform: template name: "Flash mode" id: flash_button icon: "mdi:cellphone-arrow-down" on_press: then: - switch.toggle: safe_mode_switch dashboard_import: # package_import_url: github://esphome/esphome-project-template/project-template-esp32.yaml@v6 package_import_url: github://ajfriesen/ESPHome-AirGradient/main/air-gradient.yaml wifi: networks: - ssid: !secret wifi_ssid password: !secret wifi_password reboot_timeout: 15min # Enable fallback hotspot (captive portal) in case wifi connection fails ap: ssid: "Air-Gradient Fallback Hotspot" password: !secret fallback_ssid_password captive_portal: i2c: sda: D2 scl: D1 font: - file: "font/monofont.ttf" id: opensans size: 10 display: - platform: ssd1306_i2c id: oled model: "SSD1306 64x48" pages: - id: page1 lambda: |- it.printf(0, 0, id(opensans), "CO2: %.0fppm", id(co2).state); it.printf(0, 10, id(opensans), "PM25: %.0f", id(pm25).state); it.printf(0, 20, id(opensans), "Hmdty: %.0f", id(humidity).state); it.printf(0, 30, id(opensans), "Temp: %.0fC", id(temp).state); # - id: page2 # lambda: |- # it.printf(0, 0, id(opensans), "PM10 : %.0f", id(pm10).state); # it.printf(0, 10, id(opensans), "PM25 : %.0f", id(pm25).state); # it.printf(0, 20, id(opensans), "PM100: %.0f", id(pm100).state); # Maybe add a page later interval: - interval: 5s then: - display.page.show_next: oled - component.update: oled uart: - rx_pin: D5 tx_pin: D6 baud_rate: 9600 id: uart_1 - rx_pin: D4 tx_pin: D3 baud_rate: 9600 id: uart_2 sensor: - platform: sht3xd temperature: id: temp name: "Temperature" humidity: id: humidity name: "Humidity" address: 0x44 update_interval: 5s - platform: pmsx003 # type can be PMSX003, PMS5003S, PMS5003T, PMS5003ST # https://esphome.io/components/sensor/pmsx003.html type: PMSX003 uart_id: uart_1 # pm_1_0: # id: pm10 # name: "Particulate Matter <1.0µm Concentration" pm_2_5: id: pm25 name: "Particulate Matter <2.5µm Concentration" # pm_10_0: # id: pm100 # name: "Particulate Matter <10.0µm Concentration" # formaldehyde: # id: hcho # name: "Formaldehyde (HCHO) concentration in µg per cubic meter" - platform: senseair uart_id: uart_2 co2: id: co2 name: "SenseAir CO2 Value" update_interval: 60s