esphome / issues

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

PCF8574 working only with OUTPUT #283

Closed bigstation17 closed 5 years ago

bigstation17 commented 5 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

PIP 1.12.2

ESP (ESP32/ESP8266, Board/Sonoff):

Wemos D1 mini

Affected component:

https://esphome.io/components/pcf8574.html

Description of problem: I cannot use PCF8574 with INPUT or INPUT_PULLUP.

Problem-relevant YAML-configuration entries:

esphome:
  name: test_pcf8571
  platform: ESP8266
  board: d1_mini
  esphome_core_version: 1.12.2

wifi:
  ssid: xxx
  password: xxx

logger:
  level: VERBOSE

web_server:
  port: 80

i2c:
  sda: D6
  scl: D4
  scan: True

pcf8574:
  - id: 'pcf8574_hub'
    address: 0x20
    pcf8575: False

switch:
  - platform: gpio
    name: "PCF8574 Pin #0"
    pin:
      pcf8574: pcf8574_hub
      # Use pin number 0
      number: 1
      # One of INPUT, INPUT_PULLUP or OUTPUT
      mode: INPUT
      inverted: False

Traceback (if applicable):

Failed config

switch.gpio: [source test_pcf8571.yaml:32]
  platform: gpio
  name: PCF8574 Pin #0
  pin:  [source test_pcf8571.yaml:35]
    pcf8574: pcf8574_hub
    number: 1

    Unknown value 'INPUT', must be one of 'OUTPUT'. Got 'INPUT'
    mode: INPUT
    inverted: False

Additional information and things you've tried:

OttoWinter commented 5 years ago

That would be because you're defining it inside a switch - switches control a GPIO state and do not read them. Please see binary_sensor.gpio instead for input mode.

bigstation17 commented 5 years ago

Thank you very much @OttoWinter :) i did not think about that :)