b0mbays / continuously_casting_dashboards

HACS Integration for continuously casting a Home Assistant dashboard to your Google Chromecast Displays
MIT License
208 stars 9 forks source link

state_triggers: force_cast does not work, but time_out makes it work #78

Open timconinx opened 1 week ago

timconinx commented 1 week ago

I get some very weird behaviour with a state trigger (coupled to an input_boolean helper entity)

Configuration looks like this:

continuously_casting_dashboards:
  logging_level: debug
  cast_delay: 15
  start_time: "07:00"
  end_time: "01:00"
  devices:
    "Living Room display":
      - dashboard_url: "http://192.168.1.103:8123/db-badkamer/0?kiosk"
        volume: 2
  state_triggers:
    "Living Room display":
      - entity_id: "input_boolean.badkamer_button_pressed"
        to_state: "on"
        dashboard_url: "http://192.168.1.103:8123/db-badkamer/0?kiosk"
        force_cast: true
        time_out: 10

This configuration did not work without the time_out parameter, with the time_out parameter it works but really slowly. Look at the debug logs:

2024-09-29 19:54:59.350 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Entity 'input_boolean.badkamer_button_pressed' state changed to: on
2024-09-29 19:55:02.841 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Living Room display when checking for dashboard state 'PLAYING': Title: Sex On Fire
State: PLAYING
Volume: 20
Volume muted: False
2024-09-29 19:55:02.841 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Media is playing!
2024-09-29 19:55:02.842 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Matched state for entity 'input_boolean.badkamer_button_pressed', casting dashboard to Living Room display
2024-09-29 19:55:02.842 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Checking media status for Living Room display
2024-09-29 19:55:06.244 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Media is currently playing or paused on Living Room display
2024-09-29 19:55:06.245 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Skipping cast to Living Room display because media is playing or paused.
2024-09-29 19:55:07.843 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] All device map: {'Living Room display': {'instances': [{'dashboard_url': 'http://192.168.1.103:8123/db-badkamer/0?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 2, 'start_time': datetime.time(7, 0), 'end_time': datetime.time(1, 0), 'instance_change': False, 'speaker_groups': None}], 'current_instance': 0}}
Current device map: {'Living Room display': {'dashboard_url': 'http://192.168.1.103:8123/db-badkamer/0?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 2, 'start_time': datetime.time(7, 0), 'end_time': datetime.time(1, 0), 'instance_change': False, 'speaker_groups': None}}
2024-09-29 19:55:07.843 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Current local time: 19:55:07.842974
2024-09-29 19:55:07.843 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Local time is inside the allowed casting time for Living Room display. Start time: 07:00:00 - End time: 01:00:00
2024-09-29 19:55:09.364 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Entity 'input_boolean.badkamer_button_pressed' state changed to: off
2024-09-29 19:55:11.420 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Living Room display when checking for dashboard state 'Dummy': Title: Sex On Fire
State: PLAYING
Volume: 20
Volume muted: False
2024-09-29 19:55:15.105 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Living Room display when checking for dashboard state 'Dummy': Title: Sex On Fire
State: PLAYING
Volume: 20
Volume muted: False
2024-09-29 19:55:15.106 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] HA Dashboard (or media) is playing on Living Room display...
2024-09-29 19:55:16.246 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Stopping casting dashboard on Living Room display after 10 seconds timeout
2024-09-29 19:55:30.107 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] All device map: {'Living Room display': {'instances': [{'dashboard_url': 'http://192.168.1.103:8123/db-badkamer/0?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 2, 'start_time': datetime.time(7, 0), 'end_time': datetime.time(1, 0), 'instance_change': False, 'speaker_groups': None}], 'current_instance': 0}}
Current device map: {'Living Room display': {'dashboard_url': 'http://192.168.1.103:8123/db-badkamer/0?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 2, 'start_time': datetime.time(7, 0), 'end_time': datetime.time(1, 0), 'instance_change': False, 'speaker_groups': None}}
2024-09-29 19:55:30.108 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Current local time: 19:55:30.107375
2024-09-29 19:55:30.108 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Local time is inside the allowed casting time for Living Room display. Start time: 07:00:00 - End time: 01:00:00
2024-09-29 19:55:33.281 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Living Room display when checking for dashboard state 'Dummy': Volume: 20
Volume muted: False
2024-09-29 19:55:36.595 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Living Room display when checking for dashboard state 'Dummy': Volume: 20
Volume muted: False
2024-09-29 19:55:36.595 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] HA Dashboard is NOT active on Living Room display...
2024-09-29 19:55:36.595 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Checking media status for Living Room display
2024-09-29 19:55:39.748 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Media is not playing, waiting 5 seconds before re-checking...
2024-09-29 19:55:47.910 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Media is not playing on Living Room display
2024-09-29 19:55:47.911 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Casting dashboard to Living Room display
2024-09-29 19:55:47.918 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Executing stop command...
2024-09-29 19:55:54.335 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Setting volume to 0...
2024-09-29 19:55:57.620 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Executing the dashboard cast command...
2024-09-29 19:56:01.846 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Setting volume to 20...
2024-09-29 19:56:20.066 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] All device map: {'Living Room display': {'instances': [{'dashboard_url': 'http://192.168.1.103:8123/db-badkamer/0?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 2, 'start_time': datetime.time(7, 0), 'end_time': datetime.time(1, 0), 'instance_change': False, 'speaker_groups': None}], 'current_instance': 0}}
Current device map: {'Living Room display': {'dashboard_url': 'http://192.168.1.103:8123/db-badkamer/0?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 2, 'start_time': datetime.time(7, 0), 'end_time': datetime.time(1, 0), 'instance_change': False, 'speaker_groups': None}}
2024-09-29 19:56:20.067 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Current local time: 19:56:20.066556
2024-09-29 19:56:20.067 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Local time is inside the allowed casting time for Living Room display. Start time: 07:00:00 - End time: 01:00:00
2024-09-29 19:56:23.245 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Living Room display when checking for dashboard state 'Dummy': Title: Dummy 19:56:15 GMT+0200 (Central European Summer Time)
Volume: 20
Volume muted: False
2024-09-29 19:56:26.503 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Living Room display when checking for dashboard state 'Dummy': Title: Dummy 19:56:15 GMT+0200 (Central European Summer Time)
Volume: 20
Volume muted: False
2024-09-29 19:56:26.504 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] HA Dashboard (or media) is playing on Living Room display...

It takes a minute and a half from the state change to the casting of the dashboard, and it passes the following stages:

Am I the only one having this problem... are there configurations correctly using force_cast?