I have a PIR sensor inside, a door sensor, and a PIR sensor outside.
Goal is when I go from inside to outside (inside PIR gets triggered AND door/sensor gets triggered) to turn OFF lamp inside and turn ON lamp outside for 2 minutes
Goal is when I go from outside to inside (outside PIR gets triggered AND door/sensor gets triggered) to turn OFF lamp outside and turn ON lamp inside
How to achieve this?
dap35
July 19, 2017, 12:50pm
2
While this doesn’t have the timer piece, it does address the inside/outside, so should get you started.
I have the same use case - no switch by the stairs coming up from the basement, so used to play blind-mans-bluff when I came home. Here is my automation. The basement sensor is gets tripped before you go up the stairs.
# Turns on lights at sunset
- alias: 'Rule 3 Welcome Home light in kitchen'
trigger:
platform: state
entity_id: binary_sensor.stairwell_motion_sensor_4_0
from: 'off'
to: 'on'
condition:
- condition: state
entity_id:…
1 Like
vladosam
(Vladimir)
July 19, 2017, 1:25pm
3
I have similar automation in my home. But i only use one motion sensor.
Maybe this could work?
- id: '1000'
alias: 'come back'
initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.door
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: 10
- condition: time
after: '16:00:00'
before: '23:00:00'
- condition: state
entity_id: binary_sensor.motion_sensor_outside
state: 'on'
action:
- service: light.turn_off
entity_id: light.outside
- service: light.turn_on
entity_id: light.inside
- delay: 00:03:00
- service: light.turn_off
entity_id: light.inside
- id: '1001'
alias: 'go out'
initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.door
from: 'off'
to: 'on'
condition:
condition: and
conditions:
- condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: 10
- condition: time
after: '16:00:00'
before: '23:00:00'
- condition: state
entity_id: binary_sensor.motion_sensor_inside
state: 'on'
action:
- service: light.turn_off
entity_id: light.inside
- service: light.turn_on
entity_id: light.outside
- delay: 00:03:00
- service: light.turn_off
entity_id: light.outside
You can delete time and sun condition.
1 Like
I tried this, but is not working. Problem is, I think, the pir sensor (which is in the condition) that has the ON (motion) value for too short period,
before i open the door (which triggers the door sensor) I think the pir sensor is back to OFF.
How to solve?
Blinkwise
(Rory Moser)
July 20, 2017, 12:47pm
5
How about just checking if it was last triggered in the last 3 mins?
Here is the code:
- condition: template
value_template: '{{(as_timestamp(now())-as_timestamp(states.<pir entity id goes here>.last_updated)) | int < 300 }}'
2 Likes
vladosam
(Vladimir)
July 20, 2017, 12:54pm
6
I think blinkwise is right about this. Test it and let us know if it works.
thanks will try. What is 300, 3 minutes? Should not be 360 (seconds)?
vladosam
(Vladimir)
July 20, 2017, 1:17pm
8
I think 300 is 5 minutes.
ops yes so is seconds? 60x3=180 60x5=300 ?
Blinkwise
(Rory Moser)
July 20, 2017, 8:27pm
11
no clue on the 300 lol. Its just what I set it as and its around 3 mins.
well then maybe is like 3:00
vladosam
(Vladimir)
July 21, 2017, 4:55am
13
as_timestamp() will convert datetime object or string to UNIX timestamp. UNIX timestamp is in seconds.
Blinkwise
(Rory Moser)
July 21, 2017, 1:27pm
14
there you have it, 300 is 5 mins then. So adjust your code accordingly. 5mins works in the application I am using it for