This is exactly what I want to do… but I can’t get the sensor part to work. I am assuming this is for the config.yaml in HA. The ESPHome Editor says all it well… but the compiler craps out on me. see errors below
esphome:
name: widget-1
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "XXX"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Widget-1 Fallback Hotspot"
password: "XXX"
captive_portal:
text_sensor:
- platform: homeassistant
id: sonos_volume
entity_id: sensor.media_volume
internal: true
font:
- file: 'ArchivoBlack-Regular.ttf'
id: font1
size: 20
# Example configuration entry
i2c:
sda: 4
scl: 15
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
reset_pin: 16
address: 0x3C
lambda: |-
it.printf(0, 0, id(sonos_volume).state.c_str());
and the line from configuration.yaml:
template:
- sensor:
- name: "media_volume"
value_template: "{{ state_attr('media_player.tv_speakers', 'volume_level') }}"
Annoying Errors…
INFO Reading configuration /config/esphome/widget-1.yaml...
WARNING GPIO4 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
WARNING GPIO4 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
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
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
INFO Generating C++ source...
INFO Compiling app...
Processing widget-1 (board: esp32dev; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <AsyncTCP-esphome> 1.2.2
|-- <WiFi> 1.0
|-- <FS> 1.0
|-- <Update> 1.0
|-- <ESPAsyncWebServer-esphome> 2.1.0
| |-- <AsyncTCP-esphome> 1.2.2
|-- <DNSServer> 1.1.0
|-- <ESPmDNS> 1.0
|-- <Wire> 1.0.1
Compiling /data/widget-1/.pioenvs/widget-1/src/main.cpp.o
Compiling /data/widget-1/.pioenvs/widget-1/FrameworkArduino/esp32-hal-misc.c.o
Compiling /data/widget-1/.pioenvs/widget-1/FrameworkArduino/esp32-hal-psram.c.o
Compiling /data/widget-1/.pioenvs/widget-1/FrameworkArduino/esp32-hal-rmt.c.o
/config/esphome/widget-1.yaml: In lambda function:
/config/esphome/widget-1.yaml:52:50: error: no matching function for call to 'esphome::display::DisplayBuffer::printf(int, int, const char*)'
it.printf(0, 0, id(sonos_volume).state.c_str());
^
In file included from src/esphome.h:17:0,
from src/main.cpp:3:
src/esphome/components/display/display_buffer.h:195:8: note: candidate: void esphome::display::DisplayBuffer::printf(int, int, esphome::display::Font*, esphome::Color, esphome::display::TextAlign, const char*, ...)
void printf(int x, int y, Font *font, Color color, TextAlign align, const char *format, ...)
^
src/esphome/components/display/display_buffer.h:195:8: note: candidate expects 6 arguments, 3 provided
src/esphome/components/display/display_buffer.h:207:8: note: candidate: void esphome::display::DisplayBuffer::printf(int, int, esphome::display::Font*, esphome::Color, const char*, ...)
void printf(int x, int y, Font *font, Color color, const char *format, ...) __attribute__((format(printf, 6, 7)));
^
src/esphome/components/display/display_buffer.h:207:8: note: candidate expects 5 arguments, 3 provided
src/esphome/components/display/display_buffer.h:218:8: note: candidate: void esphome::display::DisplayBuffer::printf(int, int, esphome::display::Font*, esphome::display::TextAlign, const char*, ...)
void printf(int x, int y, Font *font, TextAlign align, const char *format, ...) __attribute__((format(printf, 6, 7)));
^
src/esphome/components/display/display_buffer.h:218:8: note: candidate expects 5 arguments, 3 provided
src/esphome/components/display/display_buffer.h:228:8: note: candidate: void esphome::display::DisplayBuffer::printf(int, int, esphome::display::Font*, const char*, ...)
void printf(int x, int y, Font *font, const char *format, ...) __attribute__((format(printf, 5, 6)));
^
src/esphome/components/display/display_buffer.h:228:8: note: candidate expects 4 arguments, 3 provided
Compiling /data/widget-1/.pioenvs/widget-1/FrameworkArduino/esp32-hal-sigmadelta.c.o
Compiling /data/widget-1/.pioenvs/widget-1/FrameworkArduino/esp32-hal-spi.c.o
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c: In function 'spiTransferBytesNL':
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c:922:39: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
uint8_t * last_out8 = &result[c_longs-1];
^
/data/cache/platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-spi.c:923:40: warning: initialization from incompatible pointer type [-Wincompatible-pointer-types]
uint8_t * last_data8 = &last_data;
^
Compiling /data/widget-1/.pioenvs/widget-1/FrameworkArduino/esp32-hal-time.c.o
*** [/data/widget-1/.pioenvs/widget-1/src/main.cpp.o] Error 1
========================== [FAILED] Took 2.64 seconds ==========================