captive_portal:
external_components:
- source: my_components
uart:
tx_pin: GPIO1
rx_pin: GPIO3
baud_rate: 19200
id: utt2
sensor:
- platform: bl0906
update_interval: 10s
Frequency:
name: 'Frequency'
Temperature:
name: 'Temperature'
id: Temperature
Voltage:
name: 'Voltage'
id: Voltage
Current_1:
name: 'Current_1'
id: Current_1
Current_2:
name: 'Current_2'
Current_3:
name: 'Current_3'
Current_4:
name: 'Current_4'
Current_5:
name: 'Current_5'
Current_6:
name: 'Current_6'
Power_1:
name: 'Power_1'
id: Power_1
Power_2:
name: 'Power_2'
id: Power_2
Power_3:
name: 'Power_3'
id: Power_3
Power_4:
name: 'Power_4'
id: Power_4
Power_5:
name: 'Power_5'
id: Power_5
Power_6:
name: 'Power_6'
id: Power_6
Power_sum:
name: 'Power_sum'
id: Power_sum
Energy_1:
name: 'Energy_1'
id: Energy_1
Energy_2:
name: 'Energy_2'
id: Energy_2
Energy_3:
name: 'Energy_3'
id: Energy_3
Energy_4:
name: 'Energy_4'
id: Energy_4
Energy_5:
name: 'Energy_5'
id: Energy_5
Energy_6:
name: 'Energy_6'
id: Energy_6
Energy_sum:
name: 'Energy_sum'
id: Energy_sum
font:
- file: "swiss.ttf"
id: my_font
size: 12
- file: "swiss.ttf"
id: my_font8
size: 8
- file: "swiss.ttf"
id: my_font16
size: 16
spi:
clk_pin: GPIO14
mosi_pin: GPIO13
display:
- platform: st7735
model: "INITR_18BLACKTAB"
reset_pin: GPIO5
cs_pin: GPIO15
dc_pin: GPIO4
rotation: 0
device_width: 128
device_height: 160
col_start: 0
row_start: 0
eight_bit_color: true
update_interval: 1s
lambda: |-
auto red = Color(255, 0, 0);
auto green = Color(0, 255, 0);
auto blue = Color(0, 0, 255);
auto white = Color(255, 255, 255);
it.rectangle(0, 0, 128, 160,red); //画一个框
it.line(1, 40, 127, 40,red); //画一条线
it.line(1, 52, 127, 52,red); //画一条线
it.line(1, 70, 127, 70,red); //画一条线
it.line(1, 88, 127, 88,red); //画一条线
it.line(1, 106, 127, 106,red); //画一条线
it.line(1, 124, 127, 124,red); //画一条线
it.line(1, 142, 127, 142,red); //画一条线
it.line(11, 40, 11, 160,red); //画一条线
it.line(75, 40, 75, 160,red); //画一条线
it.print(30, 42, id(my_font8), "KW / h");
it.print(100, 42, id(my_font8), "W");
it.printf(36, 24, id(my_font), TextAlign::TOP_RIGHT, "%.1f", id(Voltage).state);
it.printf(75, 24, id(my_font), TextAlign::TOP_RIGHT, "%.1f", id(Temperature).state);
it.print(37, 24, id(my_font), "V");
it.print(75, 24, id(my_font), "C");
it.print(2, 2, id(my_font16), "E");
it.print(102, 4, id(my_font), "Kwh");
it.printf(100, 2, id(my_font16), TextAlign::TOP_RIGHT, "%7.1f", id(Energy_sum).state);
it.print(118, 28, id(my_font8), "W");
it.printf(117, 24, id(my_font), TextAlign::TOP_RIGHT, "%4.0f", id(Power_sum).state);
it.print(3, 55, id(my_font), "1");
it.print(3, 73, id(my_font), "2");
it.print(3, 91, id(my_font), "3");
it.print(3, 109, id(my_font), "4");
it.print(3, 127, id(my_font), "5");
it.print(3, 145, id(my_font), "6");
it.printf(74, 55, id(my_font), TextAlign::TOP_RIGHT, "%7.2f", id(Energy_1).state);
it.printf(74, 73, id(my_font), TextAlign::TOP_RIGHT, "%7.2f", id(Energy_2).state);
it.printf(74, 91, id(my_font), TextAlign::TOP_RIGHT, "%7.2f", id(Energy_3).state);
it.printf(74, 109, id(my_font), TextAlign::TOP_RIGHT, "%7.2f", id(Energy_4).state);
it.printf(74, 127, id(my_font), TextAlign::TOP_RIGHT, "%7.2f", id(Energy_5).state);
it.printf(74, 145, id(my_font), TextAlign::TOP_RIGHT, "%7.2f", id(Energy_6).state);
it.printf(126, 55, id(my_font), TextAlign::TOP_RIGHT, "%4.2f", id(Power_1).state);
it.printf(126, 73, id(my_font), TextAlign::TOP_RIGHT, "%4.2f", id(Power_2).state);
it.printf(126, 91, id(my_font), TextAlign::TOP_RIGHT, "%4.2f", id(Power_3).state);
it.printf(126, 109, id(my_font), TextAlign::TOP_RIGHT, "%4.2f", id(Power_4).state);
it.printf(126, 127, id(my_font), TextAlign::TOP_RIGHT, "%4.2f", id(Power_5).state);
it.printf(126, 145, id(my_font), TextAlign::TOP_RIGHT, "%4.2f", id(Power_6).state);