Mutually exclusive light buttons for white and warm

So in my quest of having two buttons for white and warm light in Homekit, I’ve created two dummy lights.

The problem with that setup, is that both warm and white can be on simultaneously (turning on one after the other) which doesn’t make a lot of sense for the user.

So now I’m trying to make them mutually exclusive, I’ve tried adding for example:

turn_on:
...
- service: light.turn_off
  entity_id: light.bedroom_warm_light

But that caused issue because when light.bedroom_warm_light it will also try to turn off the actual light.bedroom.

I tried making that dynamic. This is the latest this I’ve tried, https://github.com/JorgeAnzola/home-assistant-config/pull/28/files,

But that returns the error:

Failed to call service light/turn_on. not a valid value for dictionary value @ data['entity_id']

Any idea? Help? 🥲 thanks!

I think the issue is that you have excess quotes in your service call, I’ve created a PR in your repo.

Thanks!
🥲 unfortunately that didn’t fix the problem

Screenshot 2021-02-23 at 10.32.54


Hm, so I guess the issue then is that you call the service without an entity_id once the other light is already off.
I’ve come across something similar and just created a virtual template light that doesn’t do anything other than being an entity_id you can manipulate.
A cleaner approach would be to call a script for the turn_off service and pass the target as a parameter.
The script would contain a “Chooser” action that would turn off the actual light, depending on whether or not the other virtual light is turned on or not.

Damn, yeah. Ok, that could be, cause I tried service_template, but that’s deprecated.
I’m gonna give it a try, let’s see 🥲

The feature itself isn’t deprecated, you just don’t need the _template part anymore.

As someone on FB mentioned, sounds like you’re wanting to do something like an interlock. If you haven’t already, lots of search results here on this forum on that.

I have similar setup for net radios. To achieve it I’ve created two template switches. So you don’t turn off the other one - it just updates the state based on the state of the devices you are controlling (in my case the played radio station, in your case a state of your light.bedroom). Below is my example. You should replace the value_template with logic relevant to the warm/cool light for your device and the turn_on, turn_off - I think is already ok in your code.

- platform: template
  switches:
    radio357_gray:
      friendly_name: "Radio 357 Gray"
      value_template: "{{ is_state_attr('media_player.szary_main','media_artist', 'Radio 357 (Warsaw/Polish)') }}"
      turn_on:
        - service: media_player.turn_on
          entity_id: media_player.szary_main
        - delay: 2
        - service: script.preset5_szary
      turn_off:
        service: media_player.turn_off
        entity_id: media_player.szary_main
      icon_template: mdi:radio
    nowyswiat_gray:
      friendly_name: "Radio New Gray"
      value_template: "{{ is_state_attr('media_player.szary_main','media_artist', 'Radio Nowy Świat (Warsaw/Polish)') }}"
      turn_on:
        - service: media_player.turn_on
          entity_id: media_player.szary_main
        - delay: 2
        - service: script.preset1_szary
      turn_off:
        service: media_player.turn_off
        entity_id: media_player.szary_main
      icon_template: mdi:radio

If I understood you correctly, that’s how it’s working right now. For example:
I click “bedroom white light” —> The light goes on white) —> I click “bedroom warm light” —> The light turns to yellow. That’s correct, the state updates, the problem is that “bedroom white light” will still be on. and worse, if you click again “bedroom warm light”, the light will go off, but “bedroom white light” will still be on in the UI. That’s the problem.

Well not exactly. That is why you need the value_template in your template switches so it recognizes when the color of your light has changed and turns off accordingly.