Skip to content

💡 AppDaemon App that synchronize RGB lights with the thumbnail of a media player in Home Assistant. Be sure to ⭐️ my repo!

License

Notifications You must be signed in to change notification settings

ericmatte/ad-media-lights-sync

Repository files navigation

Media Player Lights Sync

AppDaemon App that synchronizes the color of RGB lights with the thumbnail of a media player in Home Assistant.

hacs_badge downloads-latest

Tests

Buy Me A Coffee

Example 1 Example 1

Features

  • Realtime RGB lights color synchronization with the thumbnail of a media player
  • Extract most relevant colors from a picture and assign them to lights
  • Always creates great matching moody ambiances
  • Change all configured lights color at the same time using multithreading
  • Prevent lights synchronization based on a state condition from your Home Assistant

Installation

Use HACS or download the media_lights_sync directory from inside the apps directory here to your local apps directory, then add the configuration to enable the media_lights_sync module.

Prerequisites

In order for this app to work, you need to add py3-pillow and Pillow to the config of your AppDaemon 4 Supervisor add-on:

system_packages:
  - py3-pillow
python_packages:
  - Pillow
init_commands: []
log_level: info

AppDaemon 4 in Docker

See AppDaemon with Docker.

Using the files from ./docker in your CONF path, the Docker script will recursively search the CONF directory and install the system_packages.txt and requirements.txt files.

App configuration

config/appdaemon/apps/apps.yaml

media_lights_sync:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.tv
  lights:
    - light.left_theatre_light
    - light.right_theatre_light
  ha_url: !secret ha_url
  reset_lights_after: true
  use_saturated_colors: false
  use_current_brightness: false
  condition:
    entity: input_boolean.sync_tv_lights
    state: "on"
key optional type default description
module False string media_lights_sync The module name of the app.
class False string MediaLightsSync The name of the Class.
media_player False string or list The entity_id(s) of the media player(s) to sync from1.
lights False list The list of all the lights entity_id to sync to.
ha_url True string null The URL to your Home Assistant. Examples: https://my-ha.duckdns.org, https://192.168.1.123:8123.
verify_cert True bool true Set to false if you are using https on your ha-url but are unable to trust the certificate. Bypasses cert validation.
reset_lights_after True bool false Reset lights to their initial state after turning off a medial_player. Will not reset lights if false.
quantization_method True string MedianCut Supports MedianCut, FastOctree, MaxCoverage and libimagequant. More info below.
use_saturated_colors True bool false Increase the saturation and brightness of the colors.
use_current_brightness True bool false Do not change lights brightness. If false, it will always sets all lights to maximum brightness.
transition True number null Number that represents the time (in seconds) the light should take to transition to new states.
condition True object Sync lights only if the state of the condition entity is True.
condition.entity False string The entity_id of the condition.
condition.state False string The state to match in order for the lights to sync.

1: See /developer-tools/state in your Home Assistant instance. This app will listen to changes on entity_picture_local and/or entity_picture attributes of your media_player entities.

Using a more complex condition

You can use a template condition to match more complex states:

condition:
  value_template: "{{ state_attr('media_player.tv', 'media_content_type') == 'movie' and is_state('sun.sun', 'below_horizon') }}"

The app will run if the condition returns True.

Selecting a quantization_method

There is four quantization method available, which change the way the colors palette is extracted:

  • MedianCut: Default method. Mix colors in the image using their median value.
  • FastOctree: Extract dominant colors. Use this option if you want more accurate colors.
  • MaxCoverage: Mix colors based on their maximum coverage.
  • libimagequant: High-quality conversion of RGBA images to 8-bit indexed-color (palette) images.

Alternatively, you can also combine this option with use_saturated_colors to get more vibrant colors.

Compatibility

This app should work with any media_player and RGB light integrations available in Home Assitant. That said, it has been tested and is working with the following devices:

If you've found that this app is working with another device, just let me know so I can update this list.

Notes

About

💡 AppDaemon App that synchronize RGB lights with the thumbnail of a media player in Home Assistant. Be sure to ⭐️ my repo!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages