How to retrieve the color temperature of lights in an area/device/entity

Hey there, I want to change the color temperature of lights that are bound to a switch. Now the tricky part is that other than brightness with brightness_step_pc this option isn’t available for color temperature as far as I can see. So if I want to change it by X I first have to retrieve the color_temp_value. Now the tricky part is that targets for an action can be lights in an area, lights in a device or an entity. To demonstrate what I mean, here are parts of my blueprint:

  - variables:
      command: "{{ trigger.to_state.state }}"
      kelving_step_var: 200
      target_lights: !input target_lights_on
  - choose:
      - conditions: "{{ command == 'arrow_left_click' }}"
          - service: light.turn_on
            target: target_lights
              color_temp_kelvin: "{{states(target_lights+'.attributes.color_temp_kelvin') | int - kelving_step_var}}"

now the Variable target_lights can either be an area whereas it is a dictionary like this:
{'area_id': 'office'}
a device:
{'device_id': '4281c890571f8524521efc280'}
an entity:
{'entity_id': 'light.office_ceiling_light_temp'}

So how can I consistently return a color temperature value that I then can either increase or decrease for all 3 cases?

edit: I just noticed that the dictionary can also have more values and can look something like this:
{'area_id': ['office', 'hallway'], 'device_id': 'b3435c16e1f4ebd1a60'}

so I’m even more baffled on how to handle this

If you have such entity, i believe that is your “target” , thou if your are making an automation/ template, with an input.trigger. hmmm , i really don’t know what you trying to create here
This your “action” is that a tab_action in a card ? , or in an automation, or … ?

I think im more baffled than you :slight_smile:

Yep that would work if I just got entities but in the blueprint I have a selector that lets me choose different things from the light domain:

      name: Lights ON
      description: The lights to turn on.
            domain: light

on the GUI it looks like this:

Now as you can see I can not only choose an entity but also an area. What ever I choose, it creates a dictionary with all the things that choose in the GUI. So for the example in the picture, the !input target_lights_on would look like this: {'area_id': 'office'} this I then bind to the variable target_lights in the action part of my blueprint. Now, obviously I can’t do this: states(target_lights+'.attributes.color_temp_kelvin') where target_lights is dictionary. So how instead would I fetch a color_temp_kelvin value?

Yes i figured/thought you were dealing with a blueprint, i haven’t found a blueprint for my colored-light or light strip, which fits my needs/wishes, and haven’t put much time on this either, yet … And with the latest changes in the weather-forecast component, do to previous project decisions (removing large size attributes from Entities ), then i currently won’t focus on my color-temp, or scenes ( which also is missing from default cards ) :frowning:
Have you search in HACS if there’s any cool colored-light cards, which can control color-temp ect ?

PS: if you are not able to find i.e templates in this forum through the search-function , you could add/search for the specific blueprint, im sure there must be some questions/answers there, or post that blueprint in your Topic ( In Formatted Code , don’t post a pic/screen shot), and explain what it is you want to accomplice with your “Changes” i.e a by showing Picture/screenshot of the want to create.
IF you don’t understand the blueprint ( they can be “difficult” to get a grip on), then search the forum for that blueprint, and ask help there, or create your own template/automation, in simple steps first ( so you figure out howto “address/get to” your specific attributes ( which you btw also don’t show here )

Working on the blueprint is one thing (yaml) in the GUI there seems only on/off / Brightness etc. available, the most simple “features” it seems , for obvious reasons , I i.e don’t have the same entity_attributes as you

  - bubblingcauldron
  - aurora
  - candycane
  - christmas
  - flicker
  - christmaslight
  - hanukkah
  - hauntedmansion
  - icicle
  - lightning
  - ocean
  - rainbow
  - raindrop
  - spring
  - sunrise
  - sunset
  - valentines
  - brightness
  - hs
  - onoff
color_mode: hs
brightness: 255
  - 6
  - 84
  - 255
  - 62
  - 40
  - 0.664
  - 0.312

So this is not “addressable” in a i.e light,turn_on service-call directly( in the gui , as it’s very variable from device to device, i think) , so the template is required, to change the attribute. IF above template works, i don’t know, don’t even know if the actual blueprint works or updated etc

I suggest you lookup this blueprints discussions/repro, or try in Template editor to pick/change you color_temp_kelvin

And again as i don’t know/haven’t seen this blueprint, and what you can choose/see in GUI ( what ever the GUI-Snappshot is from is not relevant, if it doesn’t follow the blueprints requirements)

Lights ON / OFF ( The lights to turn ON ) ALL lights in an Area ?, A device ? , AN Entity( i.e a specific bulp/ strip “light.something” )

Target selectors always return dict’s, and are best suited for plugging directly into services.

My suggestion is don’t use them. Use entity or device selectors.

I think that’s what’s the blueprint request ( a dict, to choose/pic a value in attribute color_temp_kelvin ) ( i dont know if it’s fixed values or a range 0 >200) Maybe this Blueprint is “including” a card with the i.e Arrow “arrow_left_click”

Yeah, I guess so, but would it be possible to retrieve one (or all) entity_id from an area selector, for example?