ColorExtractor

ColorExtractor integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] 将从给定图像中提取主要颜色,并将该颜色应用于目标灯光。作为automationHome Assistant 中的自动化允许您自动响应在家中和周围发生的事情。 [Learn more]的一部分非常有用。

配置

要将 ColorExtractor integration 添加到您的 Home Assistant 实例中,请使用此 My 按钮:

手动配置步骤

如果上述 My 按钮不起作用,您也可以手动执行以下步骤:

操作

由于 color_extractor.turn_on 将调用 light.turn_on,因此您可以传递任何有效的 light.turn_on 参数(rgb_color 将为您自动设置)。

将键 color_extract_url 传递给 action动作在 Home Assistant 的多个地方使用。作为脚本或自动化的一部分,动作定义了触发器被激活后将发生的事情。在脚本中,动作被称为序列 [Learn more] 调用将下载链接的图像并提取所提取的主要颜色。将键 color_extract_path 传递给该操作将处理来自本地存储的图像文件。color_extract_urlcolor_extract_path 是互斥的,不能一起使用。

示例 描述
color_extract_url https://example.com/images/logo.png 要处理的图像的完整URL(包括方案,http://https://
color_extract_path /tmp/album.png 我们将处理的本地存储图像文件的完整路径
entity_id light.shelf_leds 我们将设置颜色的RGB功能灯

Important

确保任何 外部 URL外部文件 得到授权使用。如果此 integration集成将 Home Assistant 与您的设备、服务等连接和集成。 [Learn more] 未被允许访问这些外部资源,您将收到错误消息。

URL 操作

将参数键 color_extract_url 添加到操作中。

action动作在 Home Assistant 的多个地方使用。作为脚本或自动化的一部分,动作定义了触发器被激活后将发生的事情。在脚本中,动作被称为序列 [Learn more] 允许您传入图像的 URL,下载它,从中获取主要颜色,然后将灯的RGB值设置为该颜色。

文件操作

将参数键 color_extract_path 添加到操作中。

action动作在 Home Assistant 的多个地方使用。作为脚本或自动化的一部分,动作定义了触发器被激活后将发生的事情。在脚本中,动作被称为序列 [Learn more] 与上面的URL操作非常相似,只是处理的是本地文件存储中的文件。

示例自动化

automationHome Assistant 中的自动化允许您自动响应在家中和周围发生的事情。 [Learn more] 中的示例用法,每当 Chromecast 上的专辑封面变化时,将其提供给 light.shelf_leds

#automation.yaml
- alias: "Chromecast 到书架灯"

  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

通过更好的过渡时间5秒,并在每次将亮度设置为100%(这是light.turn_on操作参数的一部分):

#automation.yaml
- alias: "更好的 Chromecast 到书架灯"

  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