ColorExtractor

The ColorExtractor integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] will extract the predominant color from a given image and apply that color to a target light. Useful as part of an automationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more].

Configuration

To add the ColorExtractor integration to your Home Assistant instance, use this My button:

Manual configuration steps

If the above My button doesn’t work, you can also perform the following steps manually:

  • Browse to your Home Assistant instance.

  • Go to Settings > Devices & Services.

  • In the bottom right corner, select the Add Integration button.

  • From the list, select ColorExtractor.

  • Follow the instructions on screen to complete the setup.

Actions

Because color_extractor.turn_on will then call light.turn_on, you can pass any valid light.turn_on parameters (rgb_color will be set for you though) as those will be passed along.

Passing the key color_extract_url to the actionActions are used in several places in Home Assistant. As part of a script or automation, actions define what is going to happen once a trigger is activated. In scripts, an action is called sequence. [Learn more] call will download the linked image and extract the predominant color from it. Passing the key color_extract_path to the action will process the image file from local storage instead. color_extract_url and color_extract_path are exclusive and cannot be used together.

Key Example Description
color_extract_url https://example.com/images/logo.png The full URL (including schema, http://, https://) of the image to process
color_extract_path /tmp/album.png The full path to the image file on local storage we’ll process
entity_id light.shelf_leds The RGB capable light we’ll set the color of

Important

Ensure any external URLs or external files are authorized for use. You will receive error messages if this integrationIntegrations connect and integrate Home Assistant with your devices, services, and more. [Learn more] is not allowed access to these external resources.

URL Action

Add the parameter key color_extract_url to the action.

This actionActions are used in several places in Home Assistant. As part of a script or automation, actions define what is going to happen once a trigger is activated. In scripts, an action is called sequence. [Learn more] allows you to pass in the URL of an image, have it downloaded, get the predominant color from it, and then set a light’s RGB value to it.

File Action

Add the parameter key color_extract_path to the action.

This actionActions are used in several places in Home Assistant. As part of a script or automation, actions define what is going to happen once a trigger is activated. In scripts, an action is called sequence. [Learn more] is very similar to the URL action above, except it processes a file from the local file storage.

Example Automations

Example usage in an automationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more], taking the album art present on a Chromecast and supplying it to light.shelf_leds whenever it changes:

#automation.yaml
- alias: "Chromecast to Shelf Lights"

  triggers:
    - trigger: state
      entity_id: media_player.chromecast

  actions:
    - action: color_extractor.turn_on
      data_template:
        color_extract_url: "{{ states.media_player.chromecast.attributes.entity_picture }}"
        entity_id: light.shelf_leds

With a nicer transition period of 5 seconds and setting brightness to 100% each time (part of the light.turn_on action parameters):

#automation.yaml
- alias: "Nicer Chromecast to Shelf Lights"

  triggers:
    - trigger: state
      entity_id: media_player.chromecast

  actions:
    - action: color_extractor.turn_on
      data_template:
        color_extract_url: "{{ states.media_player.chromecast.attributes.entity_picture }}"
        entity_id: light.shelf_leds
        brightness_pct: 100
        transition: 5