Code Monkey home page Code Monkey logo

ad-media-lights-sync's Introduction

I’m always seeking for new goals. I give a great interest on the quality of my work and I always want to learn more.

With a degree in computer engineering, I am passionate about what I do.


Eric's github stats

Be sure to check out my portfolio.

ad-media-lights-sync's People

Contributors

darylosu avatar desertblade avatar ericmatte avatar thundergreen avatar whimsyspoon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ad-media-lights-sync's Issues

No module named 'PIL'

I added the required system and python packages in the readme but I am getting an error that there is No module named 'PIL'.

2020-04-25 18:38:04.982809 INFO AppDaemon: Loading App Module: media_lights_sync
2020-04-25 18:38:04.988727 WARNING Error: ------------------------------------------------------------
2020-04-25 18:38:04.989301 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py:
2020-04-25 18:38:04.989768 WARNING Error: ------------------------------------------------------------
2020-04-25 18:38:04.991170 WARNING Error: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 566, in read_app
importlib.reload(self.modules[module_name])
KeyError: 'media_lights_sync'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 788, in check_app_updates
await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 276, in run_in_executor
response = future.result()
File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 571, in read_app
self.read_app(file)
File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 580, in read_app
self.modules[module_name] = importlib.import_module(module_name)
File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 783, in exec_module
File "", line 219, in _call_with_frames_removed
File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 6, in
from PIL import Image
ModuleNotFoundError: No module named 'PIL'

2020-04-25 18:38:04.991598 WARNING Error: ------------------------------------------------------------
2020-04-25 18:38:04.992151 WARNING AppDaemon: Removing associated apps:
2020-04-25 18:38:04.992599 WARNING AppDaemon: media_lights_sync

ValueError: A relative URL was received. ha_url must be specified in the configuration for relative URLs.

Describe the bug

Hi, just want to share my log with you to doublecheck if it is a bug or a not compatible light.

Additional context

LOG:

2021-05-02 15:18:27.807377 WARNING media_lights_sync_bagno_secondario: ------------------------------------------------------------
2021-05-02 15:18:27.807610 WARNING media_lights_sync_bagno_secondario: Unexpected error in worker for App media_lights_sync_bagno_secondario:
2021-05-02 15:18:27.807839 WARNING media_lights_sync_bagno_secondario: Worker Ags: {'id': '4fe5cc0a40444be7a8191145063fd0f0', 'name': 'media_lights_sync_bagno_secondario', 'objectid': 'e2970595be33430faa2373a18f75626f', 'type': 'state', 'function': <bound method MediaLightsSync.change_lights_color of <media_lights_sync.MediaLightsSync object at 0x7f4b8eea9250>>, 'attribute': 'entity_picture_local', 'entity': 'media_player.bagno_secondario', 'new_state': '/api/media_player_proxy/media_player.bagno_secondario?token=cccba97d02948d7802b4d830a5035a93d6a0db176e9bef2581046344b4b13c77&cache=818c79654a7d2206', 'old_state': '/api/media_player_proxy/media_player.bagno_secondario?token=cccba97d02948d7802b4d830a5035a93d6a0db176e9bef2581046344b4b13c77&cache=37ce9900470237a0', 'pin_app': True, 'pin_thread': 3, 'kwargs': {'attribute': 'entity_picture_local', '__thread_id': 'thread-3'}}
2021-05-02 15:18:27.807994 WARNING media_lights_sync_bagno_secondario: ------------------------------------------------------------
2021-05-02 15:18:27.808253 WARNING media_lights_sync_bagno_secondario: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 903, in worker
funcref(
File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 56, in change_lights_color
url = self.format_url(new_url, entity, attribute)
File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 155, in format_url
raise ValueError("A relative URL was received on '{entity}.{attribute}'.\nha_url must be specified in the configuration for relative URLs.".format(
ValueError: A relative URL was received on 'media_player.bagno_secondario.entity_picture_local'.
ha_url must be specified in the configuration for relative URLs.

CONFIG:

media_lights_sync_bagno_secondario:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.bagno_secondario
  photo_attribute: entity_picture
  reset_lights_after: true
  # ha_url: http://192.168.2.101:8123
  use_current_brightness: False
  use_saturated_colors: true
  condition:
    entity: input_boolean.bagnosecondario_musica_da_automazione
    state: "off"
  lights:
    - light.light.striscia_led_bagno_secondario

NB: app is called "media_lights_sync_bagno_secondario" because I have another app for lights in another room with following working config:

media_lights_sync_studio:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.studio
  photo_attribute: entity_picture
  reset_lights_after: true
  ha_url: http://192.168.2.101:8123
  use_current_brightness: False
  use_saturated_colors: true
  # condition:
    # entity: input_boolean.sync_tv_lights
    # state: "on"
  lights:
    - light.jack_lamp
    - light.lampada_scrivania

Thank you

Changing of color does not work - how to debug?

Describe the bug

Hello, I did installation and configuration exactly by the instructions. However, playing song does not change color o bulb. I checked that media player works fine and retrieves image if album (native mp3 plyer on kodi on libreelec, correctly identified by Home Assistant), I am able to manually change color of the bulb and I believe I have correct assignment as in code below.

Anything else I can do to debug the functionality?

/config/appdaemon/apps/apps.yaml:

media_lights_sync:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.libreelec
  lights:
    - light.21800710dc4f22741488_2
  ha_url: http://10.0.0.54:8123
  reset_lights_after: true
  use_saturated_colors: false
  use_current_brightness: false

I did not find any related entries in home-assistant.log. Nothing in appdaemon log either. I would suspect that in HASSIO image of album is stored in other place than the python script is looking for.

Help install - AppDaemon Configuration

after added to APPDEAMON 4 config the included info
system_packages:

  • py3-pillow
    python_packages:
  • Pillow

server gives me Failed to save addon configuration, not a valid value for dictionary value @ data['options']. Got {'system_packages': ['py3-pillow'], 'python_packages': ['Pillow']}

any help?

Add saturated colors mode

Problem
I've notice that most of the colors generated by the palette are not being well represented by the LEDS. It seems that when a color does not have enough saturation it is represented by white or blue which is very distant to a representative color of song's cover.

Solution
One solution i found was to calculate a saturated version of that color. I did that by converting RGB to HLS and setting Hue with 100% saturation and 50% lightness using the colorsys library.

That turned to be way more effective than the method without conversion (Which 50% of the time was on white or blue). This method is not 100% accurate since you may get some different HUEs from song's cover, but that happens on the ~20% of the time.

On the other hand i'm very new on writing Python so i'm not aware of code styling or easier ways to achieve the same thing, but i'll leave my here code in case someone is interested in following this up.

I added colorsys package

import colorsys

Then modified set_light_rgb method:

def set_light_rgb(self, light, color):
    """Change a light color."""
    hls = colorsys.rgb_to_hls(color[0]/255, color[1]/255, color[2]/255)
    hls_saturated = [hls[0], 0.5, 1]
    rgb_saturated = colorsys.hls_to_rgb(*hls_saturated)
    rgb_color = [int(rgb_modified[0] * 255), int(rgb_modified[1] * 255), int(rgb_modified[2] * 255)]
    light_kwargs = { "rgb_color": rgb_color }
    if not self.use_current_brightness:
        light_kwargs["brightness"] = 255
    self.turn_on(light, **light_kwargs)

Run Multiple Options

Is it possible to run multiple events? In other words, can I create a second occurrence for another room with its own media player and lights?

Help with initial setup

I have set up Media Lights Sync in my Home Assistant and I don’t seem to be getting any errors but I cant work out how to execute the app as the lights are not changing. What so you think I might be missing? I have never set up an app using AppDaemon before. I used HACS to setup.

My AppDaemon config:

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

Apps yaml:

media_lights_sync:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.lounge_apple_tv_2
  lights:
    - light.feibit_inc_co_fb56_zcw11hg1_2_2f49db13_level_light_color_on_off
    - light.feibit_inc_co_fb56_zcw11hg1_2_level_light_color_on_off
    - light.feibit_inc_co_fb56_zcw11hg1_2_8c99ed13_level_light_color_on_off
    - light.feibit_inc_co_fb56_zcw11hg1_2_7f0eca13_level_light_color_on_off
    - light.feibit_inc_co_fb56_zcw11hg1_2_d161ed13_level_light_color_on_off
    - light.feibit_inc_co_fb56_zcw11hg1_2_44f1c913_level_light_color_on_off
    - light.signify_netherlands_b_v_lct010_44b41a04_level_light_color_on_off
    - light.signify_netherlands_b_v_lst002_150cae02_level_light_color_on_off
  ha_url: http://homeassistant.local:8123
  reset_lights_after: true
  use_saturated_colors: true
  use_current_brightness: false
  condition:
    entity: input_boolean.sync_tv_lights
    state: "on"

Colors don't change from standby mode to album mode when restarting the same song

Describe the bug

Hello Eric, I made following observation. It may not be a bug, but rather a behaviour. When I start playing song (or a movie on KODI), the RGB bulb turns to correct color. When I stop the song, it turns back to normal color as it was before. But when I start to play the same song again, the bulb does not switch to album color. I assume that it is before image of current album is still cached and the script does not detect album change. This could possibly be solved by clearing album image on media player stop - the Home Assistant may do it, or just wipes the image album from lovelace card when it detects media player stop event and does not show it, but image may still be cached somewhere.

I personally have also problem with librespot, because it detects only when spotify switches from mobile phone to that player, it does not detect song change. But I think it is a problem of librespot, because HA lovelace card does not show song change either.

Best regards, Jan

Better algorithm to identify prevalent color (duplicated)

Is your feature request related to a problem? Please describe.

Dear sir,

if I am not mistaken, your script identifies best color by averaging colors in whole album. That results in mostly gray colors with some tint of prevalent color. I would like to ask you to consider different approach.

I use my own color analysis for years and I am very satisfied with it. I downsize the album, posterize it to less colors and then run statistical analysis to find what color is mostly represented in the album. This way if album is 55% red and 45% green, the result is not brown but red. Mail me at [email protected] and I will send you the script - I understand I cannot attach files here. It also has some approximation to 10 colors that are most similar. You can just replace fetching image by hass instead from last.fm and you can skip color approximation and call to ifttt at the end and you will have excellent album color finder.

Jan

Support multiple media player

I think it's will be awesome if the app will support multiple media players, Something like tv and Spotify, and extract colors from them all and reflect them to the lights.

Is this possible?

Continuously change color when watching a movie or series

Is your feature request related to a problem? Please describe.

Description of what the problem is.

There is no problem

Describe the solution you'd like

Description of what you want to happen.

I would like to have the light change every x seconds when watching a movie or series.
Could this be achieved by reading the image of the media player periodically via a loop and update the light accordingly?

Describe alternatives you've considered

Description of any alternative solutions or features you've considered.

Update the condition of the app in a way that you can define the period of the colour change in an additional condition.

Additional context

Add any other context or screenshots about the feature request here.

It's kind of an ambilight...

Errors when cover image is all black

Describe the bug

While the first light is properly skipped, at least when using the method 400 errors are still thrown.

To Reproduce

Steps to reproduce the behavior:

  1. Make sure to have at least two lights configured.
  2. Listen to any track from https://en.wikipedia.org/wiki/This_Is_Spinal_Tap_(soundtrack). I suggest Christmas with the Devil 🀘 πŸŽ… .
  3. See the 400 errors like so:

2023-12-13 19:38:21.233807 INFO media_lights_sync: Skipped black color for 'light.pedestal_1' light
2023-12-13 19:38:21.235094 INFO media_lights_sync: Set 'light.pedestal_2' light:
{'transition': 30, 'rgb_color': [], 'brightness': 255}
2023-12-13 19:38:21.239805 INFO media_lights_sync: Set 'light.pedestal_3' light:
{'transition': 30, 'rgb_color': [], 'brightness': 255}
2023-12-13 19:38:21.245798 INFO media_lights_sync: Set 'light.pedestal_4' light:
{'transition': 30, 'rgb_color': [], 'brightness': 255}
2023-12-13 19:38:21.257059 WARNING HASS: Error calling Home Assistant service default/homeassistant/turn_on
2023-12-13 19:38:21.295120 WARNING HASS: Code: 400, error: 400: Bad Request
2023-12-13 19:38:21.296774 WARNING HASS: Error calling Home Assistant service default/homeassistant/turn_on
2023-12-13 19:38:21.297256 WARNING HASS: Code: 400, error: 400: Bad Request
2023-12-13 19:38:21.297883 WARNING HASS: Error calling Home Assistant service default/homeassistant/turn_on
2023-12-13 19:38:21.298322 WARNING HASS: Code: 400, error: 400: Bad Request

I fixed this by changing the black check to:

                if color == [0, 0, 0] or len(color) == 0:

However, I'm not sure if this is actually best fixed elsewhere, as I'm using quantization_method: libimagequant and perhaps other methods always return values.

After playing, let lights return to previous state

Is it possible to let the lights go back to their original state before they are changed by this addon?
When I stop playback, the lights stay at the state which was set by the addon.

Also, I've tested it with Kodi, works ok.

Support state attributes in condition like media player source

I would like to set up multiple sync pairs for the same media plyer (Spotify) to different lights (Living Room, Bedroom). The idea is that depending on the selected Spotify speaker lights sync in the appropriate room. The speaker is tracker in the source attribute of media player's state, so it is accessible in HA. However, the condition parameter of media_lights_sync only seems to support simple values. A way to drill down to state attributes would be a great addition.

RGB lights support - ESP8266

Hi @ericmatte,
In this issue report #1 I forgot to mention that my led stripe is on a ESP8266 with ESPhome firmware. In case you want to add it in your compatibility list.
Thanks

Mark

Apple Tv support

Hi,
thank you for your app, I would like to ask if it would be possible to implement Apple TV support to your code hass-atv-beta.
The available attribute I can get is this:
entity_picture: /api/media_player_proxy/media_player.soggiorno?token=[TOKEN REMOVED]cache=https://is1-ssl.mzstatic.com/image/thumb/Music128/v4/15/21/7f/15217f17-0e8a-e1b9-d5e8-45487b4e53ad/source/600x600bb.jpg

I don't know if log error could be helpful:

2020-04-20 14:20:26.490227 WARNING media_lights_sync: ------------------------------------------------------------
2020-04-20 14:20:26.488091 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 777, in worker
    funcref(entity, attr, old_state, new_state,
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 26, in change_lights_color
    rgb_colors = self.get_colors(newUrl)
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 40, in get_colors
    fd = urlopen(url)
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 509, in open
    req = Request(fullurl, data)
  File "/usr/lib/python3.8/urllib/request.py", line 328, in __init__
    self.full_url = url
  File "/usr/lib/python3.8/urllib/request.py", line 354, in full_url
    self._parse()
  File "/usr/lib/python3.8/urllib/request.py", line 383, in _parse
    raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: 'playing'

2020-04-20 14:20:26.482535 WARNING media_lights_sync: ------------------------------------------------------------
2020-04-20 14:20:26.480592 WARNING media_lights_sync: Worker Ags: {'id': '92741f2778e54bc9be97b46dec5c5818', 'name': 'media_lights_sync', 'objectid': '55f675cdb87e4e959f8458081a69335f', 'type': 'state', 'function': >, 'attribute': 'state', 'entity': 'media_player.soggiorno', 'new_state': 'playing', 'old_state': 'paused', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'attribute': None, '__thread_id': 'thread-1'}}
2020-04-20 14:20:26.477225 WARNING media_lights_sync: Unexpected error in worker for App media_lights_sync:
2020-04-20 14:20:26.474623 WARNING media_lights_sync: ------------------------------------------------------------
2020-04-20 14:20:26.305641 WARNING media_lights_sync: ------------------------------------------------------------
2020-04-20 14:20:26.303295 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 777, in worker
    funcref(entity, attr, old_state, new_state,
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 26, in change_lights_color
    rgb_colors = self.get_colors(newUrl)
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 40, in get_colors
    fd = urlopen(url)
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 509, in open
    req = Request(fullurl, data)
  File "/usr/lib/python3.8/urllib/request.py", line 328, in __init__
    self.full_url = url
  File "/usr/lib/python3.8/urllib/request.py", line 354, in full_url
    self._parse()
  File "/usr/lib/python3.8/urllib/request.py", line 383, in _parse
    raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: 'paused'

2020-04-20 14:20:26.297838 WARNING media_lights_sync: ------------------------------------------------------------
2020-04-20 14:20:26.295595 WARNING media_lights_sync: Worker Ags: {'id': '92741f2778e54bc9be97b46dec5c5818', 'name': 'media_lights_sync', 'objectid': '55f675cdb87e4e959f8458081a69335f', 'type': 'state', 'function': >, 'attribute': 'state', 'entity': 'media_player.soggiorno', 'new_state': 'paused', 'old_state': 'playing', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'attribute': None, '__thread_id': 'thread-1'}}
2020-04-20 14:20:26.292221 WARNING media_lights_sync: Unexpected error in worker for App media_lights_sync:
2020-04-20 14:20:26.288435 WARNING media_lights_sync: ------------------------------------------------------------
2020-04-20 14:20:24.034111 WARNING media_lights_sync: ------------------------------------------------------------
2020-04-20 14:20:24.031508 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 777, in worker
    funcref(entity, attr, old_state, new_state,
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 26, in change_lights_color
    rgb_colors = self.get_colors(newUrl)
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 40, in get_colors
    fd = urlopen(url)
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 509, in open
    req = Request(fullurl, data)
  File "/usr/lib/python3.8/urllib/request.py", line 328, in __init__
    self.full_url = url
  File "/usr/lib/python3.8/urllib/request.py", line 354, in full_url
    self._parse()
  File "/usr/lib/python3.8/urllib/request.py", line 383, in _parse
    raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: 'playing'

I that is not possible don't mind.. I thank you anyway for your hard work sor the community :)

Regards
Mark

rgbww_color mode support

Support of rgbww_color mode instead of only rgb_color mode

I found this app only support rgb_color mode.
Unfortunately, some of Wiz lights cannot convert rgb_color to rgbww_color correctly.

I think more and more rgbww_color product will be in the market, is it possible to support rgbww_color if specified in app.yaml?
Thanks.

compile_error

Describe the bug
After upgrading to aTV14 and pyatv component the app is not working anymore.

Screenshots or error stack trace

Appdaemon log when starting up

2020-10-08 10:46:39.279923 WARNING Error: ------------------------------------------------------------
2020-10-08 10:46:39.281562 WARNING Error: Unexpected error loading module: /config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py:
2020-10-08 10:46:39.282943 WARNING Error: ------------------------------------------------------------
2020-10-08 10:46:39.302107 WARNING Error: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 875, in check_app_updates
    await utils.run_in_executor(self, self.read_app, mod["name"], mod["reload"])
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 290, in run_in_executor
    response = future.result()
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/site-packages/appdaemon/app_management.py", line 668, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 8, in <module>
    from PIL import Image
  File "/usr/lib/python3.8/site-packages/PIL/Image.py", line 94, in <module>
    from . import _imaging as core
ImportError: Error loading shared library libtiff.so.5: No such file or directory (needed by /usr/lib/python3.8/site-packages/PIL/_imaging.cpython-38-arm-linux-gnueabihf.so)
2020-10-08 10:46:39.303928 WARNING Error: ------------------------------------------------------------
2020-10-08 10:46:39.305606 WARNING AppDaemon: Removing associated apps:
2020-10-08 10:46:39.307003 WARNING AppDaemon: media_lights_sync

Environment versions:

  • ad-media-lights-sync: v0.4.0
  • Home Assistant: 0.115.6
  • AppDaemon: 0.3.1

Thank you for checking.

Mark

Failed installing package python3-dev

Describe the bug
Unsatisfiable constraints for python3-dev dependency.

To Reproduce
Steps to reproduce the behavior:

  1. Setup the Prerequisites from the README
  2. Start AppDaemon

Error stack trace

ERROR: unsatisfiable constraints:
  python3-3.8.2-r0:
    breaks: python3-dev-3.8.2-r1[python3=3.8.2-r1]
    satisfies: world[python3=3.8.2-r0]
[18:16:58] FATAL: Failed installing package python3-dev
[cont-init.d] appdaemon.sh: exited 1.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------

Environment versions:

  • ad-media-lights-sync: 0.3.2
  • Home Assistant: 0.112.1
  • AppDaemon: 0.2.6

Unclear documentation - how to install?

Describe the bug

Hello, your installation instructions say "download to apps directory". I am running HASSIO, I do not see any apps directory even if I launch terminal add-on a do ls or ls ..

Where is the apps directory and how to download it there if running HASSIO?

(the HACS approach does not work for me either).

Thanks, Jan

Unavailable on hacs

With the new monthly HA updates this is no longer available through hacs.

Optional expose and publish all bulb colour values as attributes (also regardless of sync being enabled)

I have no idea how to python but have added a optional sensor that populates its state and attribute to an rgb value generated (I'm not sure which)
image
master...lichenophile:ad-media-lights-sync:master
Forgive my poor implementation, it's literally some cut an paste of a snippet I found elsewhere!

I'm having trouble figuring out how to:

  1. have these attributes pushed even if I do not wish to have lights syncing to these colours
  2. a way to have all colours generated for bulbs to be published as separate attributes correctly (less important)

I realise this might be a niche sorta request and out of scope for a project that is about syncing lights specifically, so no stress.

As an example of use, this allows me to template my media player card icon and progress bar colours to complement the blurred album art background.
(I'm using modified code from this persons fantastic customised mushroom card for anyone interested)
image

Another idea is to have the ability to try to always give a attribute for a colour steal that contrasts the overall colour of the image, so it doesn't blend with the background at all, or just different enough that it doesn't blend to the point of losing visability.

custom effects, brightness control

Hi,

I just got this running thanks to the help in the (now solved) issue #7; so I thought I'd pitch an idea to implement a feature allowing users to chose an -or ideally, multiple- effect(s) to use.

My test light is a WLED; it will run the Meteor effect when started manually (usually my lights are started via scene to automatically be set to correct brightness, color, and perhaps effect).

I thought the following might be nice additional features:

  • define which effect (or effects) to apply when using this script
  • allow to cycle through those effects via configurable period of time
  • define brightness to apply when initially starting this script

Something like

media_lights_sync:
# (...)
  use_current_brightness: False
  effect: "Breathe" # OR if multiple effects
  effects:
    - "Breathe" 
    - "Smooth Meteor"
    - "Twinklefox"
  cycle_effects: True # and IF TRUE
  cycle_period: 5    # apply different effect every 5 minutes
  brightness: 120
# (...)

Also something that just came to mind while typing this: define an effect and/or color in case cover art is either plain white (or brighter than threshold ), and/or if there is no cover art available.

Unfortunately, I am having a very hard time with writing appdaemon scripts (simply not enough knowledge about programming), so I cannot implement this, at least not any time soon.

Cheers!

Define transition time for color changes

Is your feature request related to a problem? Please describe.

Some lights (im my case LIFX) change colors instantly without a transition.

Describe the solution you'd like

Define a default transition time for the color change.

I think its really distracting if the colors change instantly, would be great if this could be implemented!

Cycle trough the lights

Description of what you want to happen.

Is it possible to make it so the colours cycle trough the lights.

For example:

I have 5 lights, they change colour according to spotify. there are 5 different colours.
Cycle the 5 colours trough the 5 lights, so you have a party kind of effect

Support for Spotify

Describe the bug

Hello in your description you do not have Spotify. Is it correct that Media Player Light Sync does not support Spotify? Thanks, Jan

Error when receiving new picture: Fast Octree and libimagequant are the only valid methods for quantizing RGBA images

Issue found by @jaseonline here #35 (comment)

Describe the bug

When loading from a Fire TV, the error is thrown. I do not have any other apps running via AppDaemon and is starts without error:

2021-02-22 21:08:51.725851 INFO AppDaemon: App 'media_lights_sync' added
2021-02-22 21:08:51.728707 INFO AppDaemon: Found 1 total apps
2021-02-22 21:08:51.730313 INFO AppDaemon: Starting Apps with 1 workers and 1 pins
2021-02-22 21:08:51.732747 INFO AppDaemon: Running on port 5050
2021-02-22 21:08:51.804776 INFO HASS: Evaluating startup conditions
2021-02-22 21:08:51.830006 INFO HASS: Startup condition met: hass state=RUNNING
2021-02-22 21:08:51.831183 INFO HASS: All startup conditions met
2021-02-22 21:08:51.878401 INFO AppDaemon: Got initial state from namespace default
2021-02-22 21:08:53.756757 INFO AppDaemon: Scheduler running in realtime
2021-02-22 21:08:53.797530 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2021-02-22 21:08:53.798942 INFO AppDaemon: Adding /config/appdaemon/apps/ad-media-lights-sync to module import path
2021-02-22 21:08:53.803360 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py
2021-02-22 21:08:53.862036 INFO AppDaemon: Initializing app media_lights_sync using class MediaLightsSync from module media_lights_sync
2021-02-22 21:08:54.072214 INFO media_lights_sync: Using default (MedianCut) quantization method
2021-02-22 21:08:54.074755 INFO media_lights_sync: Listening for picture changes on 'media_player.fire_tv_living_room'
2021-02-22 21:08:54.083922 INFO AppDaemon: App initialization complete

As soon as I start Fire TV and New picture received from 'media_player.fire_tv_living_room' (entity_picture) is received, the following error message occurs:

2021-02-22 21:09:30.311110 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-22 21:09:30.312142 WARNING media_lights_sync: Unexpected error in worker for App media_lights_sync:
2021-02-22 21:09:30.313061 WARNING media_lights_sync: Worker Ags: {'id': '0bbd3dabb3f3490897699c3c629fa457', 'name': 'media_lights_sync', 'objectid': 'eda18367f1e941829417c751405c73a2', 'type': 'state', 'function': <bound method MediaLightsSync.change_lights_color of <media_lights_sync.MediaLightsSync object at 0x7f7f854b50>>, 'attribute': 'entity_picture', 'entity': 'media_player.fire_tv_living_room', 'new_state': '/api/media_player_proxy/media_player.fire_tv_living_room?token=36acae52cf4967326d22239587fb79432f886c803f5956e217402fa2b186ce65&cache=1614028163.912325', 'old_state': '/api/media_player_proxy/media_player.fire_tv_living_room?token=36acae52cf4967326d22239587fb79432f886c803f5956e217402fa2b186ce65&cache=1614028153.938489', 'pin_app': True, 'pin_thread': 0, 'kwargs': {'attribute': 'entity_picture', '__thread_id': 'thread-0'}}
2021-02-22 21:09:30.313901 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-22 21:09:30.318557 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 900, in worker
    funcref(
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 56, in change_lights_color
    rgb_colors = self.get_colors(url)
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 115, in get_colors
    palette = im.quantize(colors=len(self.lights), method=self.quantization_method).getpalette()
  File "/usr/lib/python3.8/site-packages/PIL/Image.py", line 1081, in quantize
    raise ValueError(
ValueError: Fast Octree (method == 2) and libimagequant (method == 3) are the only valid methods for quantizing RGBA images

The image can be viewed fine in my web browser via the api URL.

Additional information

From the PIL.Image documentation, it seems to not work when the image mode is RGBA.

Environment versions

  • ad-media-lights-sync: v0.7.0

No longer functioning - Unable to fetch artwork

Describe the bug

No longer produces a resulting colour change of my LIFX light-bulbs.
Previously working.
My config hasn't changed, and I've checked all configuration is still correct.
No errors is output log.

Steps to reproduce the behaviour:

  1. Toggle the associated input boolean to on
  2. Play the next track in spotify
  3. No resulting colour change on my LIFX bulbs

Expected behaviour:

Colour change of my LIFX bulbs based on album art

Environment versions:

  • ad-media-lights-sync: Latest version v1.0.0
  • Home Assistant: core-2021.11.5, supervisor-2021.12.1
  • AppDaemon: AppDaemon 4 v0.7.1

Additional context

HA media player still functions and displays album art, Spotify Mood Lights Sync also still behaves as expected.

image

working with Logitech Squeezebox integration

Is your feature request related to a problem? Please describe.
No.

Description of what the problem is.
There is no problem.

Describe the solution you'd like
None.

Describe alternatives you've considered
None.

Additional context
As titel mentions, it's working with the Logitech Squeezebox integration. You can add it to the list.
Thanks for the app!

Trigger immediately when the switch is on

Is your feature request related to a problem? Please describe.

It would be nice if you didn't have to wait for the next track for the colours to be applied.

Describe the solution you'd like

I added a listener to the input boolean for controlling light sync, but I don't know if this would work for those not adding the override switch in place.

Describe alternatives you've considered

Sorry, none so far!

Additional context

Here's my code for this.

                if self.condition["entity"] is not None:
                    self.listen_state(self.start_now, self.condition["entity"])

    def start_now(self, entity, attribute, old, new, kwargs):
        if new == "on":
            media_players = self.args["media_player"] if isinstance(self.args["media_player"], list) else [self.args["media_player"]]
            for media_player in media_players:
                for photo_attribute in PICTURE_ATTRIBUTES:
                    self.change_lights_color(media_player, photo_attribute, "", self.get_state(media_player, photo_attribute), kwargs);

Help configuration for Condition

Describe the bug

I want to use media-light-sync only at night and if a switch for party mode is off. So I added a condition as following:


media_lights_sync_studio:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.studio
  lights:
    - light.jack_lamp
    - light.lampada_scrivania
  ha_url: http://192.168.2.101:8123
  reset_lights_after: true
  use_saturated_colors: true
  use_current_brightness: false
  condition:
    - condition: template
      value_template: >-
        "{{ is_state('switch.lafesta', 'off') and state_attr('sun.sun', 'elevation') | int < 2 }}"

Below the logs:

2021-09-08 16:03:29.687804 WARNING media_lights_sync_studio: ------------------------------------------------------------
2021-09-08 16:03:29.696478 WARNING media_lights_sync_studio: ------------------------------------------------------------
2021-09-08 16:03:29.696873 WARNING media_lights_sync_studio: Unexpected error in worker for App media_lights_sync_studio:
2021-09-08 16:03:29.697468 WARNING media_lights_sync_studio: Worker Ags: {'id': '9a01d37e74ca413a8b6f53bd81e8d6df', 'name': 'media_lights_sync_studio', 'objectid': '2b62939a27424a349243e6d690693394', 'type': 'state', 'function': <bound method MediaLightsSync.change_lights_color of <media_lights_sync.MediaLightsSync object at 0x7fc00e5babb0>>, 'attribute': 'entity_picture', 'entity': 'media_player.studio', 'new_state': 'https://i.scdn.co/image/ab67616d00001e02232711f7d66a1e19e89e28c5', 'old_state': 'https://i.scdn.co/image/ab67616d00001e02caaa456c44f69f10c8b2aa53', 'pin_app': True, 'pin_thread': 3, 'kwargs': {'attribute': 'entity_picture', '__thread_id': 'thread-3'}}
2021-09-08 16:03:29.697766 WARNING media_lights_sync_studio: ------------------------------------------------------------
2021-09-08 16:03:29.698164 WARNING media_lights_sync_studio: Traceback (most recent call last):
File "/usr/lib/python3.9/site-packages/appdaemon/threading.py", line 903, in worker
funcref(
File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 42, in change_lights_color
if new_url == old_url or not self.can_change_colors():
File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 71, in can_change_colors
return self.condition is None or self.get_state(self.condition["entity"]) == self.condition["state"]
TypeError: list indices must be integers or slices, not str

2021-09-08 16:03:29.698385 WARNING media_lights_sync_studio: ------------------------------------------------------------

Some time ago this config worked for a while:

media_lights_sync_studio:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.studio
  lights:
    - light.jack_lamp
    - light.lampada_scrivania
  ha_url: http://192.168.2.101:8123
  reset_lights_after: true
  use_saturated_colors: true
  use_current_brightness: false
  condition:
    - entity:  switch.lafesta
      state: "off"
    - condition: template
      value_template: "{{ state_attr('sun.sun', 'elevation') < 2 }}"

Environment versions

  • ad-media-lights-sync: 1.0.0
  • Home Assistant: 2021.9.4
  • AppDaemon: 0.7.0 (add on version)

Any hint?

[Feature Request] adding camera entity to geet pictures

Hello,

I have Hyperion running for my ambilight. This platform adds a camera with the actual picture processed by ambilight. This updates the picture much faster than the 10 seconds of media player.
Would it be possible to use camera iso media_player?

Seems working but possible to decrease the intervall to scan?

Problem with cam is that the url does not change. Media_player seems changing the url?

Maybe it would be nice having a way to pull / update the pic to proceed every x seconds?

Restore previous light situation when music is over

Is your feature request related to a problem? Please describe.

I think that it would be great if lights are restored to previous status (on off but also brightness).

For example I use this code to change and restore a light status if I turn on main light in a room:

  - alias: Studio - Spegni lampade se lampadario si accende
    initial_state: true
    trigger:
    - platform: state
      entity_id: light.studio
      from: 'off'
      to: 'on'
    condition: []
    action:
    - service: scene.create
      data:
        scene_id: studioprima
        snapshot_entities:
        - light.lampada_scrivania
        - light.jack_lamp
    - service: light.turn_off
      data:
        entity_id: 
          - light.lampada_scrivania
          - light.jack_lamp

  - alias: Studio - Accendi lampade se lampadario si spegne (ed erano giΓ  accese)
    trigger:
    - platform: state
      entity_id: light.studio
      from: 'on'
      to: 'off'
    condition: []
    action:
    - service: scene.turn_on
      data:
        entity_id: scene.studioprima

Can it be added as default in your app?

Unknown URL Type

Describe the bug

While Syncing the lights there is an error logged ( and the lights wont sync)

To Reproduce

Use This Config

media_lights_sync:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.<player>
  lights:
    - light.wohnzimmer_lampe_2
    - light.wohnzimmer_lampe_1
    - light.wled
    - light.pc_links
    - light.pc_rechts
  ha_url: <ip>:8123
  reset_lights_after: true
  use_saturated_colors: false
  use_current_brightness: false
  condition:
    entity: input_boolean.sync_lights_wohnzimmer
    state: "on"

Expected behavior

Lights syncing

Screenshots or error stack trace

2021-08-30 21:19:16.403118 INFO media_lights_sync: New picture received from 'media_player.wohnzimmer' (entity_picture)
2021-08-30 21:19:16.419620 WARNING media_lights_sync: ------------------------------------------------------------
2021-08-30 21:19:16.420667 WARNING media_lights_sync: Unexpected error in worker for App media_lights_sync:
2021-08-30 21:19:16.421933 WARNING media_lights_sync: Worker Ags: {'id': '1a68016d493a4b6d8a79064704aaa9e3', 'name': 'media_lights_sync', 'objectid': '8ac7c56312bd45518d56230896d3ad5e', 'type': 'state', 'function': <bound method MediaLightsSync.change_lights_color of <media_lights_sync.MediaLightsSync object at 0x7fb0ddcfa0>>, 'attribute': 'entity_picture', 'entity': 'media_player.wohnzimmer', 'new_state': '/api/media_player_proxy/media_player.wohnzimmer?token=e9a77d64d181201a8e8f54964c80a720a1f2933cb2edfa1192860a22af9c16ce&cache=3dcee92f534ef9fb', 'old_state': '/api/media_player_proxy/media_player.wohnzimmer?token=e9a77d64d181201a8e8f54964c80a720a1f2933cb2edfa1192860a22af9c16ce&cache=10b5490d6a27e975', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'attribute': 'entity_picture', '__thread_id': 'thread-1'}}
2021-08-30 21:19:16.422838 WARNING media_lights_sync: ------------------------------------------------------------
2021-08-30 21:19:16.428977 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/threading.py", line 903, in worker
    funcref(
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 57, in change_lights_color
    rgb_colors = self.get_colors(url)
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 114, in get_colors
    fd = urlopen(url)
  File "/usr/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.9/urllib/request.py", line 501, in open
    req = Request(fullurl, data)
  File "/usr/lib/python3.9/urllib/request.py", line 320, in __init__
    self.full_url = url
  File "/usr/lib/python3.9/urllib/request.py", line 346, in full_url
    self._parse()
  File "/usr/lib/python3.9/urllib/request.py", line 375, in _parse
    raise ValueError("unknown url type: %r" % self.full_url)
ValueError: unknown url type: '/api/media_player_proxy/media_player.wohnzimmer?token=e9a77d64d181201a8e8f54964c80a720a1f2933cb2edfa1192860a22af9c16ce&cache=3dcee92f534ef9fb'
2021-08-30 21:19:16.429838 WARNING media_lights_sync: ------------------------------------------------------------

Netflix (and other apps) on Fire TV breaks media lights sync with 500 error

Whenever I load up the Netflix app on my Fire TV, it breaks the media lights sync. Automation reverts back to normal when I close down Netflix and return to the Home screen. Here are the logs:

2021-02-10 01:07:59.417980 INFO media_lights_sync: New picture received from 'media_player.fire_tv_living_room' (entity_picture)
2021-02-10 01:08:05.883659 INFO media_lights_sync: Set 'light.tv_hue_lightstrip' light:
{'rgb_color': [63, 130, 191]}
2021-02-10 01:08:09.390403 INFO media_lights_sync: New picture received from 'media_player.fire_tv_living_room' (entity_picture)
2021-02-10 01:08:09.516680 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-10 01:08:09.517952 WARNING media_lights_sync: Unexpected error in worker for App media_lights_sync:
2021-02-10 01:08:09.519060 WARNING media_lights_sync: Worker Ags: {'id': 'bea241ddaaf644589ad0f516c38753a5', 'name': 'media_lights_sync', 'objectid': 'd7b5cbc4f111482f9331862d20a2f648', 'type': 'state', 'function': <bound method MediaLightsSync.change_lights_color of <media_lights_sync.MediaLightsSync object at 0x7f82c907f0>>, 'attribute': 'entity_picture', 'entity': 'media_player.fire_tv_living_room', 'new_state': '/api/media_player_proxy/media_player.fire_tv_living_room?token=73def4c443ecf1dfd8e0ae3a87336cdc47b1ae9ac2189b4546727db90c353da3&cache=1612919289.360683', 'old_state': '/api/media_player_proxy/media_player.fire_tv_living_room?token=73def4c443ecf1dfd8e0ae3a87336cdc47b1ae9ac2189b4546727db90c353da3&cache=1612919279.388156', 'pin_app': True, 'pin_thread': 1, 'kwargs': {'attribute': 'entity_picture', '__thread_id': 'thread-1'}}
2021-02-10 01:08:09.520043 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-10 01:08:09.521903 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 900, in worker
    funcref(
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 52, in change_lights_color
    rgb_colors = self.get_colors(self.format_url(new_url, entity, attribute))
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 103, in get_colors
    fd = urlopen(url)
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 500: Internal Server Error
2021-02-10 01:08:09.522998 WARNING media_lights_sync: ------------------------------------------------------------

You can see it changes to RGB 63, 130, 191 on the Home screen and then breaks as soon as I load up Netflix. Other Apps are fine and I can see the entity_picture does not change when Netflix ids the source.

Home screen:
entity_picture: /api/media_player_proxy/media_player.fire_tv_living_room?token=73def4c443ecf1dfd8e0ae3a87336cdc47b1ae9ac2189b4546727db90c353da3&cache=1612919819.383837

Netflix:
entity_picture: /api/media_player_proxy/media_player.fire_tv_living_room?token=73def4c443ecf1dfd8e0ae3a87336cdc47b1ae9ac2189b4546727db90c353da3&cache=1612919929.417483

configuration.yaml

media_player:
  - platform: androidtv
    name: Fire TV Living Room
    device_class: firetv
    host: 192.168.1.37
    adb_server_ip: 127.0.0.1
    adb_server_port: 5037
    exclude_unnamed_apps: true

appdaemon.yaml (Located Redacted)

---
secrets: /config/secrets.yaml
appdaemon:
  latitude: 0.0
  longitude: 0.0
  elevation: 0
  time_zone: Europe/London
  plugins:
    HASS:
      type: hass
http:
  url: http://127.0.0.1:5050
admin:
api:
hadashboard:

apps.yaml (HA URL Redacted)

---
media_lights_sync:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.fire_tv_living_room
  lights:
    - light.tv_hue_lightstrip
  ha_url: http://192.168.1.XX:8123
  reset_lights_after: false
  use_saturated_colors: true
  use_current_brightness: true
  condition:
    entity: media_player.samsung_ue55hu7500
    state: "on"

I also use ADB - Android Debug Bridge to connect my Fire TV (IP Redacted) and this works fine based on the logs:

[08:57:41] INFO: Starting the Android Debug Bridge server...
[08:57:41] INFO: Connecting to device: 192.168.1.37...
connected to 192.168.1.XX:5555
[08:59:11] INFO: Connecting to device: 192.168.1.37...
already connected to 192.168.1.XX:5555

Add Brightness

Your app is just awesome.. Like this I get like a pseudo anbilight for my TV. THe only thing is that at the moment it turn the light to 100% each time. Is there maybe a way to adjust brightness? Would be awesome

Thanks anyway for this great app!

Your fan!

P.S. works like a charm :)

"no module name PIL"

Hi,

I just started using AppDaemon for my Home Assistant a few days ago and this app seems so cool, so I wanted to try it. Unfortunately, it will not work due to missing modules, I assume.

This is my appdaemon.yaml

appdaemon:
  threads: 10
  plugins:
    HASS:
      type: hass
      ha_url: ""
      token: ""
admin:

api:

# added these lines as in README.me; added the extra "PIL" underneath "Pillow" just as a test, didn't make a difference
system_packages:
  - musl
  - make
  - g++
  - python3-dev
  - build-base
  - jpeg-dev
  - zlib-dev
python_packages:
  - Pillow
  - PIL

log:
  logfile: STDOUT
  errorfile: STDERR
hadashboard:
  dash_url: ""

After adding the lines for ad-media-lights-sync to my apps.yaml, these errors occured

2020-05-04 11:07:22.087407 INFO AppDaemon: Loading App Module: /conf/apps/media_lights_sync.py
2020-05-04 11:07:22.095161 WARNING AppDaemon: ------------------------------------------------------------
2020-05-04 11:07:22.095370 WARNING AppDaemon: Unexpected error loading module: /conf/apps/media_lights_sync.py:
2020-05-04 11:07:22.095468 WARNING AppDaemon: ------------------------------------------------------------
2020-05-04 11:07:22.097138 WARNING AppDaemon: Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 2026, in check_app_updates
    self.read_app(mod["name"], mod["reload"])
  File "/usr/local/lib/python3.6/site-packages/appdaemon/appdaemon.py", line 1809, in read_app
    self.modules[module_name] = importlib.import_module(module_name)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/conf/apps/media_lights_sync.py", line 6, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

I am running AppDaemon in a docker container; do I have to manually install these packages to the docker container somehow? I assumed that the lines in appdaemon.yaml would automatically take care of this for me, but then it wouldn't be missing the module..?

Thank you in advance for your help :)

repository failure

Hi there,

I found your integration for syncing lights to the media player card.

When trying to add the repository to HACS is get the following error:

<Integration ericmatte/ad-media-lights-sync> Repository structure for v1.2.0 is not compliant

Can you elaborate or help me?

Not working with Cync by GE lights and bulbs

Describe the bug

"Media Player"(android TV) is setup and watching the app daemon can see it working and making calls but the lights never change or do anything.

Expected behavior

Lights change or respond.

Screenshots or error stack trace

No response.

Environment versions

  • ad-media-lights-sync: 1.2.0
  • Home Assistant: 2023.2.5
  • AppDaemon: 0.11.0

App configuration (from you apps.yaml)

media_lights_sync:
module: media_lights_sync
class: MediaLightsSync
media_player: media_player.fire_tv_192_168_1_48
lights:
- light.bed_light
- light.bedroom_lights
ha_url: homeassistant.local:8123
reset_lights_after: true
use_saturated_colors: true
use_current_brightness: false
condition:
entity: input_boolean.sync_tv_lights
state: "on"

Yandex.Station

Hello! Is it possible to add support for Yandex Station? Thank you.

Better algorithm to identify prevalent colors

Describe the bug

Hello, all colors are still very mild even when I set saturation to true. for example I would expect that for this song the color would be completely red, but in fact it is very light pink: https://www.discogs.com/Jean-Michel-Jarre-The-Concerts-In-China/release/106089

Here is settings in apps.yaml in folder apps:

media_lights_sync:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.libreelec
  lights:
    - light.21800710dc4f22741488_2
  ha_url: http://10.0.0.54:8123
  reset_lights_after: true
  use_saturated_colors: true
  use_current_brightness: true

image

Anything I can try? Thank you, Jan

Option to ignore completely black entity pictures

Hi,

would it be possible to ignore new entity pictures that are just black instead of changing all lights to 'rgb_color': [0, 0, 0] ?

I'm syncing the colors of an Android TV device and sometimes Home Assistant gets a black entity_picture.
Unfortunately, some of my Zigbee lights turn to a bright green when set to 'rgb_color': [0, 0, 0] and I would like to avoid that.

Maybe there could be an option to ignore changes to 'rgb_color': [0, 0, 0] and 'rgb_color': [255, 255, 255], so completely black and white pictures get skipped?

Thank you for considering this!

How does it works?

hey, I hope is that I rise up a thread here ok?!?

i have been trying to synchronize my lamps with music for many hours...

I installed appdaemon as an integration in the supervisor. I also installed this add-on and hopefully adjusted it correctly.

but maybe I misunderstood all of this ...
this morning i already wrote some scenes for the party light. that works quite well so far.

now I would like to trigger this a bit with the music;)
what does this addon do?

When music is playing on a media player, do the lights change color?

spotify_mood_lights_sync:
  module: spotify_mood_lights_sync
  class: SpotifyMoodLightsSync
  client_id: !secret spotify_client_id
  client_secret: !secret spotify_client_secret
  media_player: media_player.nathalies_echo_dot
  light: light.extended_color_light_2
  color_profile: default
  mode: direct
  max_retries: 1
  custom_profile:
    - point: [ 0, 0 ]
      color: [ 0, 0, 255 ]
    - point: [ 1, 0 ]
      color: [ 0, 255, 0 ]
    - point: [ 0, 1 ]
      color: [ 255, 0, 0 ]
    - point: [ 1, 1 ]
      color: [ 255, 255, 0 ]

Errors in AppDaemon Log/Lights not changing

Hello,
I have installed via Hacs and added the config as follows to my apps.yaml:

media_lights_sync:
  module: media_lights_sync
  class: MediaLightsSync
  media_player: media_player.google_home_mini
  lights: light.led1_wohnzimmer
  ha_url: https://192.168.1.137:8123
  reset_lights_after: true
  use_saturated_colors: false
  use_current_brightness: false
  condition:
    entity: input_boolean.sync_tv_lights
    state: "on"

If I look into the developer Tools,I can see the picture entities changing if I change the song, but light is not changing. Following issues are in the AppDaemon Log:

AppDaemon: Initializing app media_lights_sync using class MediaLightsSync from module media_lights_sync
2021-02-05 02:34:45.125949 INFO media_lights_sync: Listening for picture changes on 'media_player.google_home_mini'
2021-02-05 02:34:45.132420 INFO AppDaemon: App initialization complete
2021-02-05 02:35:09.381926 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-05 02:35:09.382875 WARNING media_lights_sync: Unexpected error in worker for App media_lights_sync:
2021-02-05 02:35:09.383763 WARNING media_lights_sync: Worker Ags: {'id': '0ae6673be2e249bfa7e8c4daa08478e2', 'name': 'media_lights_sync', 'objectid': 'db58209fdff64019ba2a6ee620469a8f', 'type': 'state', 'function': <bound method MediaLightsSync.change_lights_color of <media_lights_sync.MediaLightsSync object at 0xb4e8e460>>, 'attribute': 'entity_picture_local', 'entity': 'media_player.google_home_mini', 'new_state': '/api/media_player_proxy/media_player.google_home_mini?token=2354807e7a66d2b2c03ea241a1b07dacc667f5b75c256d0c4cde1f4dc8973834&cache=750effe1c450c808', 'old_state': '/api/media_player_proxy/media_player.google_home_mini?token=2354807e7a66d2b2c03ea241a1b07dacc667f5b75c256d0c4cde1f4dc8973834&cache=924d592084ff9f1a', 'pin_app': True, 'pin_thread': 2, 'kwargs': {'attribute': 'entity_picture_local', '__thread_id': 'thread-2'}}
2021-02-05 02:35:09.384670 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-05 02:35:09.403697 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 900, in worker
    funcref(
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 44, in change_lights_color
    self.store_initial_lights_states()
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 67, in store_initial_lights_states
    self.initial_lights_states = [self.get_state(self.lights[i], attribute="all") for i in range(len(self.lights))]
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 67, in <listcomp>
    self.initial_lights_states = [self.get_state(self.lights[i], attribute="all") for i in range(len(self.lights))]
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 195, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 299, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/usr/lib/python3.8/site-packages/appdaemon/adapi.py", line 1392, in get_state
    return await self.AD.state.get_state(self.name, namespace, entity_id, attribute, default, copy, **kwargs)
  File "/usr/lib/python3.8/site-packages/appdaemon/state.py", line 389, in get_state
    raise ValueError("{}: Querying a specific attribute is only possible for a single entity".format(name))
ValueError: media_lights_sync: Querying a specific attribute is only possible for a single entity
2021-02-05 02:35:09.404456 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-05 02:35:09.423361 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-05 02:35:09.424312 WARNING media_lights_sync: Unexpected error in worker for App media_lights_sync:
2021-02-05 02:35:09.425138 WARNING media_lights_sync: Worker Ags: {'id': '87ab009ece19400dbabecee9ea0d2f01', 'name': 'media_lights_sync', 'objectid': 'db58209fdff64019ba2a6ee620469a8f', 'type': 'state', 'function': <bound method MediaLightsSync.change_lights_color of <media_lights_sync.MediaLightsSync object at 0xb4e8e460>>, 'attribute': 'entity_picture', 'entity': 'media_player.google_home_mini', 'new_state': 'https://i.scdn.co/image/ab67616d00001e023797253ef8b94a9e35e1b7c6', 'old_state': 'https://i.scdn.co/image/ab67616d00001e0204a9270e5d53595a1d176779', 'pin_app': True, 'pin_thread': 2, 'kwargs': {'attribute': 'entity_picture', '__thread_id': 'thread-2'}}
2021-02-05 02:35:09.425838 WARNING media_lights_sync: ------------------------------------------------------------
2021-02-05 02:35:09.430778 WARNING media_lights_sync: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 900, in worker
    funcref(
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 44, in change_lights_color
    self.store_initial_lights_states()
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 67, in store_initial_lights_states
    self.initial_lights_states = [self.get_state(self.lights[i], attribute="all") for i in range(len(self.lights))]
  File "/config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py", line 67, in <listcomp>
    self.initial_lights_states = [self.get_state(self.lights[i], attribute="all") for i in range(len(self.lights))]
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 195, in inner_sync_wrapper
    f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
  File "/usr/lib/python3.8/site-packages/appdaemon/utils.py", line 299, in run_coroutine_threadsafe
    result = future.result(self.AD.internal_function_timeout)
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 388, in __get_result
    raise self._exception
  File "/usr/lib/python3.8/site-packages/appdaemon/adapi.py", line 1392, in get_state
    return await self.AD.state.get_state(self.name, namespace, entity_id, attribute, default, copy, **kwargs)
  File "/usr/lib/python3.8/site-packages/appdaemon/state.py", line 389, in get_state
    raise ValueError("{}: Querying a specific attribute is only possible for a single entity".format(name))
ValueError: media_lights_sync: Querying a specific attribute is only possible for a single entity
2021-02-05 02:35:09.431700 WARNING media_lights_sync: ------------------------------------------------------------

Environment versions

  • ad-media-lights-sync: 0.6.0
  • Home Assistant: 2021.2
  • AppDaemon: 0.4.1

Can you help me or fix this issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.