I’m not sure what exactly you are after. But I am happy to share my esphome file with graphs, even though maybe this isn’t what you were looking for. I use it to get data from the airgradient monitor into node-red, and then display it in domoticz. I’ll paste it below either way, maybe someone finds it useful.
This version has graphs with 12 hours of historic data shown on the OLED display. It uploads all data via mqtt, has a button to cycle the display pages, and turns off the display at night automatically. Feedback and improvements are most welcome.
Edit: Updated the yaml to my most recent version
# esphome on AirGradient Pro
# 05 March 2023, Argafål
#
# Features:
# - The front page summarizes the current values.
# - The second page is a blank/dark page in order to disable the display.
# - The last 12 hours of measurements are displayed in graphs alongside their current value.
# - The display switches off automatically at night.
# - The button (v3.7 of the AirGradient Pro board) flips through the
# different pages/graphs.
# - For configurations without a button there is a commented code block that
# shows how the display pages can be changed automatically every 5 seconds.
#
# Known issues:
# - None.
#
# Helpful hints and suggestions for improvement are most appreciated. Email:
# airgradient@argafal.de, or use the AirGradient forum.
esphome:
name: air-gradient
platform: ESP8266
board: d1_mini
libraries:
- uart=https://github.com/plerup/espsoftwareserial.git#6.17.1
project:
name: argafal.ESPHome-AirGradient
version: "1.0"
# Disable logging
logger:
baud_rate: 0
# Home Assistant API
#api:
# https://github.com/esphome/issues/issues/3187
external_components:
- source: github://pr#3384
components: [ json ]
# If you have problem flashing the device over wifi, look at ajfriesen's solution here:
# https://community.home-assistant.io/t/esphome-flashing-over-wifi-does-not-work/357352/1
ota:
password: !secret ota_password
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
uart:
- rx_pin: D5
tx_pin: D6
baud_rate: 9600
id: uart1
- rx_pin: D4
tx_pin: D3
baud_rate: 9600
id: uart2
font:
- file: "liberation_sans/LiberationSans-Regular.ttf"
id: opensans_14
size: 14
- file: "liberation_sans/LiberationSans-Regular.ttf"
id: opensans_22
size: 22
display:
- platform: ssd1306_i2c
id: oled
model: "SH1106 128x64"
contrast: 50%
pages:
- id: pageFront
lambda: |-
it.printf(0, 0, id(opensans_22), "%.1f°C %.0f%%", id(temp).state, id(humidity).state);
it.printf(0, 30, id(opensans_14), "CO2: %.0f ppm", id(co2).state);
it.printf(0, 47, id(opensans_14), "PM: %.0f %.0f %.0f ug/m3", id(pm10).state, id(pm25).state, id(pm100).state);
- id: pageDark
# Blank page for night time
lambda: |-
it.printf(0, 0, id(opensans_22), " ");
- id: page3
lambda: |-
it.graph(0, 0, id(single_temperature_graph));
it.printf(0, 47, id(opensans_14), "Temp: %.1f°C", id(temp).state);
- id: page4
lambda: |-
it.graph(0, 0, id(single_humidity_graph));
it.printf(0, 47, id(opensans_14), "Humidity: %.0f%%", id(humidity).state);
- id: page5
lambda: |-
it.graph(0, 0, id(single_co2_graph));
it.printf(0, 47, id(opensans_14), "CO2: %.0f ppm", id(co2).state);
- id: page6
lambda: |-
it.graph(0, 0, id(multi_pm_graph));
it.printf(0, 47, id(opensans_14), "PM: %.0f %.0f %.0f ug/m3", id(pm10).state, id(pm25).state, id(pm100).state);
# Automatically switch to the next page every five seconds. Disabled, we now have a button
#interval:
# - interval: 5s
# then:
# - display.page.show_next: oled
# - component.update: oled
# Button
binary_sensor:
- platform: gpio
pin: D7
name: "Button D7"
filters:
- delayed_on: 10ms
on_press:
- display.page.show_next: oled
- component.update: oled
sensor:
- platform: uptime
name: "Uptime Sensor"
id: uptime_raw
update_interval: 1s
- 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: uart1
update_interval: 30s
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"
# No hcho sensor in the air gradient package.
# formaldehyde:
# id: hcho
# name: "Formaldehyde (HCHO) concentration in µg per cubic meter"
- platform: senseair
uart_id: uart2
co2:
id: co2
name: "SenseAir CO2 Value"
update_interval: 60s
mqtt:
broker: 192.168.1.42
discovery: false
topic_prefix: air-gradient
# Not enough memory for graphs and web_server together on ESP8266 :(
#web_server:
graph:
- id: single_temperature_graph
duration: 12h
width: 128
height: 48
y_grid: 1.0
x_grid: 60min
sensor: temp
- id: single_humidity_graph
duration: 12h
width: 128
height: 48
y_grid: 10.0
x_grid: 60min
sensor: humidity
- id: single_co2_graph
duration: 12h
width: 128
height: 48
y_grid: 100.0
x_grid: 60min
sensor: co2
- id: multi_pm_graph
duration: 12h
width: 128
height: 48
y_grid: 10.0
x_grid: 60min
traces:
- sensor: pm25
- sensor: pm10
- sensor: pm100
# Turn display off at night and on again in the morning
time:
- platform: sntp
timezone: Europe/Amsterdam
id: esptime
on_time:
# Every evening
- seconds: 0
minutes: 30
hours: 23
days_of_week: MON-SUN
then:
- display.page.show: pageDark
# Every morning
- seconds: 0
minutes: 30
hours: 8
days_of_week: MON-SUN
then:
- display.page.show: pageFront