Raspberry PI GPIO Switch, applying individual GPIO inverted logic

HI,

Using the https://home-assistant.io/components/switch.rpi_gpio/
It appears the Inverted_Logic function is a global function and applies to all switches, is it possible to apply the inverted logic on an individual pin basis? IE Harwdare logic that I’m driving has a combination of GPIOs with some pins active high and other are active low.

Thanks in advance,

Rob.

did you try grouping the switch I never tried it my self but I think it might work

Thanks, will give it a go.

Hi, i have the same issue. Have you solve? How?

Hi Stefan,

No I didn’t, wasn’t a huge issue from my end, most of the switches are an automated process.

Maybe a Dev. request??

Rob.

I have the same issue. I have one Relay I want to keep NC, so if the rPi goes offline or reboots or whatever, there is power flowing through the relay. The other relays need to stay NO, so I cant invert_logic on all the GPIO pins. Maybe there is a hardware workaround? It just bothers me that my HA GUI says the switch is ‘off’ and it’s actually ‘on’, and vise-versa. There is got to be a relatively painless way to do this. It seems so simple.

Hrm. Just had a thought. Maybe using a switch template! I’ll give that a go.

I have the same challenge. I know I can use template, but having possibility to manage it on the configuration level will be much cleaner and “one-entity-less”…
I believe each pin should be able to be configured as inverted. Also the option for pull-up or pull-down should be possible to select by each GPIO. Checking raspberry documentation I found this one https://www.raspberrypi.org/documentation/configuration/config-txt/gpio.md where it seems possible to change some options for each GPIO (unfortunately there is no command for inverted logic).

I found solution here: Switch.rpi_gpio: how to invert_logic for only some of the ports?
It works for me!

Hi,

Stand to be corrected but believe this doesn’t resolve the issue of setting a individual pin to either invert or not.
The link is an example of a global setting for all the pins you nominated to invert in - platform: rpi_gpio . You can’t then nominate another group of pins to not invert.

1 Like

Well… the way I used it is to repeat the -platform: rpi_gpio section to group inverted and not inverted ports, like this:

  - platform: rpi_gpio
    invert_logic: true
    ports:
      4: IrrigationBalcony
      27: IrrigationLivingRoom

  - platform: rpi_gpio
    invert_logic: false
    ports:
      2: Radiator

This works for me.

2 Likes

This works also with remote_rpi_gpio. Thank you very much