I think I figured this out.
First, had to make a Template Switch by adding the following to my configuration.yaml file. The regular template just didn’t have the options I needed:
switch:
- platform: template
switches:
vs_bar_lights:
friendly_name: VS Bar Lights
unique_id: vs_bar_lights
# value_template: "{{ is_state('switch.vs_bar_lights','on') }}"
turn_on:
service: switch.turn_on
target:
entity_id: switch.vs_bar_lights
turn_off:
service: switch.turn_off
target:
entity_id: switch.vs_bar_lights
A lot of examples I found had the value_template line but I had to get rid of that to allow the switch to stay “on” so I could then turn it off. I am not 100% sure what that is for (or if I need it?) but it seems to work only if I comment it out.
The other thing I haven’t figured out is how to add the VS to my dashboard. Still working on that one.
Once I had the VS to play with, I could re-make the automation I had before…
alias: Bar Lights School Mornings
description: "Turn on the Bar In-Wall Outlet to turn on the Bar Xmas Lights during the week"
triggers:
- id: "on"
trigger: time
at: "06:00:00"
- id: "off"
trigger: time
at: "06:45:00"
- type: changed_states
device_id: e54e2b7a46fd0b3af2c6c0b1a628dfca
entity_id: a70a90049683804cd987a0d800c4cc42
domain: switch
trigger: device
- trigger: state
entity_id:
- switch.vs_bar_lights
conditions: []
actions:
- if:
- condition: state
entity_id: switch.vs_bar_lights
state: "off"
- condition: state
entity_id: switch.bar_in_wall_outlet
state: "off"
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
after: "06:00:00"
before: "06:45:00"
then:
- action: switch.turn_on
metadata: {}
data: {}
target:
device_id: e54e2b7a46fd0b3af2c6c0b1a628dfca
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.vs_bar_lights
- if:
- condition: state
entity_id: switch.vs_bar_lights
state: "on"
- condition: state
entity_id: switch.bar_in_wall_outlet
state: "on"
- condition: time
weekday:
- mon
- tue
- wed
- thu
- fri
after: "06:45:00"
before: "06:00:00"
then:
- action: switch.turn_off
metadata: {}
data: {}
target:
device_id: e54e2b7a46fd0b3af2c6c0b1a628dfca
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.vs_bar_lights
mode: single
Basically this will turn on an outlet at 6AM and turn it back off at 6:45AM M-F. The VS tracks state so if someone turns the switch on manually outside that 45 minute time window, it will stay on. I plan on adding a third “if” section that sends me notifications if things get out of sync (VS is on but the PS is off, PS is on but the VS is off @ 6AM, etc).
Of course things getting out of sync may not really be an issue with HA? It was with Smartthings years ago which is one of the reasons I still have it set up this way.
Anyway, I would guess that there is a totally different way to accomplish the same thing using another method so if anybody has suggestions, I am up for going down another path. This was how I had to do it using WebCore so this, at least, lets me easily migrate things over to HA while I look into re-working everything.