autohuttli/pumper.yaml

168 lines
4.6 KiB
YAML
Raw Permalink Normal View History

substitutions:
device_name: Pump monitor
device_id: pumper
project_name: juju.pumper
extra_version: ""
2025-08-30 14:26:18 +02:00
project_version: "0.8${extra_version}"
packages:
board: !include atoms3.yaml
base: !include base.yaml
pumper:
2025-02-18 20:39:35 +00:00
esphome:
on_boot:
- priority: 700
then:
- light.turn_on:
id: lcd_backlight
- display.page.show: boot_page
- component.update: lcd
- priority: 500
then:
- display.page.show: wifi_page
- component.update: lcd
2025-02-18 20:39:35 +00:00
- priority: -100
then:
- display.page.show: ready_page
- component.update: lcd
- delay: 1s
- display.page.show: level_page
- component.update: lcd
- script.execute: backlight_off
i2c:
2025-02-18 19:48:32 +00:00
- id: i2c_ext
sda: 2
scl: 1
scan: true
frequency: 400kHz
esp32_ble:
id: ble_core
esp32_ble_server:
manufacturer: "juju"
sensor:
- platform: ads1110
id: pressure_v
2025-02-18 19:48:32 +00:00
i2c_id: i2c_ext
name: "Raw sensor"
unit_of_measurement: V
device_class: voltage
update_interval: 3s
filters:
- multiply: 2.92 # (75 + 39) / 39
- sliding_window_moving_average:
send_every: 10
send_first_at: 5
on_value:
- sensor.template.publish:
id: head
state: !lambda 'return id(pressure_v).state;'
- platform: template
id: head
name: "Head"
unit_of_measurement: m
device_class: distance
icon: mdi:water
accuracy_decimals: 3
filters:
- calibrate_linear:
- 0.5 -> 0
- 4.5 -> 10.55 # 15 PSI
on_value:
- lambda: |-
std::vector<uint8_t> payload = {0xD2, 0xFC, 0x40};
payload.push_back(0x40); // Distance (mm)
int16_t value = id(head).state * 1000.0f;
if (value < 0) { value = 0; }
payload.push_back((value >> 0) & 0xFF);
payload.push_back((value >> 8) & 0xFF);
id(ble_core)->advertising_set_service_data(payload);
2025-02-18 19:48:32 +00:00
font:
- file: "gfonts://Noto+Sans"
2025-02-18 20:39:35 +00:00
id: roboto_70
size: 70
glyphsets:
- GF_Latin_Kernel
extras:
- file: "gfonts://Material+Symbols+Outlined"
glyphs:
- "\U0000e798" # mdi-water-drop
- file: "gfonts://Noto+Sans"
id: roboto_32
size: 32
2025-02-18 19:48:32 +00:00
glyphsets:
- GF_Latin_Kernel
glyphs:
- "ₘ³"
2025-02-18 20:39:35 +00:00
extras:
- file: "gfonts://Material+Symbols+Outlined"
glyphs:
- "\U0000e798" # mdi-water-drop
2025-02-18 19:48:32 +00:00
- file: "gfonts://Material+Symbols+Outlined"
id: icons_70
size: 70
glyphs:
- "\U0000e5c8" # mdi-arrow-forward
- "\U0000e5ca" # mdi-check
- "\U0000e798" # mdi-water-drop
- "\U0000e63e" # mdi-wifi
2025-02-18 19:48:32 +00:00
color:
- id: boot_background
hex: FF8F00
- id: wifi_background
hex: 6A1B9A # Purple 800
2025-02-18 19:48:32 +00:00
- id: ready_background
hex: 2E7D32
- id: water_background
hex: 1565C0
- id: text_colour
hex: FFFFFF
2025-02-18 20:39:35 +00:00
script:
- id: backlight_off
mode: restart
then:
- delay: 30s
- light.turn_off: lcd_backlight
2025-02-18 19:48:32 +00:00
display:
- id: lcd
platform: ili9xxx
dimensions:
height: 128
width: 128
offset_height: 1
offset_width: 2
model: st7789v
data_rate: 80MHz
cs_pin: 15
dc_pin: 33
reset_pin: 34
invert_colors: true
transform:
mirror_x: true
mirror_y: true
pages:
- id: boot_page
lambda: |-
it.fill(boot_background);
it.print(64, 64, id(icons_70), text_colour, TextAlign::CENTER, "\U0000e5c8");
- id: wifi_page
lambda: |-
it.fill(wifi_background);
it.print(64, 64, id(icons_70), text_colour, TextAlign::CENTER, "\U0000e63e");
2025-02-18 19:48:32 +00:00
- id: ready_page
lambda: |-
it.fill(ready_background);
it.print(64, 64, id(icons_70), text_colour, TextAlign::CENTER, "\U0000e5ca");
- id: level_page
lambda: |-
it.fill(water_background);
2025-02-18 20:39:35 +00:00
it.printf(64, 36, id(roboto_70), text_colour, TextAlign::CENTER, "%.1f", id(head).state);
it.print(64, 128-30, id(roboto_32), text_colour, TextAlign::CENTER, "\U0000e798m");