If you insist so much you can check history of your switch and see from there can you determine was switch manually turned on/off or not. Based on that you can maybe do something about it.
Or just buy presence sensor.
You have not said that a presence sensor will actually do what I want, yet you seem adamant that I should buy one - sorry, but this confuses me.
I donāt think a presence sensor is appropriate for this situation - the light is outside on my front porch and so is the motion sensor. I want the light to turn on if a car comes into my driveway, an animal runs across my porch etc.
You could explain it. I thought that you are talking about indoor situations.
I think I have this figured out. I found enkama/hass-variables and use it to set a binary sensor that I can test to determine if the light had been turned on by automation. I now have two automations and initial tests look promising. Any feedback appreciated.
alias: Front Porch Sensor Light - on
description: Turn on front porch light if motion detected
triggers:
- entity_id: binary_sensor.node_2_motion_detection
to: "on"
trigger: state
conditions:
- condition: sun
before: sunrise
after: sunset
- condition: state
entity_id: light.front_porch_light_switch
state: "off"
actions:
- target:
entity_id: light.front_porch_light_switch
action: light.turn_on
data: {}
- target:
entity_id: binary_sensor.bsw01
data:
value: "true"
action: variable.update_binary_sensor
mode: single
alias: Front Porch Sensor Light - off
description: >-
Turn off front porch light if no motion detected and it was turned on by
automation
triggers:
- entity_id: binary_sensor.node_2_motion_detection
to: "off"
for:
minutes: 2
trigger: state
conditions:
- condition: sun
before: sunrise
after: sunset
- condition: state
entity_id: light.front_porch_light_switch
state: "on"
- condition: state
entity_id: binary_sensor.bsw01
state: "on"
actions:
- target:
entity_id: light.front_porch_light_switch
action: light.turn_off
data: {}
- target:
entity_id: binary_sensor.bsw01
data:
value: "false"
action: variable.update_binary_sensor
mode: single
Edit: while re-reading my post to check for typos I found my first update - Iām going to remove the āsunā condition from the āoffā automation. Itās not needed and thereās a very small chance the āonā automation will be triggered 1 minute before sunrise and the light would then stay on all day.
This automation is awesome. It works even if you have a smart switch in the room.
Simple and efficient!
You donāt even need the helper used in the condition.
Since you use 2 automations, why not programmatically en-/dis-able the motion automation, when using the switch,
Probably because you will have to make template sensor that will determine did you turn light switch manually on/off. It is probably possible but not that easy to do.
Itās taken me a while to get my head around what you might be suggesting here and once I figured it out I realised that @ddaniel is replying to your suggestion and heās right.
My whole setup, for this scenario, is one simple smart switch (Zooz ZEN71), one motion sensor (Zooz ZSE70) and one dumb exterior flood light. If I en/disable the automation when the switch is used I canāt, easily, determine if the switch was used physically, manually through the Home Assistant app or automatically through this automation. As far as I can see the same on/off state change happens in each of these situations.
I didnāt take that into considerationā¦it was not part of the original request.
But ofc, you are right