Quick switch of light from on to off to on for halo effect

Hi there - apologies up front if this has been asked and answered; I did a fair amount of searching but couldn’t quite find what I was looking for. Feel free to redirect me and close this if I missed it!

What I’d like to accomplish: I have several Home Depot/Commercial Electric recessed lights [not smart, powered only]. These have a feature I enjoy that engage a band of lights that halo around the body of the light to serve as a night light. To turn this on, I have to toggle the light off and on again with 3 seconds of the last time the light was on. I’m trying to figure out how to configure an automation [or some other method] to deterministically engage the lights as ‘on’ (regularly) or ‘halo’ (on but with halo effect).

If anyone has the time to help me think through the logic here, I’d be quite grateful. I’m wondering if I could either track state and use delay-based call_service on/off, or if I could read the wattage on my Innovelli switches which are controlling these lights. For the latter, I’m able to see the power draw reported by the switch and of course it’s markedly lower if the Halo is on versus the light itself. For the former, I’m not sure how to do this.

Thinking out loud, if there’s a way to keep persistent state, then I could if/then, right?
1/ light off: “If the light is off, the state is obvious. To go to halo, I would turn the light on, represent the state as on, turn it off, which would toggle the state to off again, and then turn the light back on again within 3 seconds, and track the state as halo.”. The first two states I get for free from the HA integration, but the halo/on states could not represent reality unless I have a way to be sure they’re persistent.
2/ light on: Or, “if the light is on regularly, and I call for Halo, I toggle the light off deterministically and change the state to Off automatically. Then I turn the light back on within 3 seconds and go to Halo mode [change variable manually]”.
3/ light on halo: “If the light is halo’d, but I want normal operation, I first check the variable and I see it’s Halo. I turn the switch off, wait 3-4 seconds, and turn it on again”

Am I overcomplicating this? If this is the right way, any help or pseudocode to give me a nudge would be appreciated very much.

What about using the Innovelli’s reported wattage? This is less deterministic but in informal tests the results seem to be fairly consistent.

Not really sure where to start here (automations, scripts, variables?!) but the community seems super helpful so I’m hoping this is of interest to someone and that there are some ideas. Thank you so much!

Would something like this work for you. I don’t know what you want for a trigger. This requires that you add a helper that will record the state of Halo. If you turn off lights need automation to turn off halo.

alias: New Automation
description: ''
mode: single
trigger:
  - platform: device
    device_id: ''
    domain: ''
    entity_id: ''
condition: []
action:
  - service: switch.turn_off
    target:
      entity_id: switch.bar_can_lights
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: switch.turn_on
    target:
      entity_id: switch.bar_can_lights
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: switch.turn_off
    target:
      entity_id: switch.bar_can_lights
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: switch.turn_on
    target:
      entity_id: switch.bar_can_lights
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.halo_on

Thanks very much for the detailed reply! I’ve just had a chance in the last day or so to read through this and try to reason through how to implement it. I think my issue comes from a lack of familiarity with the basics of using helpers in HA, so I’ve tried to implement a few ‘toggle’ helpers that work just fine for two-state devices. Here, though, I’m stuck with what maintains the actual source of truth as to the state of the light.

The light can be in one of three states: on, off, or halo. Off is deterministic - we can tell it’s off by checking the state of the switch. On and halo are a bit more difficult - the switch can tell us that it’s on and I can query its energy draw which is materially different depending on whether we’re in halo mode or standard lighting mode.

I’ve found a helper that appears to work well for this use case, the input_select helper, where I can define the possible states. Am I correct that changing the helper should be used as as -trigger- to do something with the light, and not represent the true state of the light? If in the UI, someone toggles the helper to ‘halo’, we should perform some action that takes the light to halo mode. But if I lose power, and the light is off, the helper doesn’t follow the state of the light… am I correct there?

So I think I’m back to the if/then tree… would someone be so kind as to validate or correct my thinking here?

Let’s say I have no other trigger other than a lightswitch. Not even a helper in the UI. If I push down on the paddle, the light goes off in every case. That’s easy, right - trigger is switch down, action is light off. Do I update the helper as part of the off automation? Now, if the light is on already, and someone pushes up, I want it to go to halo mode and if it’s in on mode I want it to go to halo mode. So, again, the up button is the trigger, but is this a conditional action? “If current mode == halo, set current mode == light” and vice versa. I think that’s not exactly right, because I’m not using the helper the original reply-er suggested in the appropriate manner. And to check if current mode == halo, all I can think to do is check the consumed power by the switch and make an educated guess.

So I think I’m misunderstanding how and when to use the helper as a UI tool to select modes versus use it to track state, and how to align that state with reality.

Hopefully this makes sense, and I really do appreciate the help if anyone is willing to give me another nudge.

Thanks!

Were you able to figure this out? I’m about to install the same lights and I want to do the exact same thing as you. Wondering if there is a solution?

Thanks!