I’m trying to get two automations to work in latest version of HA.
I want to turn a scene on if motion is detected after 23:00:00 and then turn it off after 5 minutes.
Somehow i’m getting configuration errors in HA when saving this, help is appreciated!
Log error:
2017-08-20 14:04:14 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: [for] is an invalid option for [automation]. Check: automation->trigger->1->for. (See /home/homeassistant/.homeassistant/configuration.yaml, line 154). Please check the docs at https://home-assistant.io/components/automation/
Here’s my automations that should control it:
#lights on
- id: motion_light_natt
alias: Nattlampa_Övervåning
trigger:
- platform: state
entity_id: sensor.sn3_pir
to: 'motion detected'
- platform: time
at: '23:00:00'
action:
service: scene.turn_on
entity_id: scene.Nattlampa_On
#lights off
- id: motion_light_natt_off
alias: Nattlampa_off
trigger:
- platform: state
entity_id: sensor.sn3_pir
to: 'standby'
- platform: time
at: '23:00:00'
for:
minutes: 5
action:
service: scene.turn_on
entity_id: scene.Nattlampa_Off
Here are the scene config chapter:
- name: Nattlampa_On
entities:
switch.fonster_overvaning_dator:
state: on
switch.overvaning_balkong_fonster:
state: on
light.a_skrivbordslampa:
state: on
- name: Nattlampa_Off
entities:
switch.fonster_overvaning_dator:
state: off
switch.overvaning_balkong_fonster:
state: off
light.a_skrivbordslampa:
state: off
I do something similar, this might help. Use conditions to check whether the trigger should do anything
Automation
- alias: Lights on when motion on between midnight and sunrise
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d000113d11c
to: 'on'
condition:
condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: state
entity_id: group.lamp
state: 'off'
- condition: state
entity_id: media_player.samsung_tv_remote
state: 'off'
- condition: time
after: '00:00:00'
- condition: sun
before: sunrise
action:
- service: homeassistant.turn_on
entity_id: scene.nightlight
- alias: Nightlight off after 15 min when motion off and past 12 midnight
trigger:
- platform: state
entity_id: binary_sensor.motion_sensor_158d000113d11c
to: 'off'
for:
minutes: 15
seconds: 00
condition:
condition: and
conditions:
- condition: time
after: '00:00:00'
- condition: sun
before: sunrise
before_offset: '00:30:00'
- condition: state
entity_id: media_player.samsung_tv_remote
state: 'off'
- condition: state
entity_id: group.lamp
state: 'on'
action:
- service: homeassistant.turn_off
entity_id: group.lamp
- service: homeassistant.turn_off
entity_id: light.kitchen_main
The motion sensor has to be “on” for 5 minutes, is that what you want?
Also, with before: sunrise, it’ll only operate between midnight and sunrise. You can just drop the sunrise piece since you’re already checking if it’s below the horizon.