In the Process of Breaking My EspHome Yaml files into Packages to make them more Managable.
Not Sure How to Deal with this Example though,
Existing Code Block.
display:
- platform: ili9xxx
model: ILI9341
cs_pin: 22
dc_pin: 01 #TXD 0
reset_pin: 03 #RXD 0
dimensions:
height: 240
width: 320
transform:
swap_xy: True #L/Scape Pins on LHS
mirror_x: True
mirror_y: True
# swap_xy: True #L/Scape Pins on RHS
# mirror_x: False
# mirror_y: False
invert_colors: false
color_palette: 8BIT
color_order: bgr
id: tft_display
# update_interval: 10s # Added While Trying Lvgl
lambda: |-
it.fill(Color::BLACK);
// Get the hostname (derived from the 'name' in esphome: section)
// You can also get it from the API if needed, but for display purposes,
// the 'name' is often sufficient.
std::string hostname = App.get_friendly_name() + ".local";
// Print the hostname on the display
it.print(0, 0, id(robo_30), id(blue_1), TextAlign::TOP_LEFT, "Spa Monitor");
//it.printf(0, 50, id(robo_25), id(grn_1), TextAlign::TOP_LEFT , "Current Temp: %2.1f", id(spatmp_cur).state);
it.printf(0, 50, id(robo_25), id(grn_1), TextAlign::TOP_LEFT , "Current Temp:-");
it.printf(320, 50, id(robo_25), id(grn_1), TextAlign::TOP_RIGHT ," %2.1f", id(spatmp_cur).state);
//it.printf(0, 75, id(robo_25), id(org_1), TextAlign::TOP_LEFT , "Temp Rise: %2.1f", id(spatmp_rise).state);
it.printf(0, 75, id(robo_25), id(org_1), TextAlign::TOP_LEFT , "Temp Rise:");
it.printf(320, 75, id(robo_25), id(org_1), TextAlign::TOP_RIGHT , "%2.1f", id(spatmp_rise).state);
//it.printf(0, 100, id(robo_25), id(gry_1), TextAlign::TOP_LEFT , "Temp to Target: %2.1f", id(spatmp_req).state);
it.printf(0, 100, id(robo_25), id(gry_1), TextAlign::TOP_LEFT , "Temp to Target:");
it.printf(320, 100, id(robo_25), id(gry_1), TextAlign::TOP_RIGHT , "%2.1f", id(spatmp_req).state);
//it.printf(0, 125, id(robo_25), id(blue_1), TextAlign::TOP_LEFT , "Flow Rate: %2.1f", id(sparet_flo).state);
it.printf(0, 125, id(robo_25), id(blue_1), TextAlign::TOP_LEFT , "Flow Rate:");
it.printf(320, 125, id(robo_25), id(blue_1), TextAlign::TOP_RIGHT , "%2.1f", id(sparet_flo).state);
it.print(0, 160, id(robo_15), id(wht_1), hostname.c_str());
it.printf(0, 180, id(robo_15), id(yel_1),TextAlign::TOP_LEFT , "Ap: %s", id(testesp1_ap).state.c_str());
it.printf(0, 200, id(robo_15), id(blue_2), TextAlign::TOP_LEFT , "Ip: %s", id(testesp1_address).state.c_str());
it.printf(0, 220, id(robo_15), id(blue_1), TextAlign::TOP_LEFT , "Up: %s", id(testesp1_uptime_f).state.c_str());
// For example, displaying time
it.strftime(320, 220, id(robo_15), id(blue_1), TextAlign::TOP_RIGHT , "%H:%M:%S %d-%m-%Y ", id(snpt_time).now());
// Plain Text Example
//it.print(160, 220, id(robo_30), id(red_1), TextAlign::TOP_LEFT, "Hello World!");
//it.printf(0, 30, id(robo_30), id(blue_1), TextAlign::TOP_LEFT , "%.1f", id(testesp1_uptime_s).state);
I’ve Tried these two blocks as Package Files, but the Editor Reports them as in Error.
disp_conf.yaml
display:
- platform: ili9xxx
model: ILI9341
cs_pin: 22
dc_pin: 01 #TXD 0
reset_pin: 03 #RXD 0
dimensions:
height: 240
width: 320
transform:
swap_xy: True #L/Scape Pins on LHS
mirror_x: True
mirror_y: True
# swap_xy: True #L/Scape Pins on RHS
# mirror_x: False
# mirror_y: False
invert_colors: false
color_palette: 8BIT
color_order: bgr
id: tft_display
# update_interval: 10s # Added While Trying Lvgl
And
disp_lambda.yaml
lambda: |-
it.fill(Color::BLACK);
// Get the hostname (derived from the 'name' in esphome: section)
// You can also get it from the API if needed, but for display purposes,
// the 'name' is often sufficient.
std::string hostname = App.get_friendly_name() + ".local";
// Print the hostname on the display
it.print(0, 0, id(robo_30), id(blue_1), TextAlign::TOP_LEFT, "Spa Monitor");
//it.printf(0, 50, id(robo_25), id(grn_1), TextAlign::TOP_LEFT , "Current Temp: %2.1f", id(spatmp_cur).state);
it.printf(0, 50, id(robo_25), id(grn_1), TextAlign::TOP_LEFT , "Current Temp:-");
it.printf(320, 50, id(robo_25), id(grn_1), TextAlign::TOP_RIGHT ," %2.1f", id(spatmp_cur).state);
//it.printf(0, 75, id(robo_25), id(org_1), TextAlign::TOP_LEFT , "Temp Rise: %2.1f", id(spatmp_rise).state);
it.printf(0, 75, id(robo_25), id(org_1), TextAlign::TOP_LEFT , "Temp Rise:");
it.printf(320, 75, id(robo_25), id(org_1), TextAlign::TOP_RIGHT , "%2.1f", id(spatmp_rise).state);
//it.printf(0, 100, id(robo_25), id(gry_1), TextAlign::TOP_LEFT , "Temp to Target: %2.1f", id(spatmp_req).state);
it.printf(0, 100, id(robo_25), id(gry_1), TextAlign::TOP_LEFT , "Temp to Target:");
it.printf(320, 100, id(robo_25), id(gry_1), TextAlign::TOP_RIGHT , "%2.1f", id(spatmp_req).state);
//it.printf(0, 125, id(robo_25), id(blue_1), TextAlign::TOP_LEFT , "Flow Rate: %2.1f", id(sparet_flo).state);
it.printf(0, 125, id(robo_25), id(blue_1), TextAlign::TOP_LEFT , "Flow Rate:");
it.printf(320, 125, id(robo_25), id(blue_1), TextAlign::TOP_RIGHT , "%2.1f", id(sparet_flo).state);
it.print(0, 160, id(robo_15), id(wht_1), hostname.c_str());
it.printf(0, 180, id(robo_15), id(yel_1),TextAlign::TOP_LEFT , "Ap: %s", id(testesp1_ap).state.c_str());
it.printf(0, 200, id(robo_15), id(blue_2), TextAlign::TOP_LEFT , "Ip: %s", id(testesp1_address).state.c_str());
it.printf(0, 220, id(robo_15), id(blue_1), TextAlign::TOP_LEFT , "Up: %s", id(testesp1_uptime_f).state.c_str());
// For example, displaying time
it.strftime(320, 220, id(robo_15), id(blue_1), TextAlign::TOP_RIGHT , "%H:%M:%S %d-%m-%Y ", id(snpt_time).now());
// Plain Text Example
//it.print(160, 220, id(robo_30), id(red_1), TextAlign::TOP_LEFT, "Hello World!");
//it.printf(0, 30, id(robo_30), id(blue_1), TextAlign::TOP_LEFT , "%.1f", id(testesp1_uptime_s).state);
Then Use:-
esphome:
name: testesp-1
friendly_name: TestEsp-1
packages:
display: !include packages/disp_conf.yaml
color: !include packages/colors.yaml
font: !include fonts/fonts.yaml
disp_lambda: !include "packages/testesp-1/disp_lambda.yaml"
Seems Like the Indent required by the Lamba is causing the Issue.
How do I best Accheive this?