After tinkering more with the SmartThings Virtual switch @Dennis and not getting the results I wanted I decided to explore your suggestion of the Google Home Script Editor. WOH!!! I’m a little sleep deprived and may have gotten hooked. The Google Home Script Editor has been working flawlessly all this past week. I hope the below code is usefull to others. I want to add additional code that will set the brightness and color of the closet lights based on time of day. My cats pops open the closet doors in the middle of the night and the White lights have woken me up. Im going to try and figure out how to make the clost lights RED and 50% brightness between 9pm and 7am.
Working Code as of 21 Oct 2023
# ------------------------------------------------------------------------------------------ #
# Lines starting with “#” are comments and will be ignored by the automation.
# Indentation determines hierarchy within the script.
# Visit g.co/home/script-editor-docs for full documentation.
# ------------------------------------------------------------------------------------------ #
metadata:
name: MB Closet Light ON # Choose a short name that summarizes important starters and actions, like “Sunset lights”.
description: Turn MB Closet Light ON When Door Opens. Using Aeotec Door Sensor to turn on Feit Recessed Lights
automations:
# “starters” and “actions” are required; “conditions” are optional.
# Use Ctrl + Space to see autocomplete suggestions.
# ---- STARTERS ---- #
# Starters describe events that will start the automation.
# To add more than one starter, duplicate the "- type" section under "starters".
# If you add multiple starter events, any one of them happening will start the automation.
starters:
- type: device.state.OpenClose
state: openPercent
# [available operators: is, isNot, lessThan, lessThanOrEqualTo, greaterThan, greaterThanOrEqualTo]
is: 100
device: Master BR Closet Sensor - Master Bedroom
# ---- CONDITIONS ---- #
# Conditions are optional. Delete this section if it’s empty.
# Conditions will prevent an automation from starting if the conditions aren’t met.
# See g.co/home/script-editor-docs for documentation about how to use logical operators like “and”, “or”, and “not”.
condition:
type: time.between
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
before: 21:00 # HH:MM (24 hours format). Adjust time as needed
# Optional. Accepts either clock time (10:00:00 AM, with seconds optional, or in a 24 hour format), or 'sunrise' or 'sunset', with an optional offset ('sunrise+10m', for instance)
after: 07:00 # HH:MM (24 hours format). Adjust time as needed
# Optional. Days of the week to apply condition on.
# ---- ACTIONS ---- #
# Actions will start when a starter event takes place and all conditions are met.
# Actions will start in the order they appear in the script and with any delay specified.
# To add more than one action, duplicate the "- type" section under "actions".
actions:
- type: device.command.OnOff # Turn the device on.
devices: Master Bedroom Lights - Master Bedroom
on: true
- type: time.delay
for: 3min
# Set MB Closet Lights to 100 Percent Brightness
- type: device.command.BrightnessAbsolute # Adjust device absolute brightness.
brightness: 100
devices: Master Bedroom Lights - Master Bedroom
# Set MB Closet Lights Color to Bright White
- type: device.command.ColorAbsolute
color:
name: white
devices: Master Bedroom Lights - Master Bedroom
# Turns Group Master Bedroom Lights off after 3min
- type: device.command.OnOff # Turn the device off.
devices: Master Bedroom Lights - Master Bedroom
on: false