Hi there,
I am trying to set up my motion detector as a sort of intruder alarm. The problem is though that I don’t want it to work on a thursday between 08:30am & 11:00am.
How would I code that as a condition? Or am I going about it in the wrong way & should have an automation that turns off that automation (if that makes sense)?!?!?
This is my current code:
- id: '5'
alias: Intruder Detection
trigger:
- platform: state
entity_id: sensor.hall_motion_sensor
to: 'on'
condition:
- condition: state
entity_id: group.family
state: not_home
- condition: time
weekday:
- mon
- tue
- wed
- fri
- sat
- sun
action:
- service: notify.pushbullet
data:
message: 'ALERT! ALERT! Someone is in the hall'
target: 'device/Google Pixel 2'
- service: light.turn_on
entity_id: light.living_room
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.hall_downstairs_big_lamp
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.hall_downstairs_ceiling_light
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.outside_back_lights
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.outside_front_lights
- delay: '00:00:01'
- service: media_player.volume_set
data_template:
entity_id: media_player.master_bedroom_home
volume_level: 0.7
- service: tts.google_say
data:
entity_id: media_player.kitchen_speaker
message: "Intruder Alert! Home owner notified, security systems operational"
keithh666
(Keith Hull)
February 20, 2018, 2:23am
2
You can do mixed ‘and’ and ‘or’ conditions so yep I would do it as another or condition with an and condition of it being thursday and time after/before.
Have a look here for some inspiration
So am I right in thinking that I would need to add this condition for the automation to not be active on a Thursday between 08:30am & 11:00am:
- id: '5'
alias: Intruder Detection
trigger:
- platform: state
entity_id: sensor.hall_motion_sensor
to: 'on'
condition:
- condition: state
entity_id: group.family
state: not_home
- condition: time
before: '08:30'
after: '11:00'
weekday:
- thu
- condition: time
weekday:
- mon
- tue
- wed
- fri
- sat
- sun
action:
- service: notify.pushbullet
data:
message: 'ALERT! ALERT! Someone is in the hall'
target: 'device/Google Pixel 2'
- service: light.turn_on
entity_id: light.living_room
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.hall_downstairs_big_lamp
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.hall_downstairs_ceiling_light
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.outside_back_lights
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.outside_front_lights
- delay: '00:00:01'
- service: media_player.volume_set
data_template:
entity_id: media_player.master_bedroom_home
volume_level: 0.7
- service: tts.google_say
data:
entity_id: media_player.kitchen_speaker
message: "Intruder Alert! Home owner notified, security systems operational"
keithh666
(Keith Hull)
February 20, 2018, 2:46pm
4
You indentation look wrong to me - any list items need to indented by 2 spaces, lists are anything with a - so…
condition:
- condition: state
entity_id: group.family
state: not_home
- condition: time
before: '08:30'
after: '11:00'
weekday:
- thu
- condition: time
weekday:
- mon
- tue
- wed
- fri
- sat
- sun
action:
- service: notify.pushbullet
data:
message: 'ALERT! ALERT! Someone is in the hall'
target: 'device/Google Pixel 2'
- service: light.turn_on
entity_id: light.living_room
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.hall_downstairs_big_lamp
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.hall_downstairs_ceiling_light
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.outside_back_lights
- delay: '00:00:01'
- service: light.turn_on
entity_id: light.outside_front_lights
- delay: '00:00:01'
- service: media_player.volume_set
data_template:
entity_id: media_player.master_bedroom_home
volume_level: 0.7
- service: tts.google_say
data:
entity_id: media_player.kitchen_speaker
message: "Intruder Alert! Home owner notified, security systems operational"
2 Likes
Thanks for the indentation info - helped me solve lots of issues!