Raspberry Pi GPIO switching

Hi,

Hope someone can point me in the right direction.

I have hass running on a Pi model B, with a 8 channel relay connected,
but I have no idea how to get switches to show on the webpage.

I’ve added the following to the configuration.yaml and when hass starts,
all the relays switch to open, so I must be on the right track?

switch:
  platform: rpi_gpio
  ports:
    4: GPIO4
    7: GPIO7
    8: GPIO8
    9: GPIO9
    10: GPIO10
    11: GPIO11
    17: GPIO17
    18: GPIO18
  invert_logic: false

What am I missing?

Thanks in advance!

Turns out I wasn’t correctly shutting down the hass service, so any changes I made wasn’t showing until I restarted the Pi.

Next question. How do I switch multiple GPIO’s from one switch/button?

So, one button that I can add multiple GPIO’s to that also shows that they’ve been toggled on/off.

If you create a group it will trigger all the switches at once.

1 Like

I’ve played around with that, but didn’t get the desired effect.

Setting up as groups I get this http://i.imgur.com/2YY8eei.png and what I want is something more like this http://i.imgur.com/vFiUNtD.png

Ok, so you need to put groups inside of groups.

group:
  Speakers 1:
    entities:
      - switch.gpio4
      - switch.gpio7

  Speakers 2:
    entities:
      - switch.gpio8
      - switch.gpio9

The above will group your switches and if added to the front end they will show up as a card with each switch listed (like your first picture).

  Speaker Control:
    entities: 
      - group.speakers_1
      - group.speakers_2

That group when added to the front end will give you a card named speaker control with only two switches (like your second picture). Those switches when activated will trigger all the switches in a listed group.

Keep in mind that if any of the switches inside the group are on, the group switch will show as on. Also my naming isn’t correct above. You will have to get your entity IDs entered correctly but the premise is there.

Hope that helps.

I first thought it would be easy by setting up each GPIO in a scene and then activate the scene but i don’t think that would allow you to shut them off. I now think you need to create a dummy switch for each room and then automate the gpio switches to follow the dummy switch.

I don’t think they have dummy switches in HA but you can use a unused GPIO. Something like

switch:
  platform: rpi_gpio
  ports:
    1: Lounge Speakers
    2: Bedroom Speakers
    3: Study Speakers
    4: GPIO4
    7: GPIO7
    8: GPIO8

then put in a automation to have the gpio switches follow the dummy room switches. Then put the dummy room switches in a group.

Thank you! This worked!

Just had to also hide the individual switch.gpio components in customize.yaml to not show the extra groups.