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

Hi Nick and thanks for the prompt reply.

I did try to look for the changelog but admit that I couldn’t find it but did see a very similar question posted here after I hit send on mine and so think a solution may be in ‘allow_other_uses: true’ and I’m trying that now (thanks). :wink:

Changelog is linked on the esphome.io page, ESPHome 2023.12.0 - 20th December 2023 — ESPHome

Thanks again, appreciated.

Unfortunately I don’t seem to understand how to use the example as when I do like this (copied from a quoted usage elsewhere):

display:
  - platform: st7789v
    model: TTGO TDisplay 135x240  # added bit
    id: my_display
    backlight_pin: GPIO4
     allow_other_uses: true
    cs_pin: GPIO5
    dc_pin: GPIO16
    reset_pin: GPIO23

I get on validation: (were row 88 is the allow_other_uses line in question):
“mapping values are not allowed in this context
in “”, line 88, column 22”

I’ve tried it on the first re to P4, both, without the ‘true’ …

I have the same issue but not sure how to proceed and what this means for me:
Pin Reuse validation¶
There is a new validation performed on configurations to ensure that pins are not reused unintentionally. This is a common source of issues and generally a pin does not need to be reused across multiple components in a single configuration. The error can be bypassed by specifically adding another config item to all of the duplicate pin definitions. See the Pin Schema for details.

I use pin 17 2 times…

INFO ESPHome 2023.12.1
INFO Reading configuration /config/esphome/sprinklerrelais4x.yaml…
Failed config

sensor.pulse_counter: [source :163]

Pin 17 is used in multiple places.
platform: pulse_counter
name: Water Flow Hoofdkraan hr
id: flow_hoofdkraan_hr
pin:
number: 17
mode:
input: True
output: False
open_drain: False
pullup: False
pulldown: False
inverted: False
ignore_strapping_warning: False
drive_strength: 20.0
update_interval: 10s
filters:
- lambda: !lambda |-
return (x / 400.0) * 60.0;
unit_of_measurement: L/hr
disabled_by_default: False
force_update: False
icon: mdi:pulse
accuracy_decimals: 2
state_class: measurement
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
use_pcnt: True
internal_filter: 13us
sensor.pulse_counter: [source :172]

Pin 17 is used in multiple places.
platform: pulse_counter
name: Water Flow Hoofdkraan min
id: flow_hoofdkraan_min
pin:
number: 17
mode:
input: True
output: False
open_drain: False
pullup: False
pulldown: False
inverted: False
ignore_strapping_warning: False
drive_strength: 20.0
update_interval: 1s
filters:
- lambda: !lambda |-
return (x / 400.0);
unit_of_measurement: L/min
disabled_by_default: False
force_update: False
icon: mdi:pulse
accuracy_decimals: 2
state_class: measurement
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
use_pcnt: True
internal_filter: 13us

Frikking layout button, where are you after forum update.

I think you are supposed to add the indented:

allow_other_uses: true

on the line after all the lines where the same GPIO pin has been defined, like:

switch:
  - platform: gpio
    pin: GPIO4
     allow_other_uses: true
    id: backlight
    internal: true

That didn’t work for me so I just edited out the switch function that toggles the backlight on and off and to my surprise / pleasure, it works (and removed the need to try to get the override to work). :wink:

Folks could you please format your posts correctly. It’s the </> button. Or use three backticks as explained here https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

2 Likes

Sorry and thanks for the hint re how to make it work Tom. :wink:

1 Like

I had to tinker with this for a bit also. I think what your problem is, you needed to set the pin number(GPIO4) on a different line, then add the allow_other_uses after that line. Try doing this, of course you have to add this to the to pin GPIO04

switch:
  - platform: gpio
    pin: 
      number: GPIO4
      allow_other_uses: true
    id: backlight
    internal: true
5 Likes

Yep, exactly where the changelog points you to:

Pin Schema

Try it in a mobile interface yourself and you’ll see its undoable there…

It is doable

Test code

There see, from my tablet.

A tablet is not a mobile.

I’ve done it from my phone too, you need to find backtick on your keyboard.

Sent from my mobile:
yes: it is possible

It’s the first option in the cog menu button.

1 Like

Nick, you seem upset / frustrated that not everyone finds all this as easy as you seem to?

Imagine looking at a block of code or even the information on pin-schema and effectively seeing hieroglyphics?

Imagine having dyslexia or dyscalculia but really wanting to play with this stuff and just not always seeing stuff as easily as others do?

Should those of us who have to live with such things not ask in help forums for help and support and if / when we do, would it be reasonable that we be given help / support that actually helps, rather than just sends us down other rabbit holes?

Maybe it’s because I spent most of my career in ‘IT Support’ and know what it’s like to have the answers and to really be able to help others with my experience. Personally I relished that position / opportunity and learned help was only really help if it helped (the person asking for help). :wink:

In the end I helped myself (because I couldn’t make sense of the help) by removing the pin duplication as it wasn’t a function I was using anyway (backlight on/off) and just happened to be part of the code I used as it was offered by another person wiling to share.

7 Likes

I guess I probably assumed that someone who was already programming in esphome would be able to follow the docs, as you have to have a certain understanding of the docs to start with.

Thanks. This is way more constructive feedback than @nickrout’s “read the docs …”.

4 Likes

Well, that’s probably not a completely bogus assumption, please be aware that many of us are able to handle the tech (especially as it all becomes more ‘Auto-magic’) but might only copy-paste existing code, rather than create any from scratch, or be able to just read say a manual on ‘How to be a brain surgeon’ and become one overnight. :wink:

I think I can state that in my years using HA, right now, today I’m very little better doing the coding than I was at the beginning. What I have maybe picked up is the ‘steps’ involved in getting to my goal (a functional solution), how to check for a ‘good’ project to copy and how to Google to a solution.

There is little point me actively trying to learn how to code because:

If I couldn’t pick it up when I was 15 I’m not likely to be able to at 65.

Because I’m not coding regularly, I am unlikely to be able to keep up or remember, especially given my current obligations.

I would rather pay someone to do that side while I enjoy doing the bits I do like (basically everything else).

Re ‘the docs’ … I’ve never been a big reader … I mean I can, it’s just not what I enjoy, I’d rather explore something (and why the GUI was invented) and one of the things that has attracted me to HA is how intuitive it has been (considering).

As I mentioned, I’d much rather watch the Youtube ‘Launch Parties’ with the guys, see if something is of interest and take it from there.

‘Different strokes for different folks’ as they say. :wink:

4 Likes

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.