Hi everyone first time posting here. Started transitioning a couple days ago from another platform to Home Assistant. With many trials and errors i’m mostly done. I’m having trouble with an automation though, possibly needing 2 automations to achieve what I’m looking for.
Here is what I’m trying to do.
If any of the 3 doors in my garage open I want them to trigger the light switch on. Here is what I have for names.
Garage door 1 - binary_sensor.main_garage_door_sensor
Garage door 2 - binary_sensor.3rd_stall_door_sensor
Garage door 3 - sensor.garage_entry_status
After all 3 doors have been closed for at least 15 minutes I want the light switch to turn off.
The switch name is - light.garage_lights
If anyone can help me achieve this I’d be really grateful. I don’t want to have to go back to the old system.
Hi, I’m a complete noob, but I have had great success with NodeRed. I have an insanely over engineered setup for 2 window AC units as my initial project.
With that said, I think this would be a total breeze in NodeRed. Basically you can check the current status of each garage door, and decide to turn the light on or off.
If you are interested, take a look at getting it installed via the add-on store, it integrates very nicely.
I assume the binary sensors will be “on” when the corresponding door is open and “off” when closed. That’s the typical meaning.
But what about sensor.garage_entry_status? How does it indicate when the door is open & closed?
The easiest way to do this is to use two automations.
The first would trigger on any of the sensors changing to “open” and would turn on the light.
The second would use a template trigger that fires when all of the doors are closed with a “for” option that makes sure it has been that way for 15 minutes.
I’d do this in 2 parts:
1 automation that triggers when doors open
1 automation that triggers when doors close
1 script that waits for 15 min and switches the light off.
Automations:
alias: Garage - Door Opens
trigger:
- platform: state
entity_id: binary_sensor.main_garage_door_sensor, binary_sensor.3rd_stall_door_sensor, sensor.garage_entry_status
to: "on"
condition:
- condition: state
entity_id: light.garage_lights
state: 'off'
action:
- service: script.turn_off
data:
entity_id: script.garage_lights_timed_off
- service: light.turn_on
data:
entity_id: light.garage_lights
alias: Garage - Door Closes
trigger:
- platform: state
entity_id: binary_sensor.main_garage_door_sensor, binary_sensor.3rd_stall_door_sensor, sensor.garage_entry_status
to: "off"
condition:
- condition: state
entity_id: binary_sensor.main_garage_door_sensor
state: 'off'
- condition: state
entity_id: binary_sensor.3rd_stall_door_sensor
state: 'off'
- condition: state
entity_id: binary_sensor.garage_entry_status
state: 'off'
- condition: state
entity_id: light.garage_lights
state: 'on'
action:
- service: script.turn_on
data:
entity_id: script.garage_lights_timed_off
So I’m trying this code and cannot get the code to validate. I get an error Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 12).
You can only define one instance of binary_sensor
Under that (I suspect already existing) binary_sensor header in your config, just add the bit that you have under binary_sensor from above screenshot
This got my 90% of the way there. After changing a few things I was able to get it functioning the way I needed it to. I never got the script to work correctly. When it would trigger the script it would never turn the light off. I was able to solve it using some extra parameters in your automation script instead.
Absolutely, there are probably cleaner ways to do this but with my limited knowledge of this software and coding in general this is what I did to accomplish it.
automations.yaml
- id: '1596997853339'
alias: Garage - Door Opens
trigger:
- entity_id: binary_sensor.main_garage_door_sensor, binary_sensor.3rd_stall_door_sensor
platform: state
to: 'on'
- entity_id: sensor.garage_entry_door_alarm_level
platform: state
to: '255'
condition:
- condition: state
entity_id: light.garage_lights
state: 'off'
action:
- data:
entity_id: script.garage_lights_timed_off
service: script.turn_off
- data:
entity_id: light.garage_lights
service: light.turn_on
mode: single
- id: '1596997889371'
alias: Garage - Door Closes
trigger:
- entity_id: binary_sensor.main_garage_door_sensor, binary_sensor.3rd_stall_door_sensor
platform: state
to: 'off'
- entity_id: sensor.garage_entry_door_alarm_level
platform: state
to: '0'
condition:
- condition: state
entity_id: binary_sensor.main_garage_door_sensor
state: 'off'
- condition: state
entity_id: binary_sensor.3rd_stall_door_sensor
state: 'off'
- condition: state
entity_id: sensor.garage_entry_door_alarm_level
state: '0'
- condition: state
entity_id: light.garage_lights
state: 'on'
action:
- delay:
minutes: 15
- data:
entity_id: light.garage_lights
transition: 5
service: light.turn_off
mode: single
And then this one was just to have a status indicator showing open or closed instead of On/Off 0/254 etc…
sensors.yaml
- platform: template
sensors:
garage_entry_status:
friendly_name: "Garage Entry Door Status"
value_template: '{% if is_state("sensor.garage_entry_door_alarm_level", "0") %}Closed{% else %}Open{% endif %}'
Like I said probably an ugly more complicated way of doing it but couldn’t get the other way to work properly. The script would turn the lights on but the lights would never turn off unless I manually did it.