Browse Source

split configuration

esphome
Hendrik Langer 3 years ago
parent
commit
669bd761da
  1. 83
      common/base.yaml
  2. 8
      common/bh1750.yaml
  3. 8
      common/ble.yaml
  4. 14
      common/bme280.yaml
  5. 31
      common/bme680.yaml
  6. 135
      common/display.yaml
  7. 15
      common/sds011.yaml
  8. 4
      common/secrets.yaml
  9. 0
      custom/veml6075_custom_sensor.h
  10. 34
      custom/weather_icon_map.h
  11. BIN
      fonts/materialdesignicons-webfont.ttf
  12. 1
      secrets.yaml
  13. 12
      test.yaml

83
common/base.yaml

@ -0,0 +1,83 @@
esphome:
name: ${node_name}
platform: ESP32
board: lolin_d32_pro
project:
name: "xd0.esp32weatherstation2"
version: "0.0.4"
includes:
- custom/weather_icon_map.h
# Enable logging
logger:
# level: VERY_VERBOSE
# Enable Home Assistant API
api:
ota:
password: !secret esphome_ota_password
wifi:
networks:
- ssid: !secret wifi_ssid
password: !secret wifi_passwd
- ssid: !secret wifi_ssid2
password: !secret wifi_passwd2
power_save_mode: light
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: ${node_name}
password: !secret wifi_captive_portal_password
captive_portal:
time:
- platform: sntp
id: sntp_time
timezone: "Europe/Berlin"
mqtt:
broker: home.xd0.de
username: !secret esphome_mqtt_user
password: !secret esphome_mqtt_passwd
discovery: false
discovery_retain: false
topic_prefix: "thomas"
log_topic:
topic: log"thomas/${node_name}/debug"
level: INFO
# bus
i2c:
sda: 21
scl: 22
scan: true
spi:
clk_pin: 18
mosi_pin: 23
miso_pin: 19
status_led:
pin:
number: GPIO5
inverted: true
sensor:
# Battery level
- platform: adc
pin: _VBAT
name: "${node_name} VBAT Voltage"
attenuation: 11db
# filters:
# - lambda: return ( x/4096.0 ) * 2 * 3.42;
update_interval: 60s
# WiFi signal strength
- platform: wifi_signal
name: "${node_name} RSSI"
update_interval: 60s
# Example hall sensor
# - platform: esp32_hall
# name: "${node_name} ESP32 Hall Sensor"
# update_interval: 60s

8
common/bh1750.yaml

@ -0,0 +1,8 @@
# BH1750 Ambient Light Sensor
sensor:
- platform: bh1750
name: "${node_name} Illuminance"
id: lux
address: 0x23
measurement_duration: 69
update_interval: 60s

8
common/ble.yaml

@ -0,0 +1,8 @@
# Bluetooth Low-Energy
# Example configuration entry
esp32_ble_tracker:
sensor:
- platform: ble_rssi
mac_address: FA:4E:84:FF:4D:16
name: "${node_name} MiBand Hendrik RSSI value"

14
common/bme280.yaml

@ -0,0 +1,14 @@
# BME280 Temperature+Pressure+Humidity Sensor
sensor:
- platform: bme280
temperature:
name: "${node_name} Temperature"
id: temperature
pressure:
name: "${node_name} Pressure"
id: pressure
humidity:
name: "${node_name} Humidity"
id: humidity
address: 0x77
update_interval: 60s

31
common/bme680.yaml

@ -0,0 +1,31 @@
# BME680 Temperature+Pressure+Humidity+Gas Sensor
sensor:
- platform: bme680_bsec
temperature:
name: "${node_name} Temperature"
id: temperature
pressure:
name: "${node_name} Pressure"
id: pressure
humidity:
name: "${node_name} Humidity"
id: humidity
gas_resistance:
name: "${node_name} Gas Resistance"
iaq:
name: "${node_name} IAQ"
iaq_accuracy:
name: "${node_name} Numeric IAQ Accuracy"
co2_equivalent:
name: "${node_name} CO2 Equivalent"
breath_voc_equivalent:
name: "${node_name} Breath VOC Equivalent"
update_interval: 60s
text_sensor:
- platform: bme680_bsec
iaq_accuracy:
name: "${node_name} IAQ Accuracy"
bme680_bsec:
address: 0x77

135
common/display.yaml

@ -0,0 +1,135 @@
# display #250x122 pixels (250x128)
font:
- file: 'fonts/Vera.ttf'
id: font1
size: 10
- file: 'fonts/Vera.ttf'
id: font2
size: 20
# - file: 'fonts/VeraMono.ttf'
# id: font3
# size: 10
- file: 'fonts/materialdesignicons-webfont.ttf'
id: icon_font
size: 48
glyphs:
- "\U000F0590" # weather-cloudy
- "\U000F0F2F" # weather-cloudy-alert
- "\U000F0E6E" # weather-cloudy-arrow-right
- "\U000F0591" # weather-fog
- "\U000F0592" # weather-hail
- "\U000F0F30" # weather-hazy
- "\U000F0898" # weather-hurricane
- "\U000F0593" # weather-lightning
- "\U000F067E" # weather-lightning-rainy
- "\U000F0594" # weather-night
- "\U000F0F31" # weather-night-partly-cloudy
- "\U000F0595" # weather-partly-cloudy
- "\U000F0F32" # weather-partly-lightning
- "\U000F0F33" # weather-partly-rainy
- "\U000F0F34" # weather-partly-snowy
- "\U000F0F35" # weather-partly-snowy-rainy
- "\U000F0596" # weather-pouring
- "\U000F0597" # weather-rainy
- "\U000F0598" # weather-snowy
- "\U000F0F36" # weather-snowy-heavy
- "\U000F067F" # weather-snowy-rainy
- "\U000F0599" # weather-sunny
- "\U000F0F37" # weather-sunny-alert
- "\U000F14E4" # weather-sunny-off
- "\U000F059A" # weather-sunset
- "\U000F059B" # weather-sunset-down
- "\U000F059C" # weather-sunset-up
- "\U000F0F38" # weather-tornado
- "\U000F059D" # weather-windy
- "\U000F059E" # weather-windy-variant
display:
- platform: waveshare_epaper
cs_pin: 14
dc_pin: 27
reset_pin: 33
model: 2.13in-ttgo
rotation: 90
update_interval: 60s
full_update_every: 1
id: my_display
pages:
- id: page1
lambda: |-
it.print(10, 50, id(font2), "esp32weatherstation2");
- id: page2
lambda: |-
it.print(5, 6, id(font1), "${node_name}");
it.strftime(150, 6, id(font1), "%Y-%m-%d %H:%M", id(sntp_time).now());
it.line(0, 20, 250, 20);
it.filled_rectangle(0, 20, 70, 122, COLOR_ON);
it.line(0, 56, 70, 56, COLOR_OFF);
it.line(0, 92, 70, 92, COLOR_OFF);
if (id(temperature).state) {
it.printf(2, 21+4, id(font2), COLOR_OFF, "%.1f", id(temperature).state); it.printf(55, 21+4, id(font1), COLOR_OFF, "°C");
it.printf(2, 57+4, id(font2), COLOR_OFF, "%.1f", id(humidity).state); it.printf(55, 57+4, id(font1), COLOR_OFF, "%%");
it.printf(2, 93+4, id(font2), COLOR_OFF, "%.0f", id(pressure).state); it.printf(55, 93+4, id(font1), COLOR_OFF, "hPa");
it.graph(70, 21, id(temperature_graph));
it.graph(70, 57, id(humidity_graph));
it.graph(70, 93, id(pressure_graph));
}
if (id(weather_icon).has_state()) {
it.printf(133, 51, id(icon_font), weather_icon_map[id(weather_icon).state.c_str()].c_str());
}
it.printf(133, 21, id(font1), "Temp Out: %.1f°C", id(temperature_outside).state);
it.printf(133, 31, id(font1), "VOC : %.1f k\xe9", id(voc).state);
# it.printf(133, 21, id(font1), "PM2.5: %.1f", id(pm2).state);
# it.printf(133, 31, id(font1), "PM10 : %.1f", id(pm10).state);
# it.printf(133, 51, id(font1), "Lux : %.1f lx", id(lux).state);
# it.printf(133, 61, id(font1), "UVI : %.1f", id(uva).state);
# it.printf(133, 71, id(font1), "UVA : %.1f", id(uva).state);
# it.printf(133, 81, id(font1), "UVB : %.1f", id(uvb).state);
interval:
- interval: 30s
then:
- if:
condition:
- display.is_displaying_page: page1
then:
- display.page.show: page2
- component.update: my_display
graph:
# Show bare-minimum auto-ranged graph
- id: temperature_graph
duration: 1h
width: 60
height: 35
traces:
- sensor: temperature
line_type: SOLID
line_thickness: 2
- sensor: temperature_outside
line_type: DASHED
line_thickness: 1
- id: humidity_graph
sensor: humidity
duration: 1h
width: 60
height: 35
- id: pressure_graph
sensor: pressure
duration: 1h
width: 60
height: 35
# Example configuration entry
sensor:
- platform: homeassistant
name: "Temperature OpenWeatherMap"
internal: true
entity_id: sensor.openweathermap_temperature
id: temperature_outside
text_sensor:
- platform: homeassistant
id: weather_icon
internal: true
entity_id: weather.openweathermap

15
common/sds011.yaml

@ -0,0 +1,15 @@
uart:
rx_pin: 15
tx_pin: 2
baud_rate: 9600
# SDS 011 Particulate Matter Sensor
sensor:
- platform: sds011
pm_2_5:
name: "${node_name} Particulate Matter <2.5µm Concentration"
id: pm2
pm_10_0:
name: "${node_name} Particulate Matter <10.0µm Concentration"
id: pm10
update_interval: 5min

4
common/secrets.yaml

@ -0,0 +1,4 @@
<<: !include ../secrets.yaml
# You can also use Home Assistant secrets.yaml:
# <<: !include ../../secrets.yaml

0
veml6075_custom_sensor.h → custom/veml6075_custom_sensor.h

34
custom/weather_icon_map.h

@ -0,0 +1,34 @@
#include <map>
std::map<std::string, std::string> weather_icon_map
{
{"cloudy", "\U000F0590"},
{"cloudy-alert", "\U000F0F2F"},
{"cloudy-arrow-right", "\U000F0E6E"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"hazy", "\U000F0F30"},
{"hurricane", "\U000F0898"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"night", "\U000F0594"},
{"night-partly-cloudy", "\U000F0F31"},
{"partly-cloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
{"sunny-off", "\U000F14E4"},
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};

BIN
fonts/materialdesignicons-webfont.ttf

Binary file not shown.

1
secrets.yaml

@ -5,5 +5,6 @@ wifi_passwd: password1
wifi_ssid2: ssid2
wifi_passwd2: password2
esphome_ota_password: "1234567890abcdef1234567890abcdef"
wifi_captive_portal_password: "123456789abc"
esphome_mqtt_user: "mqtt-user"
esphome_mqtt_passwd: "mqtt-password"

12
test.yaml

@ -0,0 +1,12 @@
substitutions:
node_name: thomas-test
packages:
base: !include common/base.yaml
env_sensor: !include common/bme680.yaml
display: !include common/display.yaml
# remote_package:
# url: https://dev.xd0.de/hendrik/esp32-weatherstation
# ref: esphome
# files: [common/base.yaml, common/bme680.yaml]
# refresh: 1d
Loading…
Cancel
Save