New Esphome / Hass user. I’ve been building wacky DIY devices in my garage with cheap Banggood parts to stave off the mounting insanity. It went okay.
I had great success building cover templates for my left and right garage doors, and, inspired, I set about to build a “Red Light / Green Light” sensor using LED’s (with 330 ohm resistors) inside ping-pong diffusers. The idea is that, as I back the car up into the garage, the proximity sensor on the back wall sends data to another esp32 device on the front (outside) wall, where I’ve got my door open/shut sensors (working great) and this wacky Red/Green led light contraption. When I’m “in position,” the green light will turn on. When I’m not there yet, or too close, it’ll be red. Eventually I have plans to use flashing frequency to indicate how close I am, but let’s not rush into anything just yet. I’ll be pleased as punch if I can just turn the darned things on and off with the sensor.
The red/green LED lights work fine when I control them through Lovelace. They don’t look anywhere near as cool as they do online. Don’t cheap out on those ping pong balls, folks.
The conditions on the proximity sensor are firing correctly - I can see periodic “The car is in position” or “The car is too close or too far” messages in my logs for the door_opener device (that sits on the back wall, connected to the garage door switches, and the proximity sensor).
However, no matter what I do, I cannot manage to turn_on the red/green LED lights from my automation, although I’m quite sure things work right up until that exact moment. I’m clearly missing out on something, and I’m hoping some kind soul here can set me right.
Here goes:
door_sensor device - PIR sensor, left/right door sensors, Red / Green LED’s
binary_sensor:
# The sensor to detect the state of the door (not exposed to ha)
- platform: gpio
pin:
number: GPIO19
mode: INPUT_PULLUP
id: garage_sensor_left
name: "Garage Door Sensor Left"
filters:
- delayed_off: 50ms
- platform: gpio
pin:
number: GPIO18
mode: INPUT_PULLUP
id: garage_sensor_right
name: "Garage Door Sensor Right"
filters:
- delayed_off: 50ms
- platform: gpio
pin: GPIO23
name: "Garage PIR Sensor"
device_class: motion
sensor:
- platform: homeassistant
id: ha_car_sensor
name: "Car Sensor"
entity_id: sensor.car_sensor
output:
- platform: ledc
pin: GPIO22
id: garage_redlight
- platform: ledc
pin: GPIO21
id: garage_greenlight
light:
- platform: monochromatic
id: garage_red_led_light
output: garage_redlight
name: "Garage Red Light"
default_transition_length: 0s
- platform: monochromatic
id: garage_green_led_light
output: garage_greenlight
name: "Garage Green Light"
default_transition_length: 0s
door_opener device - two-channel relay, proximity sensor
switch:
# The GPIO pin which controls the relay to toggle the garage (not exposed to ha)
- platform: gpio
pin: GPIO33
id: relay_left
restore_mode: ALWAYS_OFF
# The Switch that toggles the garage when turned on (exposed to ha)
- platform: template
name: "Left Garage Door Switch"
id: trigger_relay_left
turn_on_action:
- switch.turn_on: relay_left
- delay: 400ms
- switch.turn_off: relay_left
- platform: gpio
pin: GPIO32
internal: false
id: relay_right
restore_mode: ALWAYS_OFF
# The Switch that toggles the garage when turned on (exposed to ha)
- platform: template
name: "Right Garage Door Switch"
id: trigger_relay_right
turn_on_action:
- switch.turn_on: relay_right
- delay: 400ms
- switch.turn_off: relay_right
sensor:
- platform: ultrasonic
trigger_pin: GPIO27
echo_pin: GPIO26
name: "Car Sensor"
id: car_distance_sensor
update_interval: 0.5s
on_value:
then:
- if:
condition:
binary_sensor.is_on: ha_right_garage_door
then:
- logger.log: "The right garage door is open."
- if:
condition:
sensor.in_range:
id: car_distance_sensor
above: .80
below: .95
then:
- logger.log: "The car is in position."
- homeassistant.service:
service: light.turn_on
data:
entity_id: garage_green_led_light
- homeassistant.service:
service: light.turn_off
data:
entity_id: garage_red_led_light
else:
- logger.log: "The car is too close or too far."
- homeassistant.service:
service: light.turn_off
data:
entity_id: garage_green_led_light
- homeassistant.service:
service: light.turn_on
data:
entity_id: garage_red_led_light
else:
- logger.log: "The right garage door is closed."
- homeassistant.service:
service: light.turn_off
data:
entity_id: garage_green_led_light
- homeassistant.service:
service: light.turn_off
data:
entity_id: garage_red_led_light
binary_sensor:
- platform: homeassistant
name: "Input Boolean From Home Assistant"
entity_id: binary_sensor.garage_door_sensor_right
id: ha_right_garage_door
I’ve cobbled this together from watching others’ and so far I’ve been able to work through things, but I’m worried I’m missing something fundamental that I’ll keep spinning my wheels on if I don’t reach out to ask for help.
Here’s a logfile from door_opener:
[21:27:58][D][ultrasonic.sensor:029]: 'Car Sensor' - Got distance: 0.89 m
[21:27:58][D][sensor:092]: 'Car Sensor': Sending state 0.88580 m with 2 decimals of accuracy
[21:27:58][D][main:363]: The right garage door is open.
[21:27:58][D][main:374]: The car is in position.
[21:27:58][D][ultrasonic.sensor:029]: 'Car Sensor' - Got distance: 0.89 m
[21:27:58][D][sensor:092]: 'Car Sensor': Sending state 0.89008 m with 2 decimals of accuracy
[21:27:58][D][main:363]: The right garage door is open.
[21:27:58][D][main:374]: The car is in position.
[21:27:59][D][ultrasonic.sensor:029]: 'Car Sensor' - Got distance: 0.89 m
[21:27:59][D][sensor:092]: 'Car Sensor': Sending state 0.89043 m with 2 decimals of accuracy
[21:27:59][D][main:363]: The right garage door is open.
[21:27:59][D][main:374]: The car is in position.
It all seems good from there, except for the part where it doesn’t turn the light on.
There are some vestiges in the code of things I’d tried out but abandoned that I haven’t cleaned up yet (like the HA sensor on the door_sensor device reading the proximity). Sorry if this is a noob question or rookie mistake - I appreciate any help in advance.