Compare commits

...

1 Commits

Author SHA1 Message Date
Stefan Heinrichsen 2a231b27c0 switched from neopixelbus to fastled; harmonized indentation in whole file 2020-11-07 20:54:59 +01:00
1 changed files with 130 additions and 129 deletions

View File

@ -1,150 +1,151 @@
substitutions: substitutions:
node_name: !env_var co2ampel node_name: !env_var co2ampel
esphome: esphome:
name: co2ampel_${node_name} name: 'co2ampel_${node_name}'
platform: ESP32 platform: ESP32
board: esp32doit-devkit-v1 board: esp32doit-devkit-v1
on_boot: on_boot:
- display.page.show: boot - display.page.show: boot
on_loop:
- display.page.show: co2
ota: ota:
safe_mode: True safe_mode: true
password: !secret ota_passwd password: !secret ota_passwd
logger:
level: DEBUG
wifi: wifi:
ssid: !secret wifi_ssid ssid: !secret wifi_ssid
password: !secret wifi_passwd password: !secret wifi_passwd
ap: ap:
ssid: "co2ampel" ssid: co2ampel
password: "" password: ''
captive_portal:
captive_portal: null
mqtt: mqtt:
broker: co2.cyber23.de broker: co2.cyber23.de
topic_prefix: co2ampel/${node_name} topic_prefix: 'co2ampel/${node_name}'
birth_message: birth_message:
topic: co2ampel/${node_name}/status topic: 'co2ampel/${node_name}/status'
payload: online payload: online
will_message: will_message:
topic: co2ampel/${node_name}/status topic: 'co2ampel/${node_name}/status'
payload: offline payload: offline
uart: uart:
rx_pin: GPIO16 rx_pin: GPIO16
tx_pin: GPIO17 tx_pin: GPIO17
baud_rate: 9600 baud_rate: 9600
id: uart_mhz19 id: uart_mhz19
light: light:
- platform: neopixelbus - platform: fastled_clockless
pin: GPIO4 chipset: WS2812B
num_leds: 12 pin: GPIO4
name: "ws2812 ring" num_leds: 12
id: "ws2812" max_refresh_rate: 500ms
restore_mode: ALWAYS_OFF rgb_order: GRB
name: ws2812 ring
id: ws2812
restore_mode: ALWAYS_OFF
output: output:
- platform: ledc - platform: ledc
pin: GPIO12 pin: GPIO12
id: buzzer id: buzzer
sensor: sensor:
- platform: mhz19 - platform: mhz19
update_interval: 10s update_interval: 10s
automatic_baseline_calibration: true automatic_baseline_calibration: true
uart_id: uart_mhz19 uart_id: uart_mhz19
temperature: temperature:
name: ${node_name} Temperature name: '${node_name} Temperature'
id: mhz19_temp id: mhz19_temp
co2: co2:
name: ${node_name} PPM name: '${node_name} PPM'
id: mhz19_co2 id: mhz19_co2
on_value: on_value:
then: then:
if: if:
condition: condition:
sensor.in_range: sensor.in_range:
id: mhz19_co2 id: mhz19_co2
above: 0 above: 0
below: 800 below: 800
then: then:
- light.turn_off: - light.turn_on:
id: ws2812 id: ws2812
- display.page.show: co2 brightness: 80%
else: red: 0%
if: green: 100%
condition: blue: 0%
sensor.in_range: - display.page.show: co2
id: mhz19_co2 else:
above: 800 if:
below: 1000 condition:
then: sensor.in_range:
- light.turn_on: id: mhz19_co2
id: ws2812 above: 800
brightness: 80% below: 1000
red: 50% then:
green: 50% - light.turn_on:
blue: 0% id: ws2812
- display.page.show: co2 brightness: 80%
else: red: 50%
if: green: 40%
condition: blue: 0%
sensor.in_range: - display.page.show: co2
id: mhz19_co2 else:
above: 1000 if:
then: condition:
- light.turn_on: sensor.in_range:
id: ws2812 id: mhz19_co2
brightness: 100% above: 1000
red: 100% then:
green: 0% - light.turn_on:
blue: 0% id: ws2812
# - output.turn_on: buzzer brightness: 100%
# - output.ledc.set_frequency: red: 100%
# id: buzzer green: 0%
# frequency: "5000Hz" blue: 0%
# - output.set_level: - delay: 500ms
# id: buzzer - light.toggle: ws2812
# level: "20%" - delay: 500ms
# - delay: 10ms - light.toggle: ws2812
# - output.turn_off: buzzer - delay: 500ms
- delay: 500ms - light.toggle: ws2812
- light.toggle: ws2812 - delay: 500ms
- delay: 500ms - light.toggle: ws2812
- light.toggle: ws2812 - lambda: >-
- delay: 500ms static int num_executions = 0;
- light.toggle: ws2812 ESP_LOGD("main", "I am at execution number %d", num_executions);
- delay: 500ms num_executions += 1;
- light.toggle: ws2812 - display.page.show: co2
- lambda: |-
static int num_executions = 0;
ESP_LOGD("main", "I am at execution number %d", num_executions);
num_executions += 1;
- display.page.show: co2
i2c: i2c:
sda: GPIO21 sda: GPIO21
scl: GPIO22 scl: GPIO22
font: font:
- file: "font.ttf" - file: font.ttf
id: cust_font id: cust_font
size: 70 size: 65
display: display:
- platform: ssd1306_i2c - platform: ssd1306_i2c
model: "SSD1306 128x64" model: SSD1306 128x64
address: 0x3C address: 60
brightness: 100% brightness: 100%
update_interval: 10s update_interval: 10s
pages: pages:
- id: boot - id: boot
lambda: |- lambda: |-
it.printf(64, 0, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER, ":-)"); it.printf(64, 0, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER,":-)");
- id: co2 - id: co2
lambda: |- lambda: |-
int ergb; int ergb;
ergb = id(mhz19_co2).state/100; ergb = id(mhz19_co2).state;
it.printf(64, 0, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER, "%.0i", ergb); it.printf(64, 0, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER, "%.0i", ergb);
# it.printf(64, 16, id(cust_font), COLOR_ON, TextAlign::TOP_CENTER, "%.0fPPM", id(mhz19_co2).state); # it.printf(64, 16, id(cust_font), COLOR_ON,TextAlign::TOP_CENTER, "%.0fPPM", id(mhz19_co2).state);
# it.printf(64, 40, id(cust_font),TextAlign::TOP_CENTER, "%.0f°C", id(mhz19_temp).state); # it.printf(64, 40, id(cust_font),TextAlign::TOP_CENTER,"%.0f°C", id(mhz19_temp).state);