Open stevedee78 opened 4 years ago
Copy the contents of the components directory (axp192 and st7735) to a custom_components directory next to your .yaml configuration file. I guess that should be in the config/esphome directory of a Home Assistant install but I'm not using esphome from Home Assistant.
I'm running esphome add-on in Home Assistant on raspi4 and it's working.
What I did:
esphome: name: $devicename platform: ESP32 board: m5stick-c includes:
"includes: ..." are not needed since you copied those two folders in the right path
ah yes you're right. works without includes
I'm stuck here too... Got a lot of errors at first and was able to get rid of all of them except for 'Component not found: display.'
`INFO Reading configuration /config/esphome/remote_screen.yaml...
ERROR Unable to load custom component display:
Traceback (most recent call last):
File "/opt/esphome/esphome/config.py", line 134, in _lookup_module
module = importlib.import_module(f'custom_components.{domain}')
File "/usr/lib/python3.6/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
display: [source /config/esphome/remote_screen.yaml:77]
****Component not found: display.
I placed both axp192 and st7735 folders in config>esphome>custom_components.
If anyone could nudge me in the right direction? The idea of having a functional M5Stick running esphome is just too sweet to pass up on. Thanks!
Some incompatible changes have been made in the last release, so this will not work without small modifications.
First you need change spi.SPI_DEVICE_SCHEMA
is now spi.spi_device_schema()
(display.py, line 22), then remove override
from draw_absolute_pixel_internal()
method declaration (st7735.h, line 140) and the last issue is with incompatible type of variable color
- just need to change the whole code related to it, but I am not able to think right now :)
Thanks so much, this is exactly what was needed! Works like a charm now. Now on to figuring out how to pass data from Home Assistant to the M5Stick (i.e. that specific lightbulb is ON) and I'll be set. Thanks again!
what does the code for the color varialble need to be. I have been trying to get my FW to compile but i am stuck on this.
src/esphome/components/st7735/st7735.cpp:277:13: error: no match for 'operator==' (operand types are 'int' and 'const esphome::Color')
^
src/esphome/components/st7735/st7735.cpp:279:20: error: no match for 'operator==' (operand types are 'int' and 'const esphome::Color')
^ Archiving /data/m5stickc/.pioenvs/m5stickc/libe94/libESPmDNS.a *** [/data/m5stickc/.pioenvs/m5stickc/src/esphome/components/st7735/st7735.cpp.o] Error 1 Archiving /data/m5stickc/.pioenvs/m5stickc/lib790/libFS.a src/main.cpp: In function 'void setup()': src/main.cpp:976:33: error: invalid new-expression of abstract class type 'esphome::st7735::ST7735'
I found everything I needed here: https://github.com/airy10/esphome-m5stickC/pull/10#issue-487477106 thanks to the great work done by https://github.com/geiseri
Cheers!
+1
Hi, I'm trying to add support for the st7735 display But I'm getting the following error: platfor not found: 'display.st7735'
What is the correct configuration?
I added the two directories axp192 and st7735 in esphome / custom_component, I also restarted Home Assistant but still get the error.
Can you tell me how to do it?
Thanks.
@airy10 @geiseri @abmantis @apolselli Thank you heaps for the code and sample! you guys awesome @djgragra please download the sample config from this Github repository for the start. If you still have an issue you can flash m5stick -> remove from home assistant -> delete from esphome and redo it again (this is works for me)
Sample YML:
Folder configuration for custom component:
Need some help installing.
I'm getting the following errors when I try to "validate" the *.yaml file: ERROR Unable to load custom component axp192.sensor: ERROR Unable to load custom component st7735.display:
I have the components copied into the following directory structure: config/esphome/custom_components/ax192/ config/esphome/custom_components/st7735/
I removed the "include" statements as someone suggested in an above comment.
Please use to folder structure on my comment above. The YML file have to be outside custom components folder.
Please use to folder structure on my comment above. The YML file have to be outside custom components folder.
I finally got the directory structure correct, and can compile using ESPHome without any errors. But at the end of the process, I can't upload the *.bin file to the M5stickc.
I get the following error from ESPHome:
INFO Successfully compiled program. INFO Connecting to 192.168.1.230 ERROR Connecting to 192.168.1.230:3232 failed: [Errno 111] Connection refused
Is you m5stickc already running esphome? If not, you have to upload over usb the first time. After that you can upload over wifi.
Is you m5stickc already running esphome? If not, you have to upload over usb the first time. After that you can upload over wifi.
I tried for days to upload via the USB through ESPHome, never could figure out how to do that, always wanted to use OTA. Today I found an article that said I needed to upload a bootstrap first, then esphome bin file and then after that OTA started working.
I never could get esphome-flasher to work from GUI, had to use command line and set baud rate at 115,200.
Just getting ready to try COLORS now on the display.
I found that note and did that the first time I worked with this device. The next time (with a new m5stickc), I didn't do that and things worked anyhow. I'm not sure what the difference is. Maybe some firmware differences in the shipped devices. Or I might have first run a demo program with the Arduino IDE (can't remember) and that did some magic to fix me.
Anyhow, glad you got it working.
Follow this instruction to install esphome in your environment
Installing ESPHome is very easy. All you need to do is have Python installed and install the console script through pip3.
pip3 install esphome
Read through until :
First uploading Now you can go ahead and add some more components. Once you feel like you have something you want to upload to your ESP board, simply plug in the device via USB and type the following command (replacing livingroom.yaml with your configuration file):
esphome livingroom.yaml run
For more information go to : https://esphome.io/guides/getting_started_command_line.html
Managed to get the m5stickc to validate it's yaml file but on install received the below complie error when installing. seems to be an issue with Color object.
src/esphome/components/st7735/st7735.cpp: In member function 'virtual void esphome::st7735::ST7735::draw_absolute_pixel_internal(int, int, esphome::Color)':
src/esphome/components/st7735/st7735.cpp:275:25: error: 'struct esphome::Color' has no member named 'to_rgb_565'
auto color565 = color.to_rgb_565();
anyone come across this issue or have a solution?
There was a change with the way colours are handled in esphome a few revisions ago, I remember having to change my config to define the colours like this and refer to them by id:
color:
- id: color_blue
red: 0%
green: 0%
blue: 100%
[...]
display:
- platform: ili9341
[...]
pages:
- id: page_1
lambda: |-
it.rectangle(0, 0, it.get_width(), it.get_height(), id(color_blue));
it.rectangle(0, 22, it.get_width(), it.get_height(), id(color_blue));
[...]
Not only has color handling changed, but native support for the ST7735 display was added to ESPhome 1.16.0, so we no longer need to use this custom component (it can be removed from the custom_components directory and for projects depending on it be sure to "Clean Build Files").
A few minor config changes are then needed when using the integrated display driver with m5stickC:
# wonky color fix, in lieu of finding a way to invert the display
color:
- id: color_wet
red: 100%
green: 100%
blue: 0%
- id: color_dry
red: 100%
green: 0%
blue: 100%
# built-in 80x160 TFT
display:
- platform: st7735
model: "INITR_MINI160X80"
device_height: 160
device_width: 82
col_start: 0
row_start: 0
eight_bit_color: false
cs_pin: GPIO5
dc_pin: GPIO23
reset_pin: GPIO18
lambda: |-
if (id(leak).state) {
it.fill(COLOR_ON);
it.print(42, -24, id(font1), id(color_wet), TextAlign::TOP_CENTER, "W");
it.print(42, 32, id(font1), id(color_wet), TextAlign::TOP_CENTER, "E");
it.print(42, 85, id(font1), id(color_wet), TextAlign::TOP_CENTER, "T");
} else {
it.fill(COLOR_ON);
it.print(42, -24, id(font1), id(color_dry), TextAlign::TOP_CENTER, "D");
it.print(42, 32, id(font1), id(color_dry), TextAlign::TOP_CENTER, "R");
it.print(42, 85, id(font1), id(color_dry), TextAlign::TOP_CENTER, "Y");
}
I don't want to disparage someone else's free work, but st7735 integration work in ESPHome has a few ragged edges. I wish they had exposed a config to invert the colors so the kind of trick @ryanalden did would not be necessary. Perhaps the author of it was not aware that there were common devices that need it.
Maybe I'll get up a PR for that. (Maybe I already did that. Can't remember.)
Hi, I'm trying to add support for the st7735 display But I'm getting the following error: platfor not found: 'display.st7735'
What is the correct configuration? I added the two directories axp192 and st7735 in esphome / custom_component, I also restarted Home Assistant but still get the error. Can you tell me how to do it? Thanks.
I am struggling with a basic example I cant get run. :/ Validate shows the following error: Why is this so complicated? :/
display.st7735: [source /config/esphome/m5stick1.yaml:116]
Platform not found: 'display.st7735'.
platform: st7735
Now where is actually the issue? What does it exactly mean plattform not found? -> folder structure like @pix3lize mentioned doesent work for me or I dont understand what kind of structure you mean.
/run/user/1000/gvfs/smb-share:server=192.168.0.10,share=config/esphome$ tree
.
├── custom_components
│ ├── axp192
│ │ ├── axp192.cpp
│ │ ├── axp192.h
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-36.pyc
│ │ │ ├── __init__.cpython-39.pyc
│ │ │ ├── sensor.cpython-36.pyc
│ │ │ └── sensor.cpython-39.pyc
│ │ └── sensor.py
│ └── st7735
│ ├── display.py
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── display.cpython-36.pyc
│ │ ├── display.cpython-39.pyc
│ │ ├── __init__.cpython-36.pyc
│ │ └── __init__.cpython-39.pyc
│ ├── st7735.cpp
│ └── st7735.h
├── fonts
│ ├── arial.ttf
│ ├── comic-sans-ms.ttf
│ └── OpenSans-Regular.ttf
├── i2c_enabled_by_gpio.h
├── m5stick1.yaml
└── secrets.yaml
Validate result:
Validate m5stick1.yaml ❌
INFO Reading configuration /config/esphome/m5stick1.yaml...
ERROR Unable to load component st7735.display:
Traceback (most recent call last):
File "/esphome/esphome/loader.py", line 162, in _lookup_module
module = importlib.import_module(f"esphome.components.{domain}")
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/config/esphome/custom_components/st7735/display.py", line 22, in <module>
}).extend(cv.polling_component_schema('1s')).extend(spi.SPI_DEVICE_SCHEMA)
AttributeError: module 'esphome.components.spi' has no attribute 'SPI_DEVICE_SCHEMA'
WARNING Pin 10 (9-10) might already be used by the flash interface in QUAD IO flash mode.
WARNING Pin 9 (9-10) might already be used by the flash interface in QUAD IO flash mode.
WARNING GPIO15 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
Failed config
display.st7735: [source /config/esphome/m5stick1.yaml:116]
Platform not found: 'display.st7735'.
platform: st7735
the includes doesent work either:
substitutions:
devicename: m5stick1
upper_devicename: M5StickC1
esphome:
name: $devicename
platform: ESP32
board: m5stick-c
includes:
- custom_components/axp192/axp192.h
- custom_components/st7735/st7735.h
platformio_options:
upload_speed: 115200
@MisterTFM : how did you get you structured file correct?
Thanks
I removed the folder custom_components, added again and inserted the files from here again. now its working. So thank you :)
esphome/custom_components$ ls -l
total 0
drwx------ 1 pablo pablo 0 Dec 24 14:06 axp192
drwx------ 1 pablo pablo 0 Dec 24 14:07 st7735
I used the include so I hope it is using the component from the custom_component folder:
esphome:
name: m5stick2
includes:
- custom_components/st7735/st7735.h
esp32:
board: m5stick-c
framework:
type: arduino
I was not able to build it with the custom component becuase of:
Should have read this firts: https://github.com/airy10/esphome-m5stickC/issues/4#issuecomment-893595687
Not only has color handling changed, but native support for the ST7735 display was added to ESPhome 1.16.0, so we no longer need to use this custom component (it can be removed from the custom_components directory and for projects depending on it be sure to "Clean Build Files").
A few minor config changes are then needed when using the integrated display driver with m5stickC:
# wonky color fix, in lieu of finding a way to invert the display color: - id: color_wet red: 100% green: 100% blue: 0% - id: color_dry red: 100% green: 0% blue: 100% # built-in 80x160 TFT display: - platform: st7735 model: "INITR_MINI160X80" device_height: 160 device_width: 82 col_start: 0 row_start: 0 eight_bit_color: false cs_pin: GPIO5 dc_pin: GPIO23 reset_pin: GPIO18 lambda: |- if (id(leak).state) { it.fill(COLOR_ON); it.print(42, -24, id(font1), id(color_wet), TextAlign::TOP_CENTER, "W"); it.print(42, 32, id(font1), id(color_wet), TextAlign::TOP_CENTER, "E"); it.print(42, 85, id(font1), id(color_wet), TextAlign::TOP_CENTER, "T"); } else { it.fill(COLOR_ON); it.print(42, -24, id(font1), id(color_dry), TextAlign::TOP_CENTER, "D"); it.print(42, 32, id(font1), id(color_dry), TextAlign::TOP_CENTER, "R"); it.print(42, 85, id(font1), id(color_dry), TextAlign::TOP_CENTER, "Y"); }
I'm working out using ESPHome on a TTGO T-BEAM for an idea I have to create a C component that extends the ESP API over a LoRA Mesh (bringing in Meshtastic), and I arrived here realizing that the AXP192 power controller is not implemented as a "generic YAML-configurable" ESPHome component.
I figure this is as good a places as any to ask:
Would there be a general consensus / approval at implementing a "generic AXP192 component" that could be configured in YAML (given a dependency on I2C) and configured for different boards?
No chance to install. Unfortunately, that doesn't work for me. I have Homeassisant running on a raspi3. custom_components is available. Can you describe this in more detail?