r/googlehome•
dimm0k

help and suggestion in getting light to change color/brightness throughout the day

I'd like to start off by describing what I'm trying to do before revealing the script(s) I have to "accomplish" in hopes of finding better ways to achieve my goal.

GOAL: I have a dining room light that stays on for a good part of the entire day since there are no windows there. I'd like to have the light mimic as best it can the sunrise/sunset effect where we start off with "daylight" and eventually end up with "candlelight". I currently have 5 different scripts that are started when the light is online, turned on, or every half hour. Each script handles 5 different colors and brightness and activate under the following conditions

# daylight 0600 - 1200

# cool white 1200 - 1800

# warm white 1800 - 2000

# incandescent 2000 - 2200

# candlelight (warmest) 2200+

​

CODE:

# ------------------------------------------------------------------------------------------ #
# 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: Dining lights - 01 morning activation # Choose a short name that summarizes important starters and actions, like “Sunset lights”.
  description: When turned on in the morning betw 0600 and 1200, set brightness to 100%, color to Daylight # Write a detailed description that includes everything the automation does, like “At sunset, on weekdays, close blinds, turn on lights to 50%, and play the sunset playlist on certain speakers.”
# colour names in English are:
# ivory (coolest)
# daylight 0600 - 1200
# cool white 1200 - 1800
# warm white 1800 - 2000
# incandescent 2000 - 2200
# candlelight (warmest) 2200+

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.Online
      state: online
      # [available operators: is, isNot]
      is: true
      device: Dining - Dining Room
    - type: device.state.OnOff
      state: on
      # [available operators: is, isNot]
      is: true
      device: Dining - Dining Room
    - type: time.schedule
      at: 06:00
    - type: time.schedule
      at: 06:30
    - type: time.schedule
      at: 07:00
    - type: time.schedule
      at: 07:30
    - type: time.schedule
      at: 08:00
    - type: time.schedule
      at: 08:30
    - type: time.schedule
      at: 09:00
    - type: time.schedule
      at: 09:30
    - type: time.schedule
      at: 10:00
    - type: time.schedule
      at: 10:30
    - type: time.schedule
      at: 11:00
    - type: time.schedule
      at: 11:30

  # ---- 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: 12: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: 06:00 # HH:MM (24 hours format). Adjust time as needed
    # Optional. Days of the week to apply condition on.
    weekdays:
      - MON
      - TUE
      - WED
      - THU
      - FRI
      - SAT
      - SUN

  # ---- 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: assistant.command.OkGoogle
      okGoogle: set dining to Daylight
      devices: Bedroom display - Bedroom
    - type: device.command.BrightnessAbsolute # Adjust device absolute brightness.
      brightness: 100
      devices: Dining - Dining Room

The above code is for the morning, with 4 other scripts being a clone of this with the time schedule, light color, and brightness changed accordingly. This light is mainly controlled at the switch so a simple check of the device.state.OnOff is not sufficient so I used the device.state.Online starter, as well as a time.schedule to activate every half hour. Without the time.schedule activating every half hour the script would be very inconsistent in its activation. Sometimes it would activate almost 2 hours later even though the light has been on longer than that, but most of the time it wouldn't even activate unless done manually.

Issues:

- because of the time.schedule activating every 30 minutes, I get a prompt from Google device that the device is currently unavailable right now if the light is turned off (offline) and does not need to be on at that time.

- without the time.schedule the script is unreliable at activating. for example, the last few mornings the script would activate any time the light was turned on in the morning. then a day later it did not activate at all and required a manual intervention.

- not sure if there's a better way with just one script or to optimize these 5 scripts

- looking for a better way to transition the colors and brightness so that it's not a sharp change when the script activates

Posted Sep 12, 2023, 2:10 PM UTC

10
Loading comments…