Hi, still new to this game but I am having trouble trying to get the reed sensors to change the status of the door to open or closed when the magnetism energise s(closed door) or deenergises (open door).
Everything you have looks pretty good, except you don’t specify a value for invert of your binary sensor.
For the shelly 1, the pins are the opposite
substitutions:
friendly_name: garage3
esphome:
name: garage3
platform: ESP8266
board: esp01_1m
# The door contact sensor that is attached to SW on the
# Shelly 1. Not exposed to HA, instead used to set the
# state of the cover.
binary_sensor:
- platform: gpio
pin: GPIO5
name: $friendly_name Contact Sensor
id: contact_sensor
internal: false
filters:
- invert:
# The relay in the Shelly 1 that will deliver the pulse to
# the gate opener (not exposed to HA)
switch:
- platform: gpio
pin: GPIO4
name: $friendly_name Relay
id: relay
internal: true
# This part allows remote reset of the device
- platform: restart
name: $friendly_name Relay Reset
id: restart_switch
# This creates the actual gate in HA. The state is based
# on the contact sensor. Opening/closing the gate simply
# turns the relay on/off with a 0.5s delay in between.
cover:
- platform: template
device_class: garage
name: HoonTune Farm $friendly_name
id: template_cov
lambda: |-
if (id(contact_sensor).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
close_action:
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
stop_action:
- switch.turn_on: relay
- delay: 0.5s
- switch.turn_off: relay
I am still new also, but a possible problem could be the way the reed switch is connected.
Is the pin pulled to vcc or ground when the reed switch is near a magnet? Does the pin have a pull-up or pull-down resistor set? I normal set a pull-up on the pin and then have the reed switch pull the pin to ground when the magnet is near it.
The board you are using does not have internal software enabled pull-up/down resistors, so you have to use physical resistors, the value is not that important, any value between 10K Ohm to 100K Ohm will do.
You have two options for wiring the switches, using a pull up or a pull down resistor:
Reed switches are normally closed (not open as shown in the diagrams). And binary sensors turn on when the GPIO has 3.3V on it. So you most likely want Option 1. Though the option you choose isn’t that important. If you find you have chosen the wrong one you can easily invert the signal in software.