esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

pcf8574 Read Caching #4823

Closed technononsense closed 9 months ago

technononsense commented 1 year ago

The problem

I'm using multiple pcf8574 port expanders on an i2c bus. They work fine using them as GPIOs. My intention is to use some pins in the pcf8574's in a keypad_matrix. Doing so, fills the logs with an warnings that reads are taking too long (~9-10 per second):

[14:42:42][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:42:42][W][component:205]: Components should block for at most 20-30ms.

I raised this on discord, @ssieb highlighted that the same issue had fixed in a recent PR (5137). I've taken the changes and applied them to the pcf8574 but the it's not solved the issue and I don't know enough to debug it.

Which version of ESPHome has the issue?

2023.8.1

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

n/a

What platform are you using?

ESP32

Board

WT32-ETH01

Component causing the issue

pcf8574

Example YAML snippet

substitutions:
  devicename: hub_downstairs
  devicename_upper: "Hub Downstairs"
  node_ip: 192.168.1.86

esphome:
  name: ${devicename}

esp32:
  board: wt32-eth01
  framework:
    type: arduino

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO0_IN
  phy_addr: 1
  power_pin: GPIO16

  manual_ip:
    static_ip: "${node_ip}"
    gateway: 192.168.1.254
    subnet: 255.255.255.0

web_server:

ota:
  safe_mode: on

api:

logger:

i2c:
  id: bus_a
  sda: GPIO14
  scl: GPIO15
  scan: true

pcf8574:
  - id: 'io_switch_column'
    address: 0x24
    pcf8575: false
  - id: 'io_switch_row'
    address: 0x20 
    pcf8575: false
  - id: 'io_sensors_1'
    address: 0x22
    pcf8575: false
  - id: 'io_sensors_2'
    address: 0x21
    pcf8575: false

matrix_keypad:
  id: wall_switches
  rows:
    - pin:
        pcf8574: io_switch_row
        number: 0
    - pin: 
        pcf8574: io_switch_row
        number: 1
    - pin:
        pcf8574: io_switch_row
        number: 2
    - pin:
        pcf8574: io_switch_row
        number: 3
    - pin:
        pcf8574: io_switch_row
        number: 4
    - pin:
        pcf8574: io_switch_row
        number: 5
    - pin:
        pcf8574: io_switch_row
        number: 6
    - pin:
        pcf8574: io_switch_row
        number: 7
  columns:
    - pin:
        pcf8574: io_switch_column
        number: 0
    - pin: 
        pcf8574: io_switch_column
        number: 1
    - pin: 
        pcf8574: io_switch_column
        number: 2
    - pin: 
        pcf8574: io_switch_column
        number: 3
    - pin: 
        pcf8574: io_switch_column
        number: 4
    - pin: 
        pcf8574: io_switch_column
        number: 5
    - pin: 
        pcf8574: io_switch_column
        number: 6
    - pin: 
        pcf8574: io_switch_column
        number: 7

Anything in the logs that might be useful for us?

[14:57:05][I][app:102]: ESPHome version 2023.8.1 compiled on Aug 22 2023, 14:05:30
[14:57:05][C][pcf8574:027]: PCF8574:
[14:57:05][C][pcf8574:028]:   Address: 0x24
[14:57:05][C][pcf8574:029]:   Is PCF8575: NO
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][C][pcf8574:027]: PCF8574:
[14:57:06][C][pcf8574:028]:   Address: 0x20
[14:57:06][C][pcf8574:029]:   Is PCF8575: NO
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][C][pcf8574:027]: PCF8574:
[14:57:06][C][pcf8574:028]:   Address: 0x22
[14:57:06][C][pcf8574:029]:   Is PCF8575: NO
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][C][pcf8574:027]: PCF8574:
[14:57:06][C][pcf8574:028]:   Address: 0x21
[14:57:06][C][pcf8574:029]:   Is PCF8575: NO
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][C][logger:301]: Logger:
[14:57:06][C][logger:302]:   Level: DEBUG
[14:57:06][C][logger:303]:   Log Baud Rate: 115200
[14:57:06][C][logger:305]:   Hardware UART: UART0
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][C][i2c.arduino:053]: I2C Bus:
[14:57:06][C][i2c.arduino:054]:   SDA Pin: GPIO14
[14:57:06][C][i2c.arduino:055]:   SCL Pin: GPIO15
[14:57:06][C][i2c.arduino:056]:   Frequency: 50000 Hz
[14:57:06][C][i2c.arduino:059]:   Recovery: bus successfully recovered
[14:57:06][I][i2c.arduino:069]: Results from i2c bus scan:
[14:57:06][I][i2c.arduino:075]: Found i2c device at address 0x20
[14:57:06][I][i2c.arduino:075]: Found i2c device at address 0x21
[14:57:06][I][i2c.arduino:075]: Found i2c device at address 0x22
[14:57:06][I][i2c.arduino:075]: Found i2c device at address 0x24
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][C][restart.button:017]: Restart Button 'ESP Restart Hub Downstairs'
[14:57:06][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:06][W][component:205]: Components should block for at most 20-30ms.
[14:57:06][C][safe_mode.button:022]: Safe Mode Button 'ESP Restart to Safe Mode Hub Downstairs'
[14:57:06][C][safe_mode.button:022]:   Icon: 'mdi:restart-alert'
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][C][status:034]: Status Binary Sensor 'ESPHome Status Hub Downstairs'
[14:57:07][C][status:034]:   Device Class: 'connectivity'
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][C][matrix_keypad:090]: Matrix Keypad:
[14:57:07][C][matrix_keypad:091]:  Rows:
[14:57:07][C][matrix_keypad:093]:   Pin: 0 via PCF8574
[14:57:07][C][matrix_keypad:093]:   Pin: 1 via PCF8574
[14:57:07][C][matrix_keypad:093]:   Pin: 2 via PCF8574
[14:57:07][C][matrix_keypad:093]:   Pin: 3 via PCF8574
[14:57:07][C][matrix_keypad:093]:   Pin: 4 via PCF8574
[14:57:07][C][matrix_keypad:093]:   Pin: 5 via PCF8574
[14:57:07][C][matrix_keypad:093]:   Pin: 6 via PCF8574
[14:57:07][C][matrix_keypad:093]:   Pin: 7 via PCF8574
[14:57:07][C][matrix_keypad:095]:  Cols:
[14:57:07][C][matrix_keypad:097]:   Pin: 0 via PCF8574
[14:57:07][C][matrix_keypad:097]:   Pin: 1 via PCF8574
[14:57:07][C][matrix_keypad:097]:   Pin: 2 via PCF8574
[14:57:07][C][matrix_keypad:097]:   Pin: 3 via PCF8574
[14:57:07][C][matrix_keypad:097]:   Pin: 4 via PCF8574
[14:57:07][C][matrix_keypad:097]:   Pin: 5 via PCF8574
[14:57:07][C][matrix_keypad:097]:   Pin: 6 via PCF8574
[14:57:07][C][matrix_keypad:097]:   Pin: 7 via PCF8574
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][C][ethernet:221]: Ethernet:
[14:57:07][C][ethernet:363]:   IP Address: 192.168.1.86
[14:57:07][C][ethernet:364]:   Hostname: 'hub_downstairs'
[14:57:07][C][ethernet:365]:   Subnet: 255.255.255.0
[14:57:07][C][ethernet:366]:   Gateway: 192.168.1.254
[14:57:07][C][ethernet:372]:   DNS1: 0.0.0.0
[14:57:07][C][ethernet:373]:   DNS2: 0.0.0.0
[14:57:07][C][ethernet:397]:   MAC Address: 94:3C:C6:3C:31:2F
[14:57:07][C][ethernet:402]:   Is Full Duplex: YES
[14:57:07][C][ethernet:407]:   Link Speed: 100
[14:57:07][C][ethernet:224]:   Power Pin: 16
[14:57:07][C][ethernet:226]:   MDC Pin: 23
[14:57:07][C][ethernet:227]:   MDIO Pin: 18
[14:57:07][C][ethernet:228]:   Type: LAN8720
[14:57:07][C][ethernet:229]:   PHY addr: 1
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][C][web_server:161]: Web Server:
[14:57:07][C][web_server:162]:   Address: 10.10.10.10:80
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][C][mdns:112]: mDNS:
[14:57:07][C][mdns:113]:   Hostname: hub_downstairs
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][C][ota:093]: Over-The-Air Updates:
[14:57:07][C][ota:094]:   Address: 192.168.1.86:3232
[14:57:07][W][component:204]: Component matrix_keypad took a long time for an operation (0.08 s).
[14:57:07][W][component:205]: Components should block for at most 20-30ms.
[14:57:07][C][api:138]: API Server:
[14:57:07][C][api:139]:   Address: 192.168.1.86:6053
[14:57:08][C][api:143]:   Using noise encryption: NO

Additional information

No response

github-actions[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.