See if this makes sense.
- alias: Turn on hallway light a time
initial_state: true
trigger:
platform: state
entity_id: binary_sensor.family_motion_sensor_95
to: 'on'
condition:
- condition: time
after: '22:35:00'
before: '06:00:00'
action:
service: switch.turn_on
entity_id: switch.hallway_40
Many Thanks Coolie1101, try it tonight!
by looking at the code now, it will run between that time; regardless if it is armed or not. good! try it tonight. many thanks again
- alias: Turn on hallway light a time
initial_state: true
trigger:
platform: state
entity_id: binary_sensor.XXX
to: 'on'
condition:
condition: and
conditions:
- condition: time
after: '22:35:00'
before: '06:00:00'
- condition: state
state: 'on'
entity_id: switch.XXX
action:
service: switch.turn_on
entity_id: switch.XXX
I will try this on too.
Was there anything wrong with my original code of turning switch_hallway on at that time? it seem to be ok??
I can’t tell, you need to use the </> Preformated Text Option when posting code.
Make it easy for both of us, list your entities and there states, and what you want what to do and when.
I am in Australia and I use ` to enclosed my code; not sure it is the keyboard layout or something else; but it doesn’t seem to work like yours! what do you use to enclosed your codes?
Paste your code, ctrl A, then select </> above.
<- alias: ‘turn on Hallway at a time’
trigger:
platform: state
entity_id: switch.hallway_40
to: ‘off’
condition:
condition: time
after: ‘22:35:00’
before: ‘06:00:00’
action:
- data:
entity_id: switch.hallway_40
service: switch.turn_on>
- alias: 'turn on Hallway at a time'
trigger:
platform: state
entity_id: switch.hallway_40
to: 'off'
condition:
condition: time
after: '22:35:00'
before: '06:00:00'
action:
- data:
entity_id: switch.hallway_40
service: switch.turn_on
anything wrong with ‘turn on Hallway at a time’ code?
action:
- data:
entity_id: switch.hallway_40
service: switch.turn_on
You only need data if using a template, also check your indentation.
action:
entity_id: switch.hallway_40
service: switch.turn_on
Is “switch.hallway_40” the switch to arm the motion detector?
Hi Coolie; thanks for your help. Somehow using codes with condition after and before do not work with my HA. I finally got it working by going the long way: arming and disarming the switch.family_sensor with two automation.
###Created manually
- alias: Arm Family Sensor 2350pm
trigger:
platform: time
at: ‘23:50:00’
condition: []
action:
- service: switch.turn_on
entity_id: switch.family_motion_sensor_95
###Created manually
- alias: Disarm Family Motion 6am
trigger:
platform: time
at: ‘06:00:00’
condition: []
action:
- service: switch.turn_off
entity_id: switch.family_motion_sensor_95
###created with HA automation
- action:
- data:
entity_id: switch.golf_51
service: switch.turn_on
alias: Motion Detected Family When Armed
condition:
condition: state
entity_id: switch.family_motion_sensor_95
state: ‘on’
id: ‘1527854863058’
trigger:
- entity_id: binary_sensor.family_motion_sensor_95
from: ‘off’
platform: state
to: ‘on’
###Created manually
- alias: Arm Family Sensor 2350pm
trigger:
platform: time
at: '23:50:00'
condition: []
action:
- service: switch.turn_on
entity_id: switch.family_motion_sensor_95
###Created manually
- alias: Disarm Family Motion 6am
trigger:
platform: time
at: '06:00:00'
condition: []
action:
- service: switch.turn_off
entity_id: switch.family_motion_sensor_95
###created with HA automation
- action:
- data:
entity_id: switch.golf_51
service: switch.turn_on
alias: Motion Detected Family When Armed
condition:
condition: state
entity_id: switch.family_motion_sensor_95
state: 'on'
id: '1527854863058'
trigger:
- entity_id: binary_sensor.family_motion_sensor_95
from: 'off'
platform: state
to: 'on'
Now I will try to work out how to send me a text message in Australia!