Hello!
Very new to ESPHome. I just got a M5Stack Core2 and have been doing some early tinkering. I found this
And have been trying to learn. I got battery_level, uptime, and WiFi db as entities in Home Assistant, but I am looking for a way to get brightness as a slider and/or an on/off switch to control the ili9341 screen (for battery saving purposes).
I see in their code
Line 548
void AXP192Component::SetLed(uint8_t state) {
Which I believe is a reference to shutting off the LED? But kinda stuck getting it from the cpp to yaml.
I also see in M5Core2/AXP192.cpp at master · m5stack/M5Core2 (github.com)
Line 156 appears to have code for screen brightness. Is there a simple way to get codes like that into YAML form? Or am I missing something? Thanks!
Here’s my YAML.
substitutions:
name: esphome-web-92b784
hassname: esphomeweb92b784
esphome:
name: esphome-web-92b784
platform: ESP32
board: m5stack-core-esp32
external_components:
- source:
type: git
url: https://gitlab.com/geiseri/esphome_extras.git
refresh: 0s
- source:
type: git
url: https://github.com/JensGuckenbiehl/esphome-m5core2
refresh: 0s
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
text_sensor:
- platform: homeassistant
name: "House Mode"
id: house_mode
entity_id: input_select.house_mode
- platform: homeassistant
name: "Front Door Lock"
id: front_door_lock
entity_id: lock.front_door_lock
- platform: homeassistant
name: "Party Mode Sign Text"
id: party_mode_sign_text
entity_id: input_text.party_mode_sign_text
i2c:
- id: bus_a
sda: GPIO21
scl: GPIO22
scan: True
sensor:
- platform: axp192
model: M5CORE2
address: 0x34
i2c_id: bus_a
update_interval: 30s
battery_level:
name: "${hassname} Battery Level"
id: "${hassname}_batterylevel"
- platform: wifi_signal
name: ${hassname} WiFi Signal
id: wifi_dbm
- platform: uptime
name: ${hassname} Uptime
spi:
clk_pin: GPIO18
mosi_pin: GPIO23
miso_pin: GPIO38
time:
- platform: homeassistant
id: esptime
font:
- file: 'calibri.ttf'
id: font1
size: 48
# # builtin 80x160 TFT
display:
- platform: ili9341
model: M5STACK
cs_pin: GPIO5
dc_pin: GPIO15
rotation: 0
id: core2_display
pages:
- id: page1
lambda: |-
std::string val = id(house_mode).state;
if(id(house_mode).state == "Home") {
std::string val = id(house_mode).state;
it.printf(20, 20, id(font1), Color(70,130,180), "%s Mode", val.c_str());
} else {
it.fill(COLOR_OFF);
}