genelio
(Genelio)
May 25, 2017, 3:36pm
1
Hello as usual a new guy trying to attempt the first automation.
what I am trying to do is have a zwave switch turn on for 2 hours and then off for 1 hour and then on again for 2 hours. this should happen M-F starting at 2 PM ending at 10 PM. what I’ve done so far turns the switch on but turns it right off within the minute. can someone help me figuring this out please.
alias: turn on switch after 2:00 PM
trigger:
platform: time
minutes: ‘/180’
seconds: 00
condition:
condition: time
weekday:
mon
tue
wed
thu
fri
after: ‘14:00:00’
before: ‘22:00:00’
action:
service: homeassistant.turn_on
entity_id: switch.enerwave_zw20r_20a_tr_duplex_receptacle_switch_5_0
alias: turn off switch after 2:00 PM off
trigger:
platform: time
minutes: ‘/120’
seconds: 00
condition:
condition: time
weekday:
mon
tue
wed
thu
fri
after: ‘14:00:00’
before: ‘23:00:00’
action:
service: homeassistant.turn_off
entity_id: switch.enerwave_zw20r_20a_tr_duplex_receptacle_switch_5_0
keithh666
(Keith Hull)
May 25, 2017, 5:21pm
2
alias: turn on switch after 2:00 PM
trigger:
platform: time
minutes: '/180'
seconds: 00
condition:condition: time
weekday:
mon
tue
wed
thu
fri
after: '14:00:00'
before: '22:00:00'
action:
service: homeassistant.turn_on
entity_id: switch.enerwave_zw20r_20a_tr_duplex_receptacle_switch_5_0
delay: "02:00:00"
service: homeassistant.turn_off
entity_id: switch.enerwave_zw20r_20a_tr_duplex_receptacle_switch_5_0
I would do something like that, you might want to check the formatting this is off the top of my head
genelio
(Genelio)
May 25, 2017, 6:33pm
3
hello Keithh666,
i tried what you suggested and i get the error below for the line where the first service starts.
2017-05-25 14:31:21 ERROR (MainThread) [homeassistant.bootstrap] Error loading /home/localadmin/.homeassistant/configuration.yaml: duplicate key: “service”
Make sure action is at the same indent level as trigger
keithh666
(Keith Hull)
May 25, 2017, 7:00pm
5
This is from a separate automations.yaml file…
- alias: pc_restart
trigger:
- platform: state
entity_id: input_select.pcoptions
to: "Restart"
action:
- service: shell_command.pc_restart
- delay: '00:00:05'
- service: input_select.select_option
data:
entity_id: input_select.pcoptions
option: None
You may not need the -'s if yours is in the configuration.yaml instead, you’ll still need the 2 space indentation.
genelio
(Genelio)
May 25, 2017, 7:53pm
6
Ok that did it. it is working now. thanks for getting me started. now maybe a little curve ball how would you add only if this devices are home during that same time period?
alias: turn on switch after 2:00 PM
trigger:
platform: time
minutes: ‘/180’
seconds: 00
condition:
condition: and
conditions:
condition: state
entity_id: ‘device_tracker.person’
state: ‘home’
condition: time
weekday:
mon
tue
wed
thu
fri
after: ‘14:00:00’
before: ‘22:00:00’
action:
service: homeassistant.turn_on
entity_id: switch.enerwave_zw20r_20a_tr_duplex_receptacle_switch_5_0
delay: “00:02:00”
service: homeassistant.turn_off
entity_id: switch.enerwave_zw20r_20a_tr_duplex_receptacle_switch_5_0
keithh666
(Keith Hull)
May 25, 2017, 8:17pm
7
More or less I use an input_boolean to determine if i’m home or not then use that in the condition…
- alias: 'Keith Away'
condition:
condition: state
entity_id: input_boolean.keithhome
state: 'on'
trigger:
- platform: state
entity_id: device_tracker.samsungs5wifi
state: 'not_home'
for:
minutes: 15
- platform: state
entity_id: device_tracker.samsung_s5_bt, device_tracker.workphone, device_tracker.workphonebt, device_tracker.itag
state: 'not_home'
action:
- service: homeassistant.turn_off
entity_id: input_boolean.keithhome
- alias: 'Keith Home'
condition:
condition: state
entity_id: input_boolean.keithhome
state: 'off'
trigger:
- platform: state
entity_id: device_tracker.samsungs5wifi, device_tracker.samsung_s5_bt, device_tracker.workphone, device_tracker.workphonebt, device_tracker.itag
state: 'home'
action:
service: homeassistant.turn_on
entity_id: input_boolean.keithhome
condition:
condition: state
entity_id: input_boolean.keithhome
state: 'on'
However what you have should work just as well
genelio
(Genelio)
May 25, 2017, 8:30pm
8
Keith,
Thank you very much for your assistance and for taking the time to help me out. I am sure other will benefit from this as i have.