--- substitutions: name: m5stack-air-quality-kit friendly_name: m5air static_ip: 10.18.44.204 packages: board: !include boards/m5stack-core-esp32.yaml base: !include common/base.yaml # Define I/O: UART, I²C and SPI uart: rx_pin: 16 tx_pin: 17 baud_rate: 9600 i2c: sda: 21 scl: 22 scan: true frequency: 200kHz spi: clk_pin: 18 mosi_pin: 23 miso_pin: 19 # Particulate matter sensor and temperature sensor sensor: - platform: scd4x update_interval: 60s co2: name: "CO2" id: co2 temperature: name: "Temperature" id: temperature humidity: name: "Humidity" id: humidity - platform: pmsx003 type: PMSX003 update_interval: 120s pm_1_0: id: pm1 name: "Particulate Matter <1.0µm Concentration" device_class: pm1 state_class: measurement pm_2_5: id: pm25 name: "Particulate Matter <2.5µm Concentration" device_class: pm25 state_class: measurement pm_10_0: id: pm10 name: "Particulate Matter <10.0µm Concentration" device_class: pm10 state_class: measurement # Button to toggle the display backlight binary_sensor: - platform: gpio id: M5_BtnB pin: number: 38 inverted: true on_click: then: - light.toggle: back_light - platform: homeassistant id: redping entity_id: binary_sensor.151_252_14_26 - platform: homeassistant id: wired_wan entity_id: binary_sensor.wired_wan font: - file: "fonts/UbuntuMono-Regular.ttf" id: opensans_large size: 25 glyphs: '!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz/³µ' - file: "fonts/UbuntuMono-Regular.ttf" id: opensans size: 23 glyphs: '!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz/³µ' color: - id: RED red: 100% green: 0% blue: 0% - id: GREEN red: 0% green: 100% blue: 0% - id: BLUE red: 0% green: 0% blue: 100% - id: ORANGE red: 100% green: 50% blue: 0% - id: WHITE red: 100% green: 100% blue: 100% # GPIO pin of the display backlight output: - platform: ledc pin: 32 id: gpio_32_backlight_pwm light: - platform: monochromatic output: gpio_32_backlight_pwm name: "Display Backlight" id: back_light restore_mode: ALWAYS_ON display: - platform: ili9xxx id: m5stack_display model: M5Stack invert_colors: true update_interval: 10s cs_pin: 14 dc_pin: 27 reset_pin: 33 rotation: 0 lambda: |- it.rectangle(0, 0, it.get_width(), it.get_height(), BLUE); it.rectangle(0, 22, it.get_width(), it.get_height(), BLUE); // header bar it.print(it.get_width() / 2, 11, id(opensans), RED, TextAlign::CENTER, "Particulate matter"); it.print(11, 33, id(opensans), WHITE, TextAlign::LEFT, "PM1"); it.print(11, 55, id(opensans), WHITE, TextAlign::LEFT, "PM2.5"); it.print(11, 77, id(opensans), WHITE, TextAlign::LEFT, "PM10"); it.printf(it.get_width() - 11, 33, id(opensans), WHITE, TextAlign::RIGHT, "%.0f µg/m³", id(pm1).state); it.printf(it.get_width() - 11, 55, id(opensans), WHITE, TextAlign::RIGHT, "%.0f µg/m³", id(pm25).state); it.printf(it.get_width() - 11, 77, id(opensans), WHITE, TextAlign::RIGHT, "%.0f µg/m³", id(pm10).state); it.rectangle(0, 110, it.get_width(), 22, BLUE); // header bar it.print(it.get_width() / 2, 121, id(opensans), RED, TextAlign::CENTER, "Environment"); it.print(11, 143, id(opensans), WHITE, TextAlign::LEFT, "CO2"); it.print(11, 165, id(opensans), WHITE, TextAlign::LEFT, "Temperature"); it.print(11, 187, id(opensans), WHITE, TextAlign::LEFT, "Humidity"); it.print(11, 209, id(opensans), WHITE, TextAlign::LEFT, "Internet"); it.printf(it.get_width() - 77, 143, id(opensans), WHITE, TextAlign::RIGHT, "%.0f", id(co2).state); it.printf(it.get_width() - 77, 165, id(opensans), WHITE, TextAlign::RIGHT, "%.0f", id(temperature).state); it.printf(it.get_width() - 77, 187, id(opensans), WHITE, TextAlign::RIGHT, "%.0f", id(humidity).state); auto wantext = ""; if (id(redping).state && id(wired_wan).state) { it.printf(it.get_width() - 77, 209, id(opensans), GREEN, TextAlign::RIGHT, "OK"); it.filled_rectangle(it.get_width() - 11 - 15, 215, 15, 15, GREEN); } else if (id(redping).state && id(wired_wan).state) { it.printf(it.get_width() - 77, 209, id(opensans), ORANGE, TextAlign::RIGHT, "5G"); it.filled_rectangle(it.get_width() - 11 - 15, 215, 15, 15, ORANGE); } else { it.printf(it.get_width() - 77, 209, id(opensans), RED, TextAlign::RIGHT, "NOT OK"); it.filled_rectangle(it.get_width() - 11 - 15, 215, 15, 15, RED); } it.printf(it.get_width() - 11, 143, id(opensans), WHITE, TextAlign::RIGHT, "ppm"); it.printf(it.get_width() - 11, 165, id(opensans), WHITE, TextAlign::RIGHT, "°C"); it.printf(it.get_width() - 11, 187, id(opensans), WHITE, TextAlign::RIGHT, "%%");