Hey yall. I am trying to get a 8266 with a PCF8574 lcd display to display a home assistant entity. My code is below. I keep just getting a display on ‘nan.’ I also get an error in the logs of:
[13:21:25][W][component:214]: Component display took a long time for an operation (0.29 s).
[13:21:25][W][component:215]: Components should block for at most 20-30ms.
Please help. Im at a loss.
Code:
i2c:
sda: D6
scl: D5
sensor:
platform: homeassistant
entity_id: sensor.watertanklevel_water_level_2
unit_of_measurement: “Gallons”
id: Water_Level
internal: true
display:
platform: lcd_pcf8574
dimensions: 20x4
address: 0x3F
update_interval: 1s
lambda: |-
it.printf(“%.1f”, id(Water_Level).state);
zoogara
(Daryl)
January 5, 2024, 9:57pm
2
Hi - please edit your post so your yaml is enclosed in preformatted text tags. They are accessed using </> on the posting toolbar.
The error message is just a warning. Most display components give this warning, ignore it.
The “nan” display is “not a number”. What does the log say about the sensor you are importing from home assistant?
Thank you for your thoughts. Here is what the logs say about the sensor… I know the sensor is working because its displayed in home assistant.
[16:14:08][C][i2c.arduino:053]: I2C Bus:
[16:14:08][C][i2c.arduino:054]: SDA Pin: GPIO4
[16:14:08][C][i2c.arduino:055]: SCL Pin: GPIO5
[16:14:08][C][i2c.arduino:056]: Frequency: 50000 Hz
[16:14:08][C][i2c.arduino:059]: Recovery: bus successfully recovered
[16:14:08][I][i2c.arduino:069]: Results from i2c bus scan:
[16:14:08][I][i2c.arduino:075]: Found i2c device at address 0x3F
[16:14:08][C][lcd_pcf8574:024]: PCF8574 LCD Display:
[16:14:08][C][lcd_pcf8574:025]: Columns: 20, Rows: 4
[16:14:08][C][lcd_pcf8574:026]: Address: 0x3F
[16:14:08][C][lcd_pcf8574:027]: Update Interval: 1.0s
[16:14:08][C][captive_portal:088]: Captive Portal:
[16:14:08][C][mdns:115]: mDNS:
[16:14:08][C][mdns:116]: Hostname: tankdisplay
[16:14:08][C][ota:097]: Over-The-Air Updates:
[16:14:08][C][ota:098]: Address: tankdisplay.local:8266
[16:14:08][C][ota:101]: Using Password.
[16:14:08][C][api:139]: API Server:
[16:14:08][C][api:140]: Address: tankdisplay.local:6053
[16:14:08][C][api:142]: Using noise encryption: YES
[16:14:08][C][homeassistant.sensor:030]: Homeassistant Sensor 'Water_Level'
[16:14:08][C][homeassistant.sensor:030]: State Class: ''
[16:14:08][C][homeassistant.sensor:030]: Unit of Measurement: 'Gallons'
[16:14:08][C][homeassistant.sensor:030]: Accuracy Decimals: 1
[16:14:08][C][homeassistant.sensor:031]: Entity ID: 'sensor.watertanklevel_water_level_2'
And… Turns out I just had to add it to home assistant… Its working now. thanks!