Home Assistant Community

Help with geting GPIO to work on RPi 3+

#1

Hello I installed hass.io on my Raspberry Pi 3 using the 32-bit version 2.10 image. I have successfully gotten it to work and control zwave devices with a Zwave usb dongle I bought.

Next, I would like to control a buzzer lock with a relay controlled by the gpio pins on the raspberry pi. I am trying to follow the documentation at https://www.home-assistant.io/components/rpi_gpio/ I have added entries to my configuration.yaml file and restarted the system, but none of my custom defined gpio switches appear in the web ui. All my zwave switches appear and work fine. Is there something else I need to do to get the switches to appear in the web ui?

What I really want to do is have a button in my web UI that would activate a gpio pin for 3 seconds and then shut off. This would activate a buzzer lock and give you 3 seconds to push open the door before it unlocks. It seems the “cover” option has a relay_time that could do this, although I have no need for a state_pin so just picked a dummy pin.

This is currently what my configuration.yaml looks like. I tried to create a dummy rpio switch as a test too. But I just can’t seem to get anything to show up in the web ui with this configuration.

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 42.0738
  longitude: -80.1484
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  # metric for Metric, imperial for Imperial
  unit_system: imperial
  time_zone: America/New_York
  # Customization file
  customize: !include customize.yaml

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
#http:
#  base_url: hassio:8123

api:

# Sensors
sensor:
  # Weather prediction
  - platform: yr

# Text to speech
tts:
  - platform: google_translate
    service_name: google_say

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

rpi_gpio:

switch:
  - platform: rpi_gpio
    ports:
      13: GPIOTestSwitch

cover:
  - platform: rpi_gpio
    relay_time: 3.1
    invert_relay: false
    state_pull_mode: 'UP'
    invert_state: true
    covers:
      - relay_pin: 11
        state_pin: 12
        name: 'Buzzer Lock'
#2

Remove this:

rpi_gpio:

Restart.

Have a look at the developer tools states page. Is the switch there?

#3

I removed the line you suggested and rebooted, but unfortunately it still doesn’t appear on the home screen or on the developers states page. Any other ideas?

#4

What is this in your config?

api:

Do you have any errors in your log?

#5

I believe the “api:” entry was one of the steps I had to do to get the REST API working https://developers.home-assistant.io/docs/en/external_api_rest.html It let’s me send external commands to the raspberry pi from external servers, which is working fine.

Where would I find the log you want to see? If its in the web interface under Hass.io --> System --> System log, then this is what I see, nothing seems out of the ordinary to me:

19-05-14 10:12:28 INFO (MainThread) [hassio.updater] Fetch update data from https://s3.amazonaws.com/hassio-version/stable.json
19-05-14 10:12:28 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/home-assistant/hassio-addons repository
19-05-14 10:12:28 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/hassio-addons/repository repository
19-05-14 10:12:29 INFO (MainThread) [hassio.store] Load add-ons from store: 59 all - 0 new - 0 remove
19-05-14 14:02:44 INFO (MainThread) [hassio.homeassistant] Update Home Assistant to version 0.92.2
19-05-14 14:02:44 INFO (SyncWorker_4) [hassio.docker.interface] Update image homeassistant/raspberrypi3-homeassistant:0.89.1 to homeassistant/raspberrypi3-homeassistant:0.92.2
19-05-14 14:02:44 INFO (SyncWorker_4) [hassio.docker.interface] Pull image homeassistant/raspberrypi3-homeassistant tag 0.92.2.
19-05-14 14:13:00 INFO (SyncWorker_4) [hassio.docker.interface] Tag image homeassistant/raspberrypi3-homeassistant with version 0.92.2 as latest
19-05-14 14:13:00 INFO (SyncWorker_4) [hassio.docker.interface] Stop homeassistant application
19-05-14 14:14:01 INFO (SyncWorker_4) [hassio.docker.interface] Clean homeassistant application
19-05-14 14:14:01 INFO (SyncWorker_4) [hassio.docker.interface] Cleanup images: ['homeassistant/raspberrypi3-homeassistant:0.89.1']
19-05-14 14:14:58 INFO (SyncWorker_19) [hassio.docker.homeassistant] Start homeassistant homeassistant/raspberrypi3-homeassistant with version 0.92.2
19-05-14 14:15:23 INFO (MainThread) [hassio.homeassistant] Detect a running Home Assistant instance
19-05-14 14:15:23 INFO (MainThread) [hassio.homeassistant] Successful run Home Assistant 0.92.2
19-05-14 14:23:09 INFO (MainThread) [hassio.homeassistant] Updated Home Assistant API token
19-05-14 14:24:58 INFO (SyncWorker_11) [hassio.docker.interface] Clean addon_core_ssh application
19-05-14 14:25:03 INFO (SyncWorker_11) [hassio.docker.addon] Start Docker add-on homeassistant/armv7-addon-ssh with version 5.2
19-05-14 14:34:07 INFO (SyncWorker_16) [hassio.docker.interface] Clean addon_core_ssh application
19-05-14 14:34:18 INFO (SyncWorker_16) [hassio.docker.addon] Start Docker add-on homeassistant/armv7-addon-ssh with version 5.2
19-05-14 14:47:25 INFO (SyncWorker_11) [hassio.docker.interface] Clean addon_core_ssh application
19-05-14 14:47:28 INFO (SyncWorker_11) [hassio.docker.addon] Start Docker add-on homeassistant/armv7-addon-ssh with version 5.2
19-05-14 16:12:28 INFO (MainThread) [hassio.updater] Fetch update data from https://s3.amazonaws.com/hassio-version/stable.json
19-05-14 16:12:28 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/hassio-addons/repository repository
19-05-14 16:12:28 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/home-assistant/hassio-addons repository
19-05-14 16:12:30 INFO (MainThread) [hassio.store] Load add-ons from store: 59 all - 0 new - 0 remove
19-05-14 22:12:28 INFO (MainThread) [hassio.updater] Fetch update data from https://s3.amazonaws.com/hassio-version/stable.json
19-05-14 22:12:28 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/home-assistant/hassio-addons repository
19-05-14 22:12:28 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/hassio-addons/repository repository
19-05-14 22:12:29 INFO (MainThread) [hassio.store] Load add-ons from store: 59 all - 0 new - 0 remove
19-05-15 00:12:28 INFO (MainThread) [hassio.snapshots] Found 0 snapshot files
19-05-15 00:12:28 INFO (MainThread) [hassio.host.info] Update local host information
19-05-15 00:12:28 INFO (MainThread) [hassio.utils.gdbus] Call org.freedesktop.DBus.Properties.GetAll on /org/freedesktop/hostname1
19-05-15 00:12:29 INFO (MainThread) [hassio.host.services] Update service information
19-05-15 00:12:29 INFO (MainThread) [hassio.utils.gdbus] Call org.freedesktop.systemd1.Manager.ListUnits on /org/freedesktop/systemd1
19-05-15 02:06:16 INFO (SyncWorker_16) [hassio.docker.interface] Clean addon_core_ssh application
19-05-15 02:06:25 INFO (SyncWorker_16) [hassio.docker.addon] Start Docker add-on homeassistant/armv7-addon-ssh with version 5.2
#6

That’s the system log. Look for a little (i) button lower left. Or (because it is an absolute pain to try and copy from that) look in /config/home-assistant.log

#7

Here’s the log. The first 3 errors from 5-14 are when I believe I first started playing with the config trying to get the gpio pins working and I made some typos. I since fixed those with the config file I posted above Not sure what the other errors are.

2019-05-14 10:15:15 ERROR (MainThread) [homeassistant.setup] Setup failed for introduction: Integration not found.
2019-05-14 10:15:15 ERROR (MainThread) [homeassistant.setup] Setup failed for conver: Integration not found.
2019-05-14 10:15:16 ERROR (MainThread) [homeassistant.components.device_tracker] Unable to load /config/known_devices.yaml: Config file not found: /config/known_devices.yaml
2019-05-14 11:15:13 ERROR (MainThread) [homeassistant.components.updater] Got unexpected response: None
2019-05-15 07:00:39 WARNING (zeroconf-Engine) [zeroconf] Choked at offset 106 while unpacking b'\x00\x00\x84\x00\x00\x00\x00\x04\x00\x00\x00\x01\x00\x00\x0c\x00\x01\x00\x00\x01,\x00\x04\x02\x880\x00\x02\x880\x00\x00!\x80\x01\x00\x00\x01,\x00\x0b\xf3\x08\x80\xef\xf3\t\x03\x81rF\x00\x07MyQ-14C\x05local\x00\x00\x01\x80\x01\x00\x00\x01,\x00\x04\xc0\xa8\x00j\x02\x880\x00\x00/\x80\x01\x00\x00\x01,\x00\x0b\x02\x880\x00\x00\x05\x00\x08\x00\[email protected]'
2019-05-15 07:00:39 WARNING (zeroconf-Engine) [zeroconf] Exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/zeroconf.py", line 656, in __init__
    self.read_others()
  File "/usr/local/lib/python3.7/site-packages/zeroconf.py", line 709, in read_others
    domain = self.read_name()
  File "/usr/local/lib/python3.7/site-packages/zeroconf.py", line 763, in read_name
    length = self.data[off]
IndexError: index out of range
2019-05-15 11:15:13 ERROR (MainThread) [homeassistant.components.updater] Got unexpected response: None
#8

Unrelated to GPIO but fix these first:

  1. remove introduction: from your config.yam file. This is no longer supported
  2. remove conver: or replace it with cover: if it is a typo. I had a bit of a search and could find no such integration.
  3. there seems to be something wrong with discovery.
  4. Do a config check, restart HA (if it passes) and post the log again.
#9

I actually already did steps 1 and 2 yesterday already right after I made that typo, those log entries were an old error.

But I just ran an update that updated my HassOS 2.10 to HassOS 2.12 and after it reboot, my custom GPIO switches were all there! So I’m not sure if it was a bug in version 2.10 or not, but looks like I’m good to go now. Thanks for your help.

1 Like