SmartThings Button to Lightify RGBw bulb with time dependent color and brightness - solved

Hi everyone!

Background: Had a SmartThings button, set up through my Wink Hub 2, controlling a Lightify bulb in my bedroom (also on the winkhub). From 7 am to 9pm it would toggle on/off at full brightness, from 9pm to 7am it would toggle the light on/off at 1% brightness in warmest white. I got a bunch of help crafting 2 HA automations that would control the light.

It worked great! BUT… with all the problems with Wink lately, I’m slowly moving all my stuff over to HA directly (Hassio, on RPi3B, with HUSBZB stick.) and the smartthings button setup direct through HA ZHA, is causing some issues.

I followed the How-to here: How_To: SmartThings button and I edited my automations so that at least I see the button triggering both automations now. BUTmy problem is that I don’t know how to edit the automation that controls light on/off, etc to properly do what I need. (Move from “state” on/off to ZHA event…)

Light Toggle

- id: Button
  alias: Master Light Toggle
  trigger:
    platform: event
    event_type: zha_event
    event_data:
      device_ieee: 28:6d:97:00:01:03:32:ad
      command: button_single
  condition: []
  action:
  - entity_id: light.master_bedroom
    service: light.toggle

What I call MasterFlux (change color/brightness depending on time)

- id: MasterFlux
  alias: MasterFlux
  trigger:
    platform: event
    event_type: zha_event
    event_data:
      device_ieee: 28:6d:97:00:01:03:32:ad
      command: button_single
  action:
  - data_template:
      entity_id: "{% if states.light.master_bedroom.state == 'off' and now().hour\
        \ >=21 and now().hour < 7 %}\n  scene.master_nightlight\n{% elif states.light.master_bedroom.state\
        \ == 'off' and now().hour >=7 and now().hour < 21 %}\n  scene.master_bedroom_on\n\
        {% else %}\n  light.master_bedroom\n{% endif %}\n"
    service_template: "{% if states.light.master_bedroom.state == 'off' %}\n  scene.turn_on\n\
      {% else %}\n  light.turn_off \n{% endif %}\n"

Any help would be greatly appreciated!

I suppose I just need a little healp figure out what to replace “states.light.master_bedroom.state” with. (Whatever the ZHA event equivalent is.)

Thanks!

Nope… figured it out… I think. I should be using the light as the entity in the second automation. I changed out the button as the entity, put in the light and it seems to be working properly now!

Thanks!