Connecting many wired switches to the Raspberry Pi

Good Morning,

my name is Nina, and I am new to the forum. Hello everyone :slightly_smiling_face: !

I am currently trying to build Home Assistant on a Raspberry Pi, but I need some help on how to connect my light-switches: Every switch in the apartment is wired with network cable (I used network cable to be able to upgrade, if I wanted to. For now I just want to connect 2 of the wires of the network cable to the regular switch). All of these cables exit the wall where my Raspberry is going to be.

My problem is, that I have about 30 switches in the apartment, and I don’t know how to “input” all these into the Raspberry Pi. I hope, anyone could point me in the right direction. I sure tried searching, but whenever I put anything related to “network” or “switch”, I get results for network-switches :roll_eyes:

I have found and looked into “GPIO-Expander” so far, am I on a good path? Or is there any better way?

Thanks in advance and kind regards
Nina

GPIO-Expander is the right way. But I not recommend use it direct with raspberry. When your host shutdown, it was trigger all the light. Instead of, I recommend use a esp8566, esp32 with gpio expander and esphome to connect with hassio. See the link MCP230xx I/O Expander — ESPHome

Hello HTM,

thanks for your reply! May I ask, what do you mean by “host shutdown”? A power failure?

Nina

In case hassio is restart to update new version, or you chance the config and must have to restart hassio, etc…

Since you’re using network cable, your light switches seem to control some other switching device since you cannot run high voltages over a network cable.

Do you know what sits between your wall switches and your lights?

Hello HTM,

I see. Thank you!

Nina

Hello Nick,

let me try to show you my plan:

  1. Dumb Switch on the wall. Same as quickly connecting the 2 wires
  2. The 2 wires are part of a standard cat-6 cable. So I have 8 wires per cable. Just using that would allow me to use one as GND and have 7 individual switches
  3. This needs to “somehow go into the Raspberry” :D. If it were only one cable (with 7 independent switches) I’d manage, but it will be way more than that
  4. On the Raspberry I am running Home Assistant. The raspberry is connected to several Arduinos via Ethernet. A press on the switch is registered by the Raspberry and sent over the network via MQTT
  5. The MQTT-Message is received by one of the Arduinos, who will then
  6. Control an RGB-Strip (12V)

Does that make sense?

Nina

Hi nina

Is this is an existing building/installation?

Traditionally, you have your typical lightswitch that goes to the light and fuse-box.
If it’s in an existing installation/building: what are you doing with these?
You will have 7 switches on that same spot: is this useful/needed?

I thought that a traditional electricity setup in a house is not suitable to change it so you can control lights from your fuse-box.
Just to make sure that you do things that will not work.

Hello Nick,

it is a new building, and none of the light switches have traditional wiring. Just cat-6-cable. So I have to find a way to make it work… :smiley:

Nina

So it’s a new building with existing wiring and the light switches don’t control the lights directly but some other component which control the lights?

Hello Nick,

sorry for the delay. There is no existing “traditional” wiring, the only wiring from the switches is the ethernet cable. All these ethernet cables come together where the “Home Assistant Raspberry” is going to be.

Does that make sense? Kind regards

Nina

Ok, now I understand.

So do you have multiple switches together at the same spot to be able to use multiple pairs from the same UTP cable?
Will you have enough ports to control everything?

Hello Nick,

yes, exactly. Every switch will have 2 individual buttons for now, but I would be able to upgrade if I needed to. All together there are 10 switches (10 ethernet cables going back to the Raspberry) with 20 buttons.

What do you mean by “ports”?

Nina

Ok, now it’s getting more clear… :innocent:
Was it this way done by request, are you the first owner?

Are you aware of the issues when using SD cards in a RPi and HA?

I meant enough pairs of pins for the amount of lightswitches that you intend to use.

Yes, it’s bit complicated. :smiley: I am building a tiny shed and I did it myself. I was always certain I wanted a raspberry to take care of all my lights and sensors.

I am planning to use the Raspberry with an SSD, because I know the card is going to fail eventually. That’s what you meant, right?

What do you mean by “I meant enough pairs of pins for the amount of lightswitches that you intend to use.”?

Thanks
Nina

Hi Nina, can I go a bit off-topic here ?
In trying to connect a microphone/speaker to my RasPi running HA, I discovered that the standard HA OS installation mode is intended to be run as a server and NOT have hardware directly connected.
Using a separate machine (whether a second RasPi, or the esp32 mentioned by HTM above) as GPIO interface is probably the easier approach … and allows you to easily upgrade your HA server hardware later if desired.

I hope it all goes smoothly for you.

Hello Don,

thank you so much for that advice. So that would mean “wasting” the general I/O ports on the “Server-Raspberry”?

I would love to be able to buy a device with ~ 100 I/O’s and an ethernet port : )

Nina

My interpretation is that HA is trying to be all things to all people. And its totally understandable that they prefer to put their personal time into developing the stuff that interests them, rather than writing thorough user documentation.

At the same time, HA OS has the goal to be a standard configuration easy to install and use on almost any hardware. It is neatly packaged into a closed environment which minimizes the possibility of interactions from other software or hardware on the same computer.

The other installation options allow much more control - but require much more technical expertise from the user, who takes full responsibility. Personally (despite 30 years commercial applications programming but new to linux and HA) I have been feeling swamped trying to learn the basics, so opted to use a second RasPi (which I already had) rather than figure out how to install the microphone/speaker drivers on my RasPi HA server.

The RasPi’s GPIO certainly attracted me to it years back - but I think its low price, low power consumption and linux base make it a good choice for a HA sever, even without using the GPIO.

Since HA OS doesn’t have any hardware requirements, if you have an older PC you could re-purpose … you could consider running HA OS on the PC, and use your RasPi with GPIO extender(s) for the physical interfacing which it is great at. That’s what I love (and sometimes hate) about IT - there’s always more than one way to achieve the objective :wink: