I have built in four actions to turn on/off my garage light.
-
During the daytime when the daytime light is below a certain level and the garage door opens the garage light will turn on. (I have included motion sensors also in here, the motion sensors work and turn the garage light on.)
-
When the garage door opens after sunset and before sunrise the garage light will turn on. (I have included motion sensors also in here, the motion sensors work and turn the garage light on.)
-
When the house door for the garage door opens and 1. the light is off 2. it is below a certain brightness the garage light will turn on
-
When no motion is detected for 10 minutes or the brightness is above a certain level the garage light will turn off.
The garage door opening does not work with #1 and #2.
alias: Garage Light On/Off
description: |-
Garage Motion Sensor Turns Garage Light On/Off
Garage Door Opens Turns Garage Light On
trigger:
- platform: state
entity_id:
- binary_sensor.garage_motion_sensor_1_occupancy
to: "on"
id: motionACTIVE
- platform: state
entity_id:
- binary_sensor.garage_motion_sensor_3_occupancy
to: "off"
id: motionINACTIVE
for:
hours: 0
minutes: 10
seconds: 0
- platform: numeric_state
entity_id:
- sensor.garage_motion_sensor_3_illuminance_lux
above: 100
id: illuminance100
- platform: state
entity_id:
- binary_sensor.garage_side_door_contact_sensor_contact
to: "on"
id: garageSIDEDOOROPEN
- platform: state
entity_id:
- binary_sensor.garage_door_sensor_1_contact
to: "on"
id: GarageOpen
- platform: state
entity_id:
- binary_sensor.garage_motion_sensor_3_occupancy
to: "on"
id: motionACTIVE3
- platform: state
entity_id:
- binary_sensor.garage_entryway_contact_door_sensor_contact
to: "on"
id: garageENTRYWAYOPEN
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- garageENTRYWAYOPEN
- condition: numeric_state
entity_id: sensor.garage_motion_sensor_3_illuminance_lux
below: 100
sequence:
- if:
- condition: state
entity_id: light.garage_light_switch
state: "off"
then:
- service: light.turn_on
target:
entity_id: light.garage_light_switch
data: {}
- conditions:
- condition: trigger
id:
- motionACTIVE
- GarageOpen
- garageSIDEDOOROPEN
- motionACTIVE3
- condition: time
after: sensor.sun_next_setting
before: sensor.sun_next_rising
sequence:
- service: light.turn_on
target:
entity_id: light.garage_light_switch
data: {}
- conditions:
- condition: trigger
id:
- motionACTIVE
- GarageOpen
- garageSIDEDOOROPEN
- motionACTIVE3
- condition: numeric_state
entity_id: sensor.garage_motion_sensor_3_illuminance_lux
below: 50
sequence:
- service: light.turn_on
target:
entity_id: light.garage_light_switch
data: {}
- conditions:
- condition: trigger
id:
- motionINACTIVE
- illuminance100
sequence:
- service: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.garage_light_switch
mode: restart
{
"trace": {
"last_step": "action/0/choose/0/sequence/0/if/condition/0/entity_id/0",
"run_id": "72f933d53ca056960fec0c6bf57a1484",
"state": "stopped",
"script_execution": "finished",
"timestamp": {
"start": "2024-05-29T23:12:20.261962+00:00",
"finish": "2024-05-29T23:12:20.284129+00:00"
},
"domain": "automation",
"item_id": "1711250201299",
"trigger": "state of binary_sensor.garage_entryway_contact_door_sensor_contact",
"trace": {
"trigger/6": [
{
"path": "trigger/6",
"timestamp": "2024-05-29T23:12:20.262539+00:00",
"changed_variables": {
"this": {
"entity_id": "automation.garage_motion_sensor_garage_light_on_off",
"state": "on",
"attributes": {
"id": "1711250201299",
"last_triggered": "2024-05-29T23:12:15.696455+00:00",
"mode": "restart",
"current": 0,
"friendly_name": "Garage Light On/Off"
},
"last_changed": "2024-05-29T12:56:11.764925+00:00",
"last_updated": "2024-05-29T23:12:15.747146+00:00",
"context": {
"id": "01HZ3A09TETRKVQW3ED1038DNV",
"parent_id": "01HZ3A09T58RZMP7BWP7HMR7RH",
"user_id": null
}
},
"trigger": {
"id": "garageENTRYWAYOPEN",
"idx": "6",
"alias": null,
"platform": "state",
"entity_id": "binary_sensor.garage_entryway_contact_door_sensor_contact",
"from_state": {
"entity_id": "binary_sensor.garage_entryway_contact_door_sensor_contact",
"state": "off",
"attributes": {
"device_class": "door",
"friendly_name": "Garage Entryway Contact Door Sensor Door"
},
"last_changed": "2024-05-29T22:27:17.909178+00:00",
"last_updated": "2024-05-29T22:27:17.909178+00:00",
"context": {
"id": "01HZ37DZ8N1V0M61ZGWYYMYE9S",
"parent_id": null,
"user_id": null
}
},
"to_state": {
"entity_id": "binary_sensor.garage_entryway_contact_door_sensor_contact",
"state": "on",
"attributes": {
"device_class": "door",
"friendly_name": "Garage Entryway Contact Door Sensor Door"
},
"last_changed": "2024-05-29T23:12:20.256491+00:00",
"last_updated": "2024-05-29T23:12:20.256491+00:00",
"context": {
"id": "01HZ3A0E90DJDSE6XR1GTYZZAR",
"parent_id": null,
"user_id": null
}
},
"for": null,
"attribute": null,
"description": "state of binary_sensor.garage_entryway_contact_door_sensor_contact"
}
}
}
],
"action/0": [
{
"path": "action/0",
"timestamp": "2024-05-29T23:12:20.273224+00:00",
"changed_variables": {
"context": {
"id": "01HZ3A0E95D70CRYDHE8NFTE5R",
"parent_id": "01HZ3A0E90DJDSE6XR1GTYZZAR",
"user_id": null
}
},
"result": {
"choice": 0
}
}
],
"action/0/choose/0": [
{
"path": "action/0/choose/0",
"timestamp": "2024-05-29T23:12:20.273903+00:00",
"result": {
"result": true
}
}
],
"action/0/choose/0/conditions/0": [
{
"path": "action/0/choose/0/conditions/0",
"timestamp": "2024-05-29T23:12:20.274142+00:00",
"result": {
"result": true
}
}
],
"action/0/choose/0/conditions/1": [
{
"path": "action/0/choose/0/conditions/1",
"timestamp": "2024-05-29T23:12:20.274383+00:00",
"result": {
"result": true
}
}
],
"action/0/choose/0/conditions/1/entity_id/0": [
{
"path": "action/0/choose/0/conditions/1/entity_id/0",
"timestamp": "2024-05-29T23:12:20.274499+00:00",
"result": {
"result": true,
"state": 37
}
}
],
"action/0/choose/0/sequence/0": [
{
"path": "action/0/choose/0/sequence/0",
"timestamp": "2024-05-29T23:12:20.280294+00:00"
}
],
"action/0/choose/0/sequence/0/if": [
{
"path": "action/0/choose/0/sequence/0/if",
"timestamp": "2024-05-29T23:12:20.280620+00:00",
"result": {
"result": false
}
}
],
"action/0/choose/0/sequence/0/if/condition/0": [
{
"path": "action/0/choose/0/sequence/0/if/condition/0",
"timestamp": "2024-05-29T23:12:20.280778+00:00",
"result": {
"result": false
}
}
],
"action/0/choose/0/sequence/0/if/condition/0/entity_id/0": [
{
"path": "action/0/choose/0/sequence/0/if/condition/0/entity_id/0",
"timestamp": "2024-05-29T23:12:20.280921+00:00",
"result": {
"result": false,
"state": "on",
"wanted_state": "off"
}
}
]
},
"config": {
"id": "1711250201299",
"alias": "Garage Light On/Off",
"description": "Garage Motion Sensor Turns Garage Light On/Off\nGarage Door Opens Turns Garage Light On",
"trigger": [
{
"platform": "state",
"entity_id": [
"binary_sensor.garage_motion_sensor_1_occupancy"
],
"to": "on",
"id": "motionACTIVE"
},
{
"platform": "state",
"entity_id": [
"binary_sensor.garage_motion_sensor_3_occupancy"
],
"to": "off",
"id": "motionINACTIVE",
"for": {
"hours": 0,
"minutes": 10,
"seconds": 0
}
},
{
"platform": "numeric_state",
"entity_id": [
"sensor.garage_motion_sensor_3_illuminance_lux"
],
"above": 100,
"id": "illuminance100"
},
{
"platform": "state",
"entity_id": [
"binary_sensor.garage_side_door_contact_sensor_contact"
],
"to": "on",
"id": "garageSIDEDOOROPEN"
},
{
"platform": "state",
"entity_id": [
"binary_sensor.garage_door_sensor_1_contact"
],
"to": "on",
"id": "GarageOpen"
},
{
"platform": "state",
"entity_id": [
"binary_sensor.garage_motion_sensor_3_occupancy"
],
"to": "on",
"id": "motionACTIVE3"
},
{
"platform": "state",
"entity_id": [
"binary_sensor.garage_entryway_contact_door_sensor_contact"
],
"to": "on",
"id": "garageENTRYWAYOPEN"
}
],
"condition": [],
"action": [
{
"choose": [
{
"conditions": [
{
"condition": "trigger",
"id": [
"garageENTRYWAYOPEN"
]
},
{
"condition": "numeric_state",
"entity_id": "sensor.garage_motion_sensor_3_illuminance_lux",
"below": 100
}
],
"sequence": [
{
"if": [
{
"condition": "state",
"entity_id": "light.garage_light_switch",
"state": "off"
}
],
"then": [
{
"service": "light.turn_on",
"target": {
"entity_id": "light.garage_light_switch"
},
"data": {}
}
]
}
]
},
{
"conditions": [
{
"condition": "trigger",
"id": [
"motionACTIVE",
"GarageOpen",
"garageSIDEDOOROPEN",
"motionACTIVE3"
]
},
{
"condition": "time",
"after": "sensor.sun_next_setting",
"before": "sensor.sun_next_rising"
}
],
"sequence": [
{
"service": "light.turn_on",
"target": {
"entity_id": "light.garage_light_switch"
},
"data": {}
}
]
},
{
"conditions": [
{
"condition": "trigger",
"id": [
"motionACTIVE",
"GarageOpen",
"garageSIDEDOOROPEN",
"motionACTIVE3"
]
},
{
"condition": "numeric_state",
"entity_id": "sensor.garage_motion_sensor_3_illuminance_lux",
"below": 50
}
],
"sequence": [
{
"service": "light.turn_on",
"target": {
"entity_id": "light.garage_light_switch"
},
"data": {}
}
]
},
{
"conditions": [
{
"condition": "trigger",
"id": [
"motionINACTIVE",
"illuminance100"
]
}
],
"sequence": [
{
"service": "light.turn_off",
"metadata": {},
"data": {},
"target": {
"entity_id": "light.garage_light_switch"
}
}
]
}
]
}
],
"mode": "restart"
},
"blueprint_inputs": null,
"context": {
"id": "01HZ3A0E95D70CRYDHE8NFTE5R",
"parent_id": "01HZ3A0E90DJDSE6XR1GTYZZAR",
"user_id": null
}
},
"logbookEntries": [
{
"name": "Garage Light On/Off",
"message": "triggered by state of binary_sensor.garage_entryway_contact_door_sensor_contact",
"source": "state of binary_sensor.garage_entryway_contact_door_sensor_contact",
"entity_id": "automation.garage_motion_sensor_garage_light_on_off",
"context_id": "01HZ3A0E95D70CRYDHE8NFTE5R",
"when": 1717024340.263079,
"domain": "automation"
}
]
}