Door Status

Good Afternoon,

I have home assistant installed on my Raspberry Pi3 and i would like to be able to do the following but am struggling with where to start with the code so would someone please provide a few pointers ?

I wish to have a button that shows Door Open and another button showing Door Closed and then a third and final button showing Door Status, the plan would be that when i press Door Open then GPIO pin number 3 will activate and wen Door Closed is pressed have GPIO pin number 5 activate.

Then finally i would like the button showing Door Status to somehow show the status of the door, to show if its either open or closed (Maybe just green for open and red for closed as an icon or similar. Also in order to show an accurate status i would need a door contact wired onto the door but im unsure how i would then program a GPIO pin to act as a status if that ,makes sense ?

Really have been scratching my head on this so really would appreciate someones help where possible.

Thanks in advance

This Raspberry PI GPIO Switch and Raspberry PI GPIO Binary Sensor might be what you are looking for.

Look at the GPIO Switch ans GPIO Binary Sensor components.

I currently use magnetic reed alarm switches in my windows and doors to determine when they open and close. They are wired directly to the GPIO pins on my pi.

1 Like

Thanks but how did you wire the contact ? ground and a particular pin ? ive tried the code as recommended but im still not having any joy with the code to see the status of the gpio the contact would be wired into ?

Correct. My sensors are wired to ground and a particular pin. Here’s a photo from my test run. There’s a shared ground for all 6 zones and then a numbered gpio pin for each zone individually.

ok cool, thanks, but any idea of the command to see the status of each GPIO so i can tell if its open or closed ?

binary_sensor:
  - platform: rpi_gpio
    device_class: opening
    ports:
      22: Front Door
      6: Front Windows
      27: Garage Door
      17: Back Door
      18: Back Windows
      4: Bedroom Windows

They’ll show up as binary sensors, so you can check the state just like any other component.

ok so i assume under my homescreen of home assistant i will see tabs of all windows and then an icon nect to it to show if its open or closed ?

or could it at least be an option to have all windows monitored listed and then an icon or slider next to each window to indicate if it was open or closed ?

can anyone please help ?