GPIO Level changes with starting Home Assistant

Hello everyone,

I simply don’t know how to proceed further and can not find anything that solves my issue here with HA.

But step by step: I have the Core Version of HA in docker and ran the command:

docker run --init -d --restart=unless-stopped --privileged --cap-add SYS_RAWIO --device=/dev/mem -v /home/pi/hassio:/config -v /etc/localtime:/etc/localtime:ro --network=host homeassistant/raspberrypi3-homeassistant:stable

Next I sat 5 binary sensor the following way:

binary_sensor:

  • platform: rpi_gpio
    ports:
    4: “Water1”
    13: “Water 2”
    6: “Water 3”
    5: “Water 4”
    21: “Garden Light”

so far so good.

Now the weird part, I set up this config in the configuration.yaml and reboot HA and see the following (Picture 1) even that every relay on the corresponding gpio is turned off and has never been turned on

I investigated further and figured, that after a restart of the Raspberry Pi, the command raspi-gpio get delivers the following (Picture 2)

also everything alright so far, but now when I start HomeAssistant in the browser, the raspi-gpio get command delivers the following (Picture 3)

The level of the GPIO 4 changed to 1!!!, resulting in HA showing “Water 1” as turned on. But nothing has turned on, also there is no automation running or anything similar.

The only change made to the original configuration.yaml was adding the lines mentioned above.

Hope anyone can help me resolving this issue.

Thank you very much in advance.

All Best,
Martin

Do you have pull down resistors to stop the inputs floating?

If you don’t they will be susceptible to noise.

Also some GPIO pins are pulled up when the pi starts. See the “Pull” columns in this table:

Finally, the Home Assistant the GPIO input integration has (had?) issues. It often misses transitions back to the off state. I recommend you do not use it. Though this may have been fixed and you just need to adjust the bounce time.

Thank you very much for the fast reply.

What I don’t understand is, that when I don’t start HA (meaning open HA in the browser) and just run Raspberry and running whatever python code the gpio look like in picture 2.

If input floating would be the cause, than it should be already the case with the startup from the raspberry, isn’t it?

Some HA internal procedure changes the state and I guess that has something to do with the permission HA to write dev/mem?

I also changed the gpio from 4 to 26 and 14, same result!

Next I took off the cable to the gpio, but left the yaml untouched…same result: starting the raspberry shows picture 2, subsequently starting HA in the browser shows picture 3 (with nothing connected to the respective gpio)

I also installed HA freshly and configured again the yaml as already stated in my initial post, same result.

Funny part, if i delete the gpio 4 line in the yaml configure file, that behavior does no cope for the next gpio in line (gpio 13), contrary everything just works as expected but now with 4 instead of 5 binary sensors -.-

I do not really understand whats going on at the start of HA. Thank you very much in advance.

All best,
Martin