Trying to set up a switch using GPIO on RasPi

Hello everyone! Another question has come up!

I want to use the GPIO pins of my Raspberry Pi to send simple HIGH/LOW signals to the digital pins on my Arduino so i can run a script and do a digitalread etc etc.

So when i put the component into my config file,

switch:
  platform: rpi_gpio
  ports:
  11: Fan Office
  invert_logic: false

i got the follow in my log

16-08-08 16:27:58 homeassistant.components.switch: Error while setting up platform rpi_gpio
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 98, in _setup_platform
    discovery_info)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/switch/rpi_gpio.py", line 27, in setup_platform
    for port, name in ports.items():
AttributeError: 'NoneType' object has no attribute 'items'

Any clue as to what i should do?

Try indenting the port number properly.

switch:
  platform: rpi_gpio
  ports:
    11: Fan Office
  invert_logic: false

Port 11 is not valid
run “gpio readall” from command line. This will show gpio status and port numbering
use numbering listed under BCM for GPIO

I tried that and it gave me even more errors!

So this worked for getting rid of the error in my log file, but on the front end i still dont have a simple toggle that i thought that would give me to be able to trigger. Any suggestions?

What’s your current config?

Are you using groups?
Do they show as an Entity in State tab?(what do they show as?)

1 Like

I am using groups. Hm. Ok. ill look into that.

That worked!

I added it in a new group for various switches and then added it to the main page and voila! thanks so much!

one quick question though. What exactly is BCM?

You said in my config file i should refer to it under the ports: section as what it says under the BCM column when i do gpio readall, even though its named “gpio.7” and its physica number is “7”.

So why do i have to refer to it as its BCM number in the config file?

You do not refer to it as BCM in config.
The correct number is shown under BCM column when type “GPIO read all” in command line.
Your config was correct, just number was wrong. Maybe indent was wrong but I cannot confirm that.

So wait, in my config file under ports: i put “4” to refer to the circled GPIO pin (as shown in screenshot below).
Should it be refered to as “7” instead under ports:?

i tested it out by switching it on and off from the front end and then running “gpio readall” again and i can see it switch from “0” to “1” in the V column. so i know that by putting “4” in the config file, it switches the GPIO.7 pin high/low