346 lines
9.7 KiB
Text
346 lines
9.7 KiB
Text
esphome:
|
|
name: plants
|
|
esp32:
|
|
board: esp32dev
|
|
framework:
|
|
type: esp-idf
|
|
version:
|
|
recommended
|
|
# Custom sdkconfig options
|
|
sdkconfig_options:
|
|
CONFIG_COMPILER_OPTIMIZATION_SIZE: y
|
|
|
|
# Enable logging
|
|
logger:
|
|
|
|
# Enable Home Assistant API
|
|
api:
|
|
password: !secret plants_ota
|
|
|
|
ota:
|
|
password: !secret plants_ota
|
|
|
|
wifi:
|
|
ssid: !secret wifi_ssid
|
|
password: !secret wifi_password
|
|
#fast_connect: true
|
|
|
|
# Enable fallback hotspot (captive portal) in case wifi connection fails
|
|
ap:
|
|
ssid: "plants Fallback Hotspot"
|
|
password: "1Xzqff400HYc"
|
|
|
|
# web_server:
|
|
# port: 80
|
|
|
|
color:
|
|
- id: my_red
|
|
red: 100%
|
|
green: 0%
|
|
blue: 0%
|
|
- id: my_yellow
|
|
red: 100%
|
|
green: 100%
|
|
blue: 0%
|
|
- id: my_green
|
|
red: 0%
|
|
green: 100%
|
|
blue: 0%
|
|
- id: my_blue
|
|
red: 0%
|
|
green: 0%
|
|
blue: 100%
|
|
- id: my_gray
|
|
red: 50%
|
|
green: 50%
|
|
blue: 50%
|
|
|
|
font:
|
|
- file: "LiberationSans.ttf"
|
|
id: liberationsans_48
|
|
size: 48
|
|
- file: "LiberationSans.ttf"
|
|
id: liberationsans_36
|
|
size: 36
|
|
- file: "LiberationSans.ttf"
|
|
id: liberationsans_24
|
|
size: 24
|
|
- file: "LiberationSans.ttf"
|
|
id: liberationsans_12
|
|
size: 12
|
|
|
|
binary_sensor:
|
|
- platform: status
|
|
name: "Node Status"
|
|
id: system_status
|
|
- platform: gpio
|
|
pin:
|
|
number: GPIO0
|
|
inverted: true
|
|
mode:
|
|
input: true
|
|
pullup: true
|
|
id: tdisplay_button_input_0
|
|
filters:
|
|
- delayed_on: 100ms
|
|
- delayed_off: 100ms
|
|
on_press:
|
|
then:
|
|
- if:
|
|
condition:
|
|
- script.is_running: main_loop
|
|
then:
|
|
- logger.log: Script is running, can't rewind page
|
|
else:
|
|
- globals.set:
|
|
id: currpage
|
|
value: !lambda |-
|
|
int newpage = id(currpage) - 2;
|
|
if ((newpage >= id(pagecount)) || (newpage < 0)) {
|
|
return id(pagecount) - 1;
|
|
} else {
|
|
return id(currpage) - 2;
|
|
}
|
|
- script.execute: main_loop
|
|
- platform: gpio
|
|
pin:
|
|
number: GPIO35
|
|
inverted: true
|
|
id: tdisplay_button_input_1
|
|
filters:
|
|
- delayed_on: 100ms
|
|
- delayed_off: 100ms
|
|
on_press:
|
|
then:
|
|
- if:
|
|
condition:
|
|
- script.is_running: main_loop
|
|
then:
|
|
- logger.log: Script is running, can't next page
|
|
else:
|
|
- script.execute: main_loop
|
|
|
|
switch:
|
|
- platform: gpio
|
|
pin: GPIO4
|
|
id: backlight
|
|
internal: true
|
|
|
|
time:
|
|
- platform: homeassistant
|
|
id: esptime
|
|
|
|
spi:
|
|
clk_pin: GPIO18
|
|
mosi_pin: GPIO19
|
|
|
|
esp32_ble_tracker:
|
|
scan_parameters:
|
|
active: false
|
|
|
|
# external_components:
|
|
# - source: github://myhomeiot/esphome-components
|
|
# components: [ ble_gateway ]
|
|
|
|
# ble_gateway:
|
|
# devices:
|
|
# - mac_address: 58:2D:34:10:6F:D6 # Bedroom
|
|
# - mac_address: 58:2D:34:10:70:6E # Living Room
|
|
# - mac_address: 58:2D:34:10:74:70 # Office
|
|
# - mac_address: 58:2D:34:39:6A:8E # Kitchen
|
|
# on_ble_advertise:
|
|
# then:
|
|
# homeassistant.service:
|
|
# service: ble_monitor.parse_data
|
|
# data:
|
|
# packet: !lambda return packet;
|
|
# gateway_id: blerelay
|
|
|
|
|
|
image:
|
|
- file: "img/water-percent.png"
|
|
id: "water_percent"
|
|
type: GRAYSCALE
|
|
- file: "img/thermometer.png"
|
|
id: "thermometer"
|
|
type: GRAYSCALE
|
|
- file: "img/brightness.png"
|
|
id: "brightness"
|
|
type: GRAYSCALE
|
|
|
|
# display is 240x135
|
|
display:
|
|
- platform: st7789v
|
|
id: my_display
|
|
backlight_pin: GPIO4
|
|
cs_pin: GPIO5
|
|
dc_pin: GPIO16
|
|
reset_pin: GPIO23
|
|
rotation: 270
|
|
pages:
|
|
- id: time_page
|
|
lambda: |-
|
|
it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
|
|
it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
|
|
|
|
it.strftime((240 / 2), (140 / 3) * 1 + 5, id(liberationsans_24), id(my_gray), TextAlign::CENTER, "%Y-%m-%d", id(esptime).now());
|
|
it.strftime((240 / 2), (140 / 3) * 2 + 5, id(liberationsans_48), id(my_gray), TextAlign::CENTER, "%H:%M", id(esptime).now());
|
|
it.print(5, 5, id(liberationsans_12), id(my_yellow), TextAlign::TOP_LEFT, "ESPHome");
|
|
|
|
if (id(system_status).state) {
|
|
it.print(235, 5, id(liberationsans_12), id(my_green), TextAlign::TOP_RIGHT, "Online");
|
|
}
|
|
else {
|
|
it.print(235, 5, id(liberationsans_12), id(my_red), TextAlign::TOP_RIGHT, "Offline");
|
|
}
|
|
- id: moisture_page
|
|
lambda: |-
|
|
it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
|
|
it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
|
|
|
|
it.strftime(235,5, id(liberationsans_12), id(my_gray), TextAlign::TOP_RIGHT, "%Y-%m-%d", id(esptime).now());
|
|
it.strftime(5, 5, id(liberationsans_12), id(my_gray), TextAlign::TOP_LEFT, "%H:%M:%S", id(esptime).now());
|
|
|
|
it.image(10, 30, id(water_percent));
|
|
std::string sensor_title = id(sensortitle).state;
|
|
it.printf(85, 30, id(liberationsans_24), id(my_gray), TextAlign::TOP_LEFT, sensor_title.c_str());
|
|
it.printf(85, (140 / 3) * 1 + 30, id(liberationsans_48),id(my_gray), TextAlign::TOP_LEFT, "%.0f %%", id(sensorfloat) );
|
|
- id: temp_page
|
|
lambda: |-
|
|
it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
|
|
it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
|
|
|
|
it.strftime(235,5, id(liberationsans_12), id(my_gray), TextAlign::TOP_RIGHT, "%Y-%m-%d", id(esptime).now());
|
|
it.strftime(5, 5, id(liberationsans_12), id(my_gray), TextAlign::TOP_LEFT, "%H:%M:%S", id(esptime).now());
|
|
|
|
it.image(10, 30, id(thermometer));
|
|
std::string sensor_title = id(sensortitle).state;
|
|
it.printf(85, 30, id(liberationsans_24), id(my_gray), TextAlign::TOP_LEFT, sensor_title.c_str());
|
|
float temp_f = id(sensorfloat) * (9.0/5.0) + 32.0;
|
|
it.printf(85, (140 / 3) * 1 + 30, id(liberationsans_48),id(my_gray), TextAlign::TOP_LEFT, "%.0f °F", temp_f );
|
|
- id: lux_page
|
|
lambda: |-
|
|
it.rectangle(0, 0, it.get_width(), it.get_height(), id(my_blue));
|
|
it.rectangle(0, 20, it.get_width(), it.get_height(), id(my_blue)); // header bar
|
|
|
|
it.strftime(235,5, id(liberationsans_12), id(my_gray), TextAlign::TOP_RIGHT, "%Y-%m-%d", id(esptime).now());
|
|
it.strftime(5, 5, id(liberationsans_12), id(my_gray), TextAlign::TOP_LEFT, "%H:%M:%S", id(esptime).now());
|
|
|
|
it.image(10, 30, id(brightness));
|
|
std::string sensor_title = id(sensortitle).state;
|
|
it.printf(85, 30, id(liberationsans_24), id(my_gray), TextAlign::TOP_LEFT, sensor_title.c_str());
|
|
it.printf(85, (140 / 3) * 1 + 30, id(liberationsans_36),id(my_gray), TextAlign::TOP_LEFT, "%d lx", id(sensorint) );
|
|
|
|
interval:
|
|
- interval: 60s
|
|
then:
|
|
- script.execute: main_loop
|
|
|
|
globals:
|
|
- id: currpage
|
|
type: int
|
|
restore_value: no
|
|
initial_value: "0"
|
|
- id: pagecount
|
|
type: int
|
|
restore_value: no
|
|
initial_value: '5'
|
|
- id: sensorfloat
|
|
type: float
|
|
restore_value: no
|
|
initial_value: "0.0"
|
|
- id: sensorint
|
|
type: int
|
|
restore_value: no
|
|
initial_value: "0"
|
|
text_sensor:
|
|
- id: sensortitle
|
|
platform: template
|
|
internal: true
|
|
lambda: |-
|
|
return {};
|
|
- id: sensortext
|
|
platform: template
|
|
internal: true
|
|
lambda: |-
|
|
return {};
|
|
|
|
script:
|
|
- id: main_loop
|
|
then:
|
|
- if:
|
|
condition:
|
|
lambda: "return id(currpage) == 0;"
|
|
then:
|
|
- logger.log: 'Displaying time page'
|
|
- display.page.show: time_page
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return id(currpage) == 1;
|
|
then:
|
|
- logger.log: 'Displaying Coleus moisture page'
|
|
- text_sensor.template.publish:
|
|
id: sensortitle
|
|
state: "Coleus Soil"
|
|
- globals.set:
|
|
id: sensorfloat
|
|
value: !lambda |-
|
|
return id(coleus_moist).state;
|
|
- display.page.show: moisture_page
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return id(currpage) == 2;
|
|
then:
|
|
- logger.log: 'Displaying Coleus temp page'
|
|
- text_sensor.template.publish:
|
|
id: sensortitle
|
|
state: "Coleus Temp"
|
|
- globals.set:
|
|
id: sensorfloat
|
|
value: !lambda |-
|
|
return id(coleus_temp).state;
|
|
- display.page.show: temp_page
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return id(currpage) == 3;
|
|
then:
|
|
- logger.log: 'Displaying Coleus lux page'
|
|
- text_sensor.template.publish:
|
|
id: sensortitle
|
|
state: "Coleus Lux"
|
|
- globals.set:
|
|
id: sensorint
|
|
value: !lambda |-
|
|
return id(coleus_light).state;
|
|
- display.page.show: lux_page
|
|
- component.update: my_display
|
|
- globals.set:
|
|
id: currpage
|
|
value: !lambda |-
|
|
return id(currpage) += 1;
|
|
- if:
|
|
condition:
|
|
lambda: |-
|
|
return id(currpage) >= id(pagecount);
|
|
then:
|
|
- globals.set:
|
|
id: currpage
|
|
value: '0'
|
|
sensor:
|
|
- platform: xiaomi_hhccjcy01
|
|
mac_address: "C4:7C:8D:6C:A2:8D"
|
|
temperature:
|
|
name: "Coleus Temperature"
|
|
id: coleus_temp
|
|
moisture:
|
|
name: "Coleus Moisture"
|
|
id: coleus_moist
|
|
illuminance:
|
|
name: "Coleus Illuminance"
|
|
id: coleus_light
|
|
conductivity:
|
|
name: "Coleus Soil Conductivity"
|
|
id: coleus_soilv
|