I have seen a few examples of code snippets on the ESPHome website as well as in other places which I tried to use to show the value of a temperature sensor on a LCD display. The display as such is working fine, I can print text to it and position the text as expected. When I try to tie in a sensor value from HA it fails and gives me a warning during compiling…
/config/esphome/mini-d1-lcd-01.yaml:50:45: warning: format '%f' expects argument of type 'double', but argument 5 has type 'esphome::homeassistant::HomeassistantTextSensor*' [-Wformat=]
it.printf(0, 1, "Temp: %.1f C", id(templr));
I add the yaml content for that particular ESP32 below excluding the section with passwords and keys etc…
thank you for the suggestions. nickrout, your suggestion fills the LCD with garbage, does not show any thing expected. mulcmu, I have changed it now to the following.
This compiles without issues but instead of a value I have only “nan” written in line 2. I thought its maybe because the value in HA has to change for it to refresh, I used a power sensor for testing which changes frequently but the same thing. Restarting HS also does not help. I can see the value of the sensors I use update and change in HA but nothing happens on the LCD. The extra “(” does not work, I get an error while compiling.
no, the log remains silent, I’ve been watching it for the last 10 minutes and noting changes. Here the log with blanced out MAC addreses and SSID.
INFO Reading configuration /config/esphome/mini-d1-lcd-01.yaml...
INFO Starting log output from mini-d1-lcd-01.local using esphome API
INFO Successfully connected to mini-d1-lcd-01.local
[09:02:57][I][app:102]: ESPHome version 2022.11.3 compiled on Nov 30 2022, 08:48:45
[09:02:57][C][wifi:504]: WiFi:
[09:02:57][C][wifi:362]: Local MAC: xxxxxxxxxx
[09:02:57][C][wifi:363]: SSID: xxxxxxxxxx
[09:02:57][C][wifi:364]: IP Address: 10.200.0.227
[09:02:57][C][wifi:366]: BSSID: xxxxxxxxxx
[09:02:58][C][wifi:367]: Hostname: 'mini-d1-lcd-01'
[09:02:58][C][wifi:369]: Signal strength: -31 dB ▂▄▆█
[09:02:58][C][wifi:373]: Channel: 1
[09:02:58][C][wifi:374]: Subnet: 255.255.255.0
[09:02:58][C][wifi:375]: Gateway: 10.200.0.1
[09:02:58][C][wifi:376]: DNS1: 10.200.0.2
[09:02:58][C][wifi:377]: DNS2: 0.0.0.0
[09:02:58][C][logger:293]: Logger:
[09:02:58][C][logger:294]: Level: DEBUG
[09:02:58][C][logger:295]: Log Baud Rate: 115200
[09:02:58][C][logger:296]: Hardware UART: UART0
[09:02:58][C][i2c.arduino:052]: I2C Bus:
[09:02:58][C][i2c.arduino:053]: SDA Pin: GPIO21
[09:02:58][C][i2c.arduino:054]: SCL Pin: GPIO22
[09:02:58][C][i2c.arduino:055]: Frequency: 50000 Hz
[09:02:58][C][i2c.arduino:058]: Recovery: bus successfully recovered
[09:02:58][I][i2c.arduino:068]: Results from i2c bus scan:
[09:02:58][I][i2c.arduino:074]: Found i2c device at address 0x27
[09:02:58][C][lcd_pcf8574:024]: PCF8574 LCD Display:
[09:02:58][C][lcd_pcf8574:025]: Columns: 20, Rows: 4
[09:02:58][C][lcd_pcf8574:026]: Address: 0x27
[09:02:58][C][lcd_pcf8574:027]: Update Interval: 1.0s
[09:02:58][C][captive_portal:088]: Captive Portal:
[09:02:58][C][mdns:103]: mDNS:
[09:02:58][C][mdns:104]: Hostname: mini-d1-lcd-01
[09:02:58][C][ota:093]: Over-The-Air Updates:
[09:02:58][C][ota:094]: Address: mini-d1-lcd-01.local:3232
[09:02:58][C][ota:097]: Using Password.
[09:02:58][C][api:138]: API Server:
[09:02:58][C][api:139]: Address: mini-d1-lcd-01.local:6053
[09:02:58][C][api:141]: Using noise encryption: YES
[09:02:58][C][homeassistant.sensor:030]: Homeassistant Sensor 'testsensor'
[09:02:58][C][homeassistant.sensor:030]: State Class: ''
[09:02:58][C][homeassistant.sensor:030]: Unit of Measurement: ''
[09:02:58][C][homeassistant.sensor:030]: Accuracy Decimals: 1
[09:02:58][C][homeassistant.sensor:031]: Entity ID: 'sensor.house_ampere'
I am again using a sensor that changes all the time to make sure I have values to be updated. I have another ESP32 as pulse counter on a electricity meter, that does show updates every minute but that is the other direction. ESP32 → HA where thie LCD Display would be HA → ESP32.
Just another observation, the ESP32 in question does not show up as a device to be added or configured in Settings → Devices & Services. IDK if that supposed to show or not, since its an output and not an input to HA I did not think it would show up since it adds no new entities or anything to the HA system as such. OTA updated and logs function fine and the devices shows as on-line in the ESPHome site on the HA server.
It needs to be added to HA in order for HA to initiate the api connection. It can be added manually by adding another ESPHome device using the HA UI + New Integration. The IP address (10.200.0.227) can be entered manually, then it should prompt for the api encryption key. Not sure why the auto discovery didn’t detect it.
That seems to have done the trick, I can now see in the log the state being send. I am not home now so I have no eye on the actual display but the logs look promising.