168 lines
4.6 KiB
YAML
168 lines
4.6 KiB
YAML
substitutions:
|
|
device_name: Pump monitor
|
|
device_id: pumper
|
|
project_name: juju.pumper
|
|
extra_version: ""
|
|
project_version: "0.8${extra_version}"
|
|
|
|
packages:
|
|
board: !include atoms3.yaml
|
|
base: !include base.yaml
|
|
pumper:
|
|
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
|
|
- 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:
|
|
- 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
|
|
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);
|
|
|
|
font:
|
|
- file: "gfonts://Noto+Sans"
|
|
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
|
|
glyphsets:
|
|
- GF_Latin_Kernel
|
|
glyphs:
|
|
- "ₘ³"
|
|
extras:
|
|
- file: "gfonts://Material+Symbols+Outlined"
|
|
glyphs:
|
|
- "\U0000e798" # mdi-water-drop
|
|
- 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
|
|
|
|
color:
|
|
- id: boot_background
|
|
hex: FF8F00
|
|
- id: wifi_background
|
|
hex: 6A1B9A # Purple 800
|
|
- id: ready_background
|
|
hex: 2E7D32
|
|
- id: water_background
|
|
hex: 1565C0
|
|
- id: text_colour
|
|
hex: FFFFFF
|
|
|
|
script:
|
|
- id: backlight_off
|
|
mode: restart
|
|
then:
|
|
- delay: 30s
|
|
- light.turn_off: lcd_backlight
|
|
|
|
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");
|
|
- 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);
|
|
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");
|