Trying to create a color change automation w/ dropdown

I am trying to create an automation that chages a colour light bulb to the next color setting in a dropdown list. I have used a couple blueprints that do this, but I do not have a clue to turn this into lovelace automation.

Any hints, pointers on how to do this?

Greg

Does the state of the select/input_select need to stay put or can it change?

No sure what you are asking. I am guessing either would be ok.

Greg

I’m just trying to figure out how you want/need this automation to work… so far we know there’s a light and a color selection dropdown, but you haven’t provided enough info for us to know how they already relate to each other, how they need to function in relation to one another, what will trigger the automation, what conditions need to be met, etc.

Ah, sorry not enough coffee when I replied before.

We can start with a clean slate. I have a color lightbulb, and a remote switch with a spare button.
What I was hoping to have happen is for the light to go through a colour change with each press of the button. If something like this exists already I can use that. Like I said I have the blueprint for an IKEA switch, but too much of a NOOB here to know how to change it.

Greg

If you are already using the blueprint for other button functions on the remote, you probably don’t need an automation but a script. Scripts can be called like a service from a blueprint, automation, or dashboard button.

Your script could be something like:

alias: Change Input Select Update light color
sequence:
  - service: input_select.select_next
    data:
      cycle: true
    target:
      entity_id: input_select.color_names
  - delay:
      milliseconds: 100
  - service: light.turn_on
    data:
      color_name: "{{ state('input_select.color_names') }}"
    target:
      entity_id: light.example_light
mode: single

In your blueprint, you would then find the option for the button in question and select a Call Service action with script.change_input_select_update_light_color as the service.

1 Like

Thanks I will give that a try!
Thanks for your help!

Thanks for the hint @Didgeridrew! Im so happy to get it working with your help!

My lamp didnt support the Colors as a name, just push RGB Values so this script worked for me:

alias: Farbwechsel der Lampe RGB Kugel
sequence:
  - service: input_select.select_next
    data:
      cycle: true
    target:
      entity_id: input_select.rgb_color
  - delay:
      milliseconds: 100
  - service: light.turn_on
    data:
      rgb_color: "{{ states('input_select.rgb_color').split(',') }}"
    target:
      entity_id: light.iot_z_lampergb_kugel_licht
mode: single

The Value in the Helpers can be:
Helper Name: rgb_color
Option:
255,0,0
0,255,0
0,0,255
and so on

So when you add the script to an button action on a Ikea blueprint, you can change the colors on a button press.

Sorry for the very long delay. Lots happening…
OK here is where I am with this. I am writing an Automation for my Hue Remote Control. I have the Power/Bright/Dim/hue buttons. The first three are obvious, the third one I want to use to change the colour of my light to the next one in a list. The list would best be a ‘helper’ as the end goal is to make this into a blueprint with different helper scripts for different bulbs.

So looking at the YAML code for replacing this:

      - conditions:
          - condition: trigger
            id:
              - 4press
        sequence:
          - action: script.kennel_colour_fade
            metadata: {}
            data: {}

Greg

I worked your code (thank you for the excellent example) to become this:

        sequence:
          - service: input_select.select_next
            data:
              cycle: true
            target:
              entity_id: input_select.colour_presets
            action: input_select.select_next
          - delay:
              milliseconds: 100
          - data:
              color_name: "{{ states('input_select.colour_preset') }}"
            target:
              entity_id: light.hue_color_lamp_3
            action: light.turn_on

This problem I am having is the button does not do anything when pressed. Even weirder is then I go back into the YAML editor my code has been changed to this:

        sequence:
          - data:
              cycle: true
            target:
              entity_id: input_select.colour_presets
            action: input_select.select_next
          - delay:
              milliseconds: 100
          - data:
              color_name: "{{ states('input_select.colour_preset') }}"
            target:
              entity_id: light.hue_color_lamp_3
            action: light.turn_on

As you can see the second line: ‘-service: input_select.select_next’ is missing. The only difference is I did not create a script, instead I put the code into the automation.

No idea what I am doing wrong. So close yet to far away…

The whole automation code is this:

alias: 001-test-Kennel Dimmer
description: ""
triggers:
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 1
    unique_id: e2a85195-7b89-43d9-8c29-74ca3200e9f2
    trigger: device
    id: 1press
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: repeat
    subtype: 1
    unique_id: e2a85195-7b89-43d9-8c29-74ca3200e9f2
    trigger: device
    id: 2hold
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 2
    unique_id: f1432e3c-101c-4603-98fa-92377f75540c
    trigger: device
    id: 2press
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 3
    unique_id: b442dc08-8917-4831-8bdc-c7e7179444a0
    trigger: device
    id: 3press
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 4
    unique_id: d1e96a66-a78b-4174-9a1c-7c0e33a42920
    trigger: device
    id: 4press
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - 1press
        sequence:
          - type: toggle
            device_id: 0aca47d491afcc168d2536a993542610
            entity_id: c61851971768a01fde09423784dfa7a2
            domain: light
      - conditions:
          - condition: trigger
            id:
              - 1hold
        sequence:
          - type: turn_off
            device_id: 0aca47d491afcc168d2536a993542610
            entity_id: c61851971768a01fde09423784dfa7a2
            domain: light
      - conditions:
          - condition: trigger
            id:
              - 2press
        sequence:
          - device_id: 0aca47d491afcc168d2536a993542610
            domain: light
            entity_id: c61851971768a01fde09423784dfa7a2
            type: brightness_increase
      - conditions:
          - condition: trigger
            id:
              - 3press
        sequence:
          - device_id: 0aca47d491afcc168d2536a993542610
            domain: light
            entity_id: c61851971768a01fde09423784dfa7a2
            type: brightness_decrease
      - conditions:
          - condition: trigger
            id:
              - 4press
        sequence:
          - data:
              cycle: true
            target:
              entity_id: input_select.colour_presets
            action: input_select.select_next
          - delay:
              milliseconds: 100
          - data:
              color_name: "{{ states('input_select.colour_preset') }}"
            target:
              entity_id: light.hue_color_lamp_3
            action: light.turn_on
mode: single

In the months since I posted that example the key service has been soft-deprecated in preference for action. You can use either one, but not both.

A couple notes on using colorname:

  1. As Afraskai noted above, occasionally you will run into lights that are not compatible with the use of colorname.
  2. You need to use the CSS3 color names. If the options of the Input Select are different values, you can use templating to translate them to the appropriate value.

Thank you everyone!! Here is the automation now. It is working as expected:

alias: 001-test-Kennel Dimmer
description: ""
triggers:
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 1
    unique_id: e2a85195-7b89-43d9-8c29-74ca3200e9f2
    trigger: device
    id: 1press
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: repeat
    subtype: 1
    unique_id: e2a85195-7b89-43d9-8c29-74ca3200e9f2
    trigger: device
    id: 2hold
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 2
    unique_id: f1432e3c-101c-4603-98fa-92377f75540c
    trigger: device
    id: 2press
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 3
    unique_id: b442dc08-8917-4831-8bdc-c7e7179444a0
    trigger: device
    id: 3press
  - device_id: 60ecf2bc8065b2a99facc19a9ce5fe23
    domain: hue
    type: short_release
    subtype: 4
    unique_id: d1e96a66-a78b-4174-9a1c-7c0e33a42920
    trigger: device
    id: 4press
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - 1press
        sequence:
          - type: toggle
            device_id: 0aca47d491afcc168d2536a993542610
            entity_id: c61851971768a01fde09423784dfa7a2
            domain: light
      - conditions:
          - condition: trigger
            id:
              - 1hold
        sequence:
          - type: turn_off
            device_id: 0aca47d491afcc168d2536a993542610
            entity_id: c61851971768a01fde09423784dfa7a2
            domain: light
      - conditions:
          - condition: trigger
            id:
              - 2press
        sequence:
          - device_id: 0aca47d491afcc168d2536a993542610
            domain: light
            entity_id: c61851971768a01fde09423784dfa7a2
            type: brightness_increase
      - conditions:
          - condition: trigger
            id:
              - 3press
        sequence:
          - device_id: 0aca47d491afcc168d2536a993542610
            domain: light
            entity_id: c61851971768a01fde09423784dfa7a2
            type: brightness_decrease
      - conditions:
          - condition: trigger
            id:
              - 4press
        sequence:
          - data:
              cycle: true
            target:
              entity_id: input_select.rgb_colour
            action: input_select.select_next
          - delay:
              milliseconds: 100
          - data:
              rgb_color: "{{ states('input_select.rgb_colour').split(',') }}"
            target:
              entity_id: light.hue_color_lamp_3
            action: light.turn_on
mode: single

My next step is to get the automation to check if the bulb is colour or white. If colour change the colour, is white change the warmth.

After that turn the whole thing into a blueprint and publish it to the forum.

Greg