I have been using this configuration for 2 pir sensor with sonoff bridge to control the lights in bhaus sala. this is working fine but this is working 24/7. I would like to control this configuration to deactivate in a specific time of the day or when it is sunset until 11pm or 23:00. Any help on how I may go about the scheduling?
- alias: Turn on Bhaus Sala if there is movement
trigger:
- platform: state
entity_id: binary_sensor.bhaus_sala_motion, binary_sensor.bhaus_kitchen_motion
to: 'on'
action:
- service: homeassistant.turn_on
data:
entity_id:
- switch.bhaus_sala
- service: timer.start
data:
entity_id: timer.bhaussala
- alias: Turn Off Bhaus Sala 5 minutes after trigger
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.bhaussala
action:
- service: homeassistant.turn_off
data:
entity_id:
- switch.bhaus_sala
timer:
bhaussala:
duration: 00:05:00
Sorry for the newbie question @VDRainer I was actually scouring the forum for possible solutions but couldnât find one. Thanks for guiding me to the right way. And here is my config now:
- alias: Turn Off Bhaus Sala 5 minutes after trigger
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.bhaussala
condition:
condition: time
after: 23:00:00
before: 17:00:00
weekday:
- mon
- tue
- wed
- thu
- fri
- sat
- sun
action:
- service: homeassistant.turn_off
data:
entity_id:
- switch.bhaus_sala
But this is giving me an error in config check:
Invalid config for [automation]: extra keys not allowed @ data[âconditionâ][0][âafterâ]. Got None
extra keys not allowed @ data[âconditionâ][0][âbeforeâ]. Got None
not a valid value for dictionary value @ data[âconditionâ][0][âconditionâ]. Got None
required key not provided @ data[âconditionâ][0][âentity_idâ]. Got None. (See /config/configuration.yaml, line 375). Please check the docs at https://home-assistant.io/components/automation/
Hello @VDRainer, I couldnât quite grasp what you meant with
I am trying to implement from 17:00 - 23:00 even if there is no motion detected the light stays on. My old config is this:
- alias: Turn on Bhaus Sala if there is movement
trigger:
- platform: state
entity_id: binary_sensor.bhaus_sala_motion, binary_sensor.bhaus_kitchen_motion
to: 'on'
action:
- service: homeassistant.turn_on
data:
entity_id:
- switch.bhaus_sala
- service: timer.start
data:
entity_id: timer.bhaussala
- service: timer.restart
data:
entity_id: timer.bhaussala
- alias: Turn Off Bhaus Sala 5 minutes after trigger
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.bhaussala
action:
- service: homeassistant.turn_off
data:
entity_id:
- switch.bhaus_sala
timer:
bhaussala:
duration: 00:05:00
This is without the condition. Now with the conditions set, I am monitoring the timer I noticed that the timer doesnât reset to 5mins even though there is motion detected it just keeps going down until it stays in active although the light stays on but I am feeling there is something wrong here?