"Pin 4 is used in multiple places" since update?

Yeah, like others, this kind of snuck up on me. Very quickly checked the documentation, tried to add the line to ignore the duplication and it wouldn’t pass validation in HA, so I’ve put it off for the time being.

Of note, the documentation page for the display I’m using is still using an example config that duplicates GPIO pins, so someone who knows this stuff better than I might want to update it lest it cause issues for the next guy.

I’ll figure it out eventually since I’ve figured out my issues in the past, but I wanted to chime in.

Edit: Okay, figured it out, but I’ve seen more than a few devs say that reusing GPIO pins is bad practice and honestly don’t know where to start with the st7789v since even the documentation is instructing me to reuse the pin. It’s compiling and working, so I guess I’ll just leave it be for the time being.

1 Like

Does it? I can’t see that. Would you please tell me exactly where that is? ST7789V TFT LCD — ESPHome

What the docs for Pin Schema say is that there may be cases where pin sharing is needed, and it allows for that

  • allow_other_uses (Optional, boolean): If the pin is also specified elsewhere in the configuration. By default multiple uses of the same pin will be flagged as an error. This option will suppress the error and is intended for rare cases where a pin is shared between multiple components. Defaults to false.

This change really messed me up.
Thanks all for the guidance.

None of the examples here should actually be using the workaround. They are examples of why this validation was added. If you need help de-duplicating your pins, then come ask on the esphome discord.

1 Like

add “allow_other_uses: True” everywhere PIN reused. 1st times, 2nd times, 3rd times…
ex:

first_component:
  pin:
    allow_other_uses: True

second_component:
  pin:
    allow_other_uses: True

In what case are you having to use a pin more than once?

Where template sensors use the same data of a pin.

I don’t think that’s a good reason, the template sensor can always use the data from the sensor wihich is the ‘first user’ of that pin. And if it is the same type you also can use the copy component Copy Integration — ESPHome.

1 Like

Very similar issue, but I didn’t find the answer
I added allow_other_uses: true

status_led:
  pin:
    number: GPIO13
    allow_other_uses: true
    inverted: true

output:
  - platform: esp8266_pwm
    id: blue_led
    pin: GPIO13
    allow_other_uses: true
    inverted: True

light:
  - platform: monochromatic
    name: sonoff_mini_1_blueled
    output: blue_led

In most cases it works, but here I got response

output.esp8266_pwm: [source <unicode string>:75]
  platform: esp8266_pwm
  id: blue_led
  pin: GPIO13
  
  [allow_other_uses] is an invalid option for [output.esp8266_pwm]. Please check the indentation.
  allow_other_uses: True
  inverted: True

It is from Sonoff mini flashed with ESPhome

output:
  - platform: esp8266_pwm
    id: blue_led
    pin: 
       number: GPIO13
       allow_other_uses: true
    inverted: True

Just like the instructions say!

1 Like

I seem to follow the instruction correctly but I get the next message

INFO ESPHome 2024.2.1
INFO Reading configuration /config/esphome/moisture.yaml...
Failed config

output.gpio: [source /config/esphome/moisture.yaml:41]
  
  Pin 2 incorrectly sets allow_other_uses: true.
  platform: gpio
  id: light_output
  pin: 
    number: 2
    allow_other_uses: True
    mode: 
      output: True
      input: False
      open_drain: False
      pullup: False
      pulldown: False
      analog: False
    inverted: False
  inverted: True

this is my file (moisture):


output:
  - platform: gpio
    id: light_output
    pin:
      number: GPIO2
      allow_other_uses: true
    inverted: true

sensor:
- platform: adc
  id: "adcMoisture"
  pin:
    number: A0
    allow_other_uses: true
  accuracy_decimals: 5
  unit_of_measurement: '%'
  filters:
    - calibrate_linear:
      - 0.00488  -> 100.0
      - 0.00391 -> 0
  name: "Plant - Moisture Level"
  update_interval: 30s
- platform: adc
  id: "adcRaw_Sensor_Data"
  pin:
    number: A0
    allow_other_uses: true
  accuracy_decimals: 5
  name: "Plant - Sensor Voltage"
  update_interval: 30s
- platform: wifi_signal
  name: "Plant - WiFi Signal Sensor"
  update_interval: 30s

You only seem to use gpio2 once, so why are you setting to allow_other_uses:?