ericmatte / ad-media-lights-sync

💡 AppDaemon App that synchronize RGB lights with the thumbnail of a media player in Home Assistant. Be sure to ⭐️ my repo!
MIT License
99 stars 9 forks source link

Help with initial setup #52

Closed PottsNet closed 2 years ago

PottsNet commented 2 years ago

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"
PottsNet commented 2 years ago

Under Entities in AppDaemon the callback are increasing by one with every song.

PottsNet commented 2 years ago

Not sure if this helps?

image
PottsNet commented 2 years ago

appdaemon.yaml

secrets: /config/secrets.yaml
appdaemon:
  latitude: xxxxxx
  longitude: xxxxxx
  elevation: 70
  time_zone: Australia/Sydney
  plugins:
    HASS:
      type: hass
http:
  url: http://homeassistant.local:5050
admin:
api:
hadashboard:
PottsNet commented 2 years ago

AppDaemon log looks good too:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing... 
-----------------------------------------------------------
 Add-on: AppDaemon
 Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
-----------------------------------------------------------
 Add-on version: 0.8.2
 You are running the latest version of this add-on.
 System: Home Assistant OS 7.5  (armv7 / raspberrypi4)
 Home Assistant Core: 2022.3.7
 Home Assistant Supervisor: 2022.03.5
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing... 
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] appdaemon.sh: executing... 
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/armv7/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/armv7/APKINDEX.tar.gz
v3.15.2-29-g0e3027f82f [https://dl-cdn.alpinelinux.org/alpine/v3.15/main]
v3.15.2-29-g0e3027f82f [https://dl-cdn.alpinelinux.org/alpine/v3.15/community]
OK: 15434 distinct packages available
(1/16) Installing py3-olefile (0.46-r5)
(2/16) Installing libpng (1.6.37-r1)
(3/16) Installing freetype (2.11.0-r0)
(4/16) Installing libimagequant (2.16.0-r0)
(5/16) Installing libjpeg-turbo (2.1.2-r0)
(6/16) Installing lcms2 (2.12-r1)
(7/16) Installing openjpeg (2.4.0-r2)
(8/16) Installing libwebp (1.2.2-r0)
(9/16) Installing zstd-libs (1.5.0-r0)
(10/16) Installing tiff (4.3.0-r0)
(11/16) Installing libxau (1.0.9-r0)
(12/16) Installing libmd (1.0.3-r0)
(13/16) Installing libbsd (0.11.3-r1)
(14/16) Installing libxdmcp (1.1.3-r0)
(15/16) Installing libxcb (1.14-r2)
(16/16) Installing py3-pillow (8.4.0-r3)
OK: 88 MiB in 83 packages
Looking in links: https://wheels.home-assistant.io/alpine-3.14/armv7/
Requirement already satisfied: Pillow in /usr/lib/python3.9/site-packages (8.4.0)
[cont-init.d] appdaemon.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[17:59:17] INFO: Starting AppDaemon...
2022-03-28 17:59:19.454562 INFO AppDaemon: AppDaemon Version 4.2.1 starting
2022-03-28 17:59:19.454948 INFO AppDaemon: Python version is 3.9.7
2022-03-28 17:59:19.455279 INFO AppDaemon: Configuration read from: /config/appdaemon/appdaemon.yaml
2022-03-28 17:59:19.455625 INFO AppDaemon: Added log: AppDaemon
2022-03-28 17:59:19.455953 INFO AppDaemon: Added log: Error
2022-03-28 17:59:19.456382 INFO AppDaemon: Added log: Access
2022-03-28 17:59:19.458296 INFO AppDaemon: Added log: Diag
2022-03-28 17:59:19.507909 INFO AppDaemon: Loading Plugin HASS using class HassPlugin from module hassplugin
2022-03-28 17:59:19.593119 INFO HASS: HASS Plugin Initializing
2022-03-28 17:59:19.593730 INFO HASS: HASS Plugin initialization complete
2022-03-28 17:59:19.594784 INFO AppDaemon: Initializing HTTP
2022-03-28 17:59:19.595619 INFO AppDaemon: Using 'ws' for event stream
2022-03-28 17:59:19.604133 INFO AppDaemon: Starting API
2022-03-28 17:59:19.611743 INFO AppDaemon: Starting Admin Interface
2022-03-28 17:59:19.612572 INFO AppDaemon: Starting Dashboards
2022-03-28 17:59:19.647965 INFO HASS: Connected to Home Assistant 2022.3.7
2022-03-28 17:59:19.692459 INFO AppDaemon: App 'hello_world' added
2022-03-28 17:59:19.697081 INFO AppDaemon: App 'media_lights_sync' added
2022-03-28 17:59:19.699231 INFO AppDaemon: Found 2 total apps
2022-03-28 17:59:19.700579 INFO AppDaemon: Starting Apps with 2 workers and 2 pins
2022-03-28 17:59:19.703839 INFO AppDaemon: Running on port 5050
2022-03-28 17:59:19.852188 INFO HASS: Evaluating startup conditions
2022-03-28 17:59:19.872465 INFO HASS: Startup condition met: hass state=RUNNING
2022-03-28 17:59:19.873448 INFO HASS: All startup conditions met
2022-03-28 17:59:19.975860 INFO AppDaemon: Got initial state from namespace default
2022-03-28 17:59:21.721633 INFO AppDaemon: Scheduler running in realtime
2022-03-28 17:59:21.730091 INFO AppDaemon: Adding /config/appdaemon/apps to module import path
2022-03-28 17:59:21.731664 INFO AppDaemon: Adding /config/appdaemon/apps/ad-media-lights-sync to module import path
2022-03-28 17:59:21.738824 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/hello.py
2022-03-28 17:59:21.755109 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/ad-media-lights-sync/media_lights_sync.py
2022-03-28 17:59:21.796137 INFO AppDaemon: Initializing app hello_world using class HelloWorld from module hello
2022-03-28 17:59:21.799913 INFO AppDaemon: Initializing app media_lights_sync using class MediaLightsSync from module media_lights_sync
2022-03-28 17:59:21.997830 INFO hello_world: Hello from AppDaemon
2022-03-28 17:59:22.000308 INFO hello_world: You are now ready to run Apps!
2022-03-28 17:59:22.007834 INFO media_lights_sync: Using default quantization method
2022-03-28 17:59:22.010791 INFO media_lights_sync: Listening for picture changes on 'media_player.lounge_apple_tv_2'
2022-03-28 17:59:22.018651 INFO AppDaemon: App initialization complete
ericmatte commented 2 years ago

Hi @PottsNet,

Your AppDeamon config and appdaemon.yaml looks good, and the logs shows that the app has been initialized without errors. I have some suggestions of what you should check.

First, make sure that your media_player is actually sending thumbnails to Home Assistant:

CleanShot 2022-03-31 at 18 48 50

CleanShot 2022-03-31 at 18 50 32


After that, you should check the logs directly in AppDaemon:

CleanShot 2022-03-31 at 18 52 26

If your don't see anything in this section when you change the song on your media_player, there may be an error, that you can check here:

CleanShot 2022-03-31 at 18 54 22


As for your apps.yaml, here is some things your could try out:

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
+  ha_url: http://192.168.1.123:8123/
  reset_lights_after: true
  use_saturated_colors: true
  use_current_brightness: false
-  condition:
-    entity: input_boolean.sync_tv_lights
-    state: "on"

Let me know if it helps!

ericmatte commented 2 years ago

Also, just to be sure, does your FB56-ZCW11HG1.2 supports RGB values from Home Assistant?

PottsNet commented 2 years ago

Excellent. Thank you. Changing to IP and removing conditions fixed it. Is there an option I can use to turn the automation on an off without turning the media player off?

ericmatte commented 2 years ago

That would be to add back the condition you had with input_boolean.sync_tv_lights. If your input_boolean.sync_tv_lights is on, the lights will change their color when your media_player is showing a new thumbnail.

If the condition is false, the lights won't change et will stay the same as their current state.

Keep in mind that the condition input for this app is really basic by design and can only check the current state value of your entity.

Cheers

PottsNet commented 2 years ago

Thanks Eric. Would it be difficult to change the state of input_boolean.sync_tv_lights via a switch in Home Assistant or is that already a feature and I have missed it?

ericmatte commented 2 years ago

Actually, the input_boolean.sync_tv_lights should be a helper input that you create in your Home Assistant like so:

CleanShot 2022-04-06 at 09 19 27

You give it a name and after that use its Entity ID into the app condition field. After that it should appear in your lovelace dashboard as a simple switch.

PottsNet commented 2 years ago

That is very cool! Neat party trick :). Thanks for your effort in creating and help with setting it up. The new switch in HA is just what I needed. My wife wasn't impressed with the lights changing all the time :) IMG_5404 )

ericmatte commented 2 years ago

That must be a nice setup you have with all the recessed downlights!

Thank you for using this app, and have fun!

PottsNet commented 2 years ago

Thanks Eric. It's probably nicer in life than in this photo but you get the idea :) Ceiling lights are considered primary lights in Australia so every room has them. Table lamps are mostly decorative so that's why I have six DLs. Also allows you to turn the lights off in front of the TV and still have low lighting over your head. Thanks again! IMG_5405