kylemanna / sniffer

ESP32 Air Quality Sensor with PMSA003 + BME680 and 1.14" LCD
Other
121 stars 15 forks source link

Pin 4 Used in Multiple Places #15

Closed bepstein111 closed 6 months ago

bepstein111 commented 6 months ago

Unsure if this is a bug that ESPHome introduced, but when I went to update my sniffer with a new version, it complained that "Pin 4 is used in multiple places," both in as a gpio switch and as the backlight pin for the st7789v. Are you aware of this?

Ralphy140 commented 6 months ago

This is a new feature to stop misconfiguration where you reuse a pin by accident, It seems that this might be an edge case they have not captured in the feature release of 2023.12

Ralphy140 commented 6 months ago

Seems like someone has lodged a bug for this and the answer is to add Add "allow_other_uses: true"

I have not updated to 2023.12 yet but I would suggest adding it to the switch and see what happens

Ralphy140 commented 6 months ago

switch:

bepstein111 commented 6 months ago

[allow_other_uses] is an invalid option for [switch.gpio]. Please check the indentation.

hmmmm

Ralphy140 commented 6 months ago

Ok had a play, The code needs to be updated as following

switch:
  - platform: gpio
    pin: 
      number: GPIO4
      allow_other_uses: true
    name: "${upper_devicename} Backlight"
    id: backlight
    restore_mode: ALWAYS_ON

and


    backlight_pin:
      number: GPIO4
      allow_other_uses: true
Ralphy140 commented 6 months ago

This will need to be rolled into the main code by @kylemanna going forward

bepstein111 commented 6 months ago

Yep, just figured this out myself, they finally seem to have added it to the documentation. For reference: https://esphome.io/guides/configuration-types.html?highlight=allow_other_uses#pin-schema

bepstein111 commented 6 months ago

I'll throw a pull request together.