Thanks for your advice.
Instead of using mdi:
images, I switched to the font version, which also made it easier to select the correct symbol programatically.
Meanwhile, I am attempting to have a yaml config running in SDL2, use a sensor exported by HomeAssistant.
I have installed esphome
etc. (including brew install sdl2 libsodium
) on MacOS.
Here is my YAML, incidentally, the sensor is valid :
esphome:
name: testing
friendly_name: Testing
includes:
- battery.h # provides the const char * batterySymbol(int soc) function
project:
name: esphome.host
version: "0"
logger:
api:
encryption:
key: "FCFOW5mzObf7RRtvey6g2cXB61id4z0y8btYwkFp7W0="
sensor:
- platform: homeassistant
entity_id: sensor.ooctcl60bp_statement_of_charge
id: battery_soc
font:
- file: "gfonts://Roboto"
id: roboto20
size: 20
- file: "fonts/materialdesignicons.ttf"
id: symbols
size: 60
glyphs: [
"\U000F008E", # battery0
"\U000F007A", # battery10
"\U000F007B", # battery20
"\U000F007C", # battery30
"\U000F007D", # battery40
"\U000F007E", # battery50
"\U000F007F", # battery60
"\U000F0080", # battery70
"\U000F0081", # battery80
"\U000F0082", # battery90
"\U000F0079", # battery100
"\U000F1904", # home
"\U000F0599", # sunny
"\U000F0D3E", # transmission
]
host:
display:
- platform: sdl
id: sdl_display
update_interval: 1s
auto_clear_enabled: false
show_test_card: false
dimensions:
width: 300
height: 400
lambda: |-
int soc = int(id(battery_soc).state);
it.print(100, 100, id(symbols), TextAlign::BOTTOM_CENTER, batterySymbol(soc));
it.printf(100, 100, id(roboto20), TextAlign::TOP_CENTER, "%d%%", soc);
When I attempt to run this, I get errors with libsodium
which I had already installed.
ESPHome esphome run testing.yaml
INFO ESPHome 2024.6.6
INFO Reading configuration testing.yaml...
/Users/quinn/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
warnings.warn(
INFO Generating C++ source...
INFO Compiling app...
Processing testing (platform: platformio/native)
-----------------------------------------------------------------------------------------------------------------------------------------------------
/Users/quinn/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
warnings.warn(
Dependency Graph
|-- noise-c @ 0.1.4
Compiling .pioenvs/testing/src/main.o
Linking .pioenvs/testing/program
Undefined symbols for architecture arm64:
"__crypto_generichash_blake2b_pick_best_implementation", referenced from:
_sodium_init in libsodium.a[20](core.o)
"__crypto_pwhash_argon2_pick_best_implementation", referenced from:
_sodium_init in libsodium.a[20](core.o)
"__crypto_stream_salsa20_pick_best_implementation", referenced from:
_sodium_init in libsodium.a[20](core.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
*** [.pioenvs/testing/program] Error 1
Did I get the wrong libsodium package installed?
Should the SDL2 host environment be able to access sensors in Home Assistant?
Thanks for any suggestions.