esphome-configs/cash.yaml
2025-07-06 15:10:08 +02:00

84 lines
2 KiB
YAML

# Hardware: https://docs.thingpulse.com/guides/espaper-plus-kit/
#
# Programming via serial requires a serial converter. To program, the device has to be put in a
# programming mode. This is done by pressing the RESET (the rightmost) button while holding the
# middle button. But after setting up esphome and the WiFi credentials you can just keep flashing
# via OTA. After flashing via any method, you must do a manual reset.
# Epaper display that displays the amount of cash tracked by RevBank.
esphome:
name: espaper
friendly_name: Cash
esp8266:
board: nodemcu
logger:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ota:
platform: esphome
password: !secret ota_password
mqtt:
broker: !secret mqtt_server
sensor:
- platform: wifi_signal
name: "WiFi Signal dB"
update_interval: 10s
state_topic: bitlair/esphome/spacestate-bitlair/wifi_signal
retain: false
- platform: mqtt_subscribe
id: cash
topic: bitlair/bank/cash
on_value:
then:
- component.update: epaper
text_sensor:
- platform: version
name: "ESPHome Version"
hide_timestamp: true
state_topic: bitlair/esphome/cash/version
font:
- file: "gfonts://Roboto"
id: font_label
size: 32
- file: "gfonts://Roboto"
id: font_cash
size: 56
spi:
clk_pin: 14
mosi_pin: 13
display:
- platform: waveshare_epaper
id: epaper
model: 2.90in
cs_pin: 15
dc_pin: 5
busy_pin: 4
reset_pin: 2
update_interval: 60s
rotation: 270
lambda: |-
char label[32];
snprintf(label, sizeof(label), "geld in kas");
int label_w, label_h, _;
const int label_y = 10;
id(font_label).measure(label, &label_w, &_, &_, &label_h);
it.printf(it.get_width()/2 - label_w/2, label_y, id(font_label), "%s", label);
char cash_str[16];
snprintf(cash_str, sizeof(cash_str), "€ %.02f", id(cash).state);
int cash_w;
id(font_cash).measure(cash_str, &cash_w, &_, &_, &_);
it.printf(it.get_width()/2 - cash_w/2, label_y+label_h+2, id(font_cash), "%s", cash_str);