b0mbays / continuously_casting_dashboards

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

Anyway to cast as a service? #48

Open Roachforlife opened 9 months ago

Roachforlife commented 9 months ago

I see that Google Cast exists and I can call it to push to my Lenovo Display, however for some reason it doesnt like my Mushroom Cards. I also see you can base things based on state. Was hoping to make a simple automation for a Button I have that when I press it will use dashcast to push to my screen so I can manually turn on and off. Is this possible? Thanks

b0mbays commented 9 months ago

Hey @Roachforlife yes you are correct, there is support for this using 'state_triggers' feature. There's more info here:

https://github.com/b0mbays/continuously_casting_dashboards#-entity-changed-dashboard-casting

You should be able to use this with your button if you have it setup and connected to home assistant. It should be recording the entities and it's probably either simply 'off' or 'on'. Try testing it out and check what the states are called then follow the setup doc.

Let me know if you have any issues 👍

Roachforlife commented 8 months ago

Sorry for the delay getting back to you. I am finally getting around to testing this and still having issues. Basically, for now, I set up a virtual button via the helper section of HA. I then set it so when the button is set to 'On' it should cast, however it does nothing. In all honesty Ive never made a virtual button before but the premise seems very simple and I am manually turning it on/off in the phone app. When I check the log viewer nothing fires and of course, nothing casts to the screen. Wondering if I am just missing something in my yaml. I also posted a handful of other questions, sorry they are a hodgepodge of things surrounding this integration. Definitely appreciate the assistance!!

Helper button

image

image

image

YAML

continuously_casting_dashboards:
  logging_level: debug
  cast_delay: 30
  state_triggers:
    "Giuseppe":
        - entity_id: input_boolean.turn_dashcast_on_off
          to_state: "On"
          dashboard_url: "http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk"
          time_out: 1200
          force_cast: false

NOTE - you had helped me earlier and everything was working on a timer based system so I know the dashboard is good as well as the http and access, etc

Some general questions if you dont mind assisting (thank you again for the helpful and quick responses!)

  1. I like the idea of force_cast false, as sometimes my kiddo is watching something on youtube and it doesnt cast over it. I did, however, notice that if I cast my wyze cam via google (like I did before i found this integration), it doesnt honor that even when force cast is set to false. Do you know the parameters of what it considers media and to not override? I assume I have no control over this right?
  2. When using the entity state method, you have in your example about turning it on and sending a dashboard, and then on the off state, to set to another dashboard (dark theme for example). Is there instead of way to just cancel dashcast instead? So if, say button is pressed On it turns dashcast on, but if pressed to off, it turns dashcast casting off altogether?
  3. When using the time method (not entity state), I tried to use the same display for 2 time periods by basically putting the same code for my display twice, with different times. This didnt seem to work (however this was early in my testing and I didnt go back so it may be an issue on my end). But the idea would be I want the dashboard on when the kiddo is sleeping so maybe 12-3pm and then again 8pm-midnight, sort of thing
  4. I noticed when I do not 'set' the volume via yaml, it still messes with it, often setting it to 1 for some reason. Is this maybe a bug or just an issue with the casting method? I guess I would have assumed if I didnt set it, it wouldnt even display the volume and would honor whatever it was set at (ie if on 5 already, it would stay 5 and not show the volume display at all since no change)
  5. I believe you were mentioning this in another thread and its not really related to your integration but I am having the damnest time with my cameras showing. They do actually show, some of the time. I noticed right after restarting HA they almost never show. If I change the dashboard Ill get the 'the dashboard has changed' and I can click to refresh which seems to sometimes work. I am on 2024.2.3 currently and curious if this was the same issue you were experiencing?
  6. SPeaking of refreshing, do you know if there is a way to manually refresh (or automatically I suppose) the dashboard that is casted, similar to what I mentioned when I change the dashboard, it recgonizes it and then has me click to refresh. I realize this is not exactly related to this integration but thought you might have gone thru similar issues.
  7. Random question but its normal that when the yaml is changed I need to do a full restart of HA and not just the yaml? I guess I just assumed that since I changed only the yaml I could get away with the smaller restart but doesnt seem to be the case. Just double checking Im not doing something

Okay that was a lot, and I know some are not entirely linked to your integration but any help is much appreciated. Also one more thing to add, on the other thread you helped me and one of the things we discussed was adding 'admin' rights to the dashboard user in HA. Im realizing that I probably needed it since I was using my out of the box overview dashboard which I noticed requires admin by default. My subsequent ones I made after do not. So I wanted to let you know for if you want to update your page maybe a notice about checking the dashboard properties to see if admin rights are needed when setting up the user account.

Roachforlife commented 8 months ago

Hello, quick update. Still hoping to pick your brain on those 7 questions however to update I have made a little progress

My new config file

continuously_casting_dashboards:
  logging_level: debug
  cast_delay: 45
  start_time: "00:00"
  end_time: "23:59"
  devices:
    "Giuseppe":
      - dashboard_url: "http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk"
        volume: 3
  #...
  state_triggers:
    "Giuseppe":
        - entity_id: "input_boolean.turn_dashcast_on_off"
          to_state: "on"
          dashboard_url: "http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk"
          time_out: 1200
          force_cast: true

As mentioend before I made a toggle called dashcast on/off and referenced it with a state of on. I noticed that in the logviewer it said 'on' in lowercase instead of 'On' so I thought maybe that might make a difference but no dice. I also thought it was interesting that when I restart HA it does cast it, but then I guess hits the time out. Changing the toggle status makes no difference after that.

Checking the logs I now see timeout errors

2024-03-06 13:52:20.257 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] HA Dashboard (or media) is NOT playing on Giuseppe!
2024-03-06 13:52:20.257 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Casting dashboard to Giuseppe
2024-03-06 13:52:20.334 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Executing stop command...
2024-03-06 13:52:30.710 ERROR (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Timeout casting dashboard to Giuseppe: 
2024-03-06 13:52:33.989 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Stopping casting dashboard on Giuseppe after 1200 seconds timeout
2024-03-06 13:53:15.715 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] All device map: {'Giuseppe': {'instances': [{'dashboard_url': 'http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 3, 'start_time': datetime.time(0, 0), 'end_time': datetime.time(23, 59), 'instance_change': False}], 'current_instance': 0}}
Current device map: {'Giuseppe': {'dashboard_url': 'http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk', 'dashboard_state_name': 'Dummy', 'media_state_name': 'PLAYING', 'volume': 3, 'start_time': datetime.time(0, 0), 'end_time': datetime.time(23, 59), 'instance_change': False}}
2024-03-06 13:53:15.716 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Current local time: 13:53:15.715048
2024-03-06 13:53:15.716 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Local time is inside the allowed casting time for Giuseppe. Start time: 00:00:00 - End time: 23:59:00
2024-03-06 13:53:40.270 WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.samsung_qn90b_2 is taking over 10 seconds
2024-03-06 13:53:42.114 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Giuseppe when checking for dashboard state 'Dummy': Volume: 0
Volume muted: False
2024-03-06 13:53:58.787 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Status output for Giuseppe when checking for dashboard state 'Dummy': Volume: 0
Volume muted: False
2024-03-06 13:53:58.790 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] HA Dashboard (or media) is NOT playing on Giuseppe!
2024-03-06 13:53:58.790 INFO (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Casting dashboard to Giuseppe
2024-03-06 13:53:58.982 DEBUG (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Executing stop command...
2024-03-06 13:54:12.545 WARNING (MainThread) [homeassistant.helpers.entity] Update of media_player.samsung_qn90b_2 is taking over 10 seconds
2024-03-06 13:54:12.873 ERROR (MainThread) [custom_components.continuously_casting_dashboards.dashboard_caster] Timeout casting dashboard to Giuseppe: 

Question, and this is probably a dumb one, but when using the STATE feature, I still need to list the DEVICES section, is that correct? The way the code example is written it omits the device section but I presume the "#..." is to signify an addition to the devices section above it. I have tried both ways and still not getting to work but trying to make sure I am on the right path.

b0mbays commented 8 months ago

Hey @Roachforlife going to answer your questions below:

  1. What's the use case for setting this to false if this only happens when you activate this trigger? If the Hub is being used by Youtube and you don't want to cast the dashboard, then you wouldn't activate the trigger manually? 🤔

The parameters for the integration knowing whether it is showing media is a message that is logged when the integration checks in with the Hub, and asks what the status is. The only two I have added are in this code shown below:

is_media_state = "PLAYING" in status_output or "Netflix" in status_output

So, this only accounts for things that give a 'PLAYING' or 'Netflix' status. Your casted camera might not report the same status. You can check what the status is if you install 'catt' locally on a computer on your network, and do a call to your hub whilst the casted camera is active on your hub.

The repo is here: https://github.com/skorokithakis/catt

Once you have it installed run:

catt -d Giuseppe status

Then check the status message and report back. I could then add this to the code above.

  1. Kind of... However, you can't do this directly with this integration. You can create your own automation that does this. Setup the 'When' to be a button or anything you want, and then on the 'Then do' type in: media_player.turn_off

Then select your Hub as the target. This will stop the casted dashboard on the device on demand.

Screenshot 2024-03-07 at 14 51 50

  1. I haven't tried this myself but that should work? If it doesn't let me know and I'll try it myself.

  2. That's by design. I set the volume to 1 before the casting because the casting process creates an annoying sound so we mute that this way, and then set the volume to how it was before (if possible) or the default volume (or user set volume).

  3. You are correct! There was a bug introduced in 2024.2.x that caused issues with live cameras so I remained on 2023.2.x. This is fixed in 2024.3.0 so update to this and you'll have no issues.

  4. I'm not too sure. After a quick google it looks like you might be able to do this with Browser Mod so maybe try that?

  5. Yep unfortunately after changing the configuration.yaml a full restart is required. Annoying I know! I must have restarted HA 500 times when working on this integration 😆

Good spot with the admin rights. I'll get that added 👍

I'm confused about what you intend to do with your hub? You have it set to cast all day and night and also a state trigger to start the same dashboard on the same device? 🤔 Apologies If I have misunderstood!

Roachforlife commented 8 months ago

Thanks for the feedback. In between meetings so I will need to circle back on some but thanks for the feedback. I actually installed catt to test this along the way thinking I might need it so I will give the status call a shot and let you know. Thank you for being open to adding more.

As for how I plan to use it, I have basically been doing baby steps along the way since I couldnt get the state process working from the jump, which is why my questions seem a bit all over the place. For my usage, I do enjoy using the Lenovo display, its perfect (relatively) at casting my Wyze camera while my 2yr old sleeps, so I may want to turn it off for then (unless the feeds are more reliable in HA Dashboard which I will do more testing on). I also have times where she wants to watch something on Youtube in particular so I want to turn off the dashboard during those times. I think either of the following scenarios could work for me

  1. Cast all the time, but force cast is false and it doesnt override when Youtube app or Wyze app on the display are being used
  2. OR... use more of an on/off switch where I can tell it to cast when I either click a button, virtual or physical and then I either click again to turn off, or have a timeout. Actually doesnt even need a timeout as long as if I put youtube/wyze on, it doesnt force itself over the feeds. I had earlier put catt in because its more of a 'service' that I can call when I want, as opposed to listening constantly. To be honest i got it to cast a website but didnt like casting my dashboard in kiosk mode. Never really attempted to trouble shoot that.
  3. Or... basically the same as item 2 above but using a motion sensor to turn on when near by with a timeout of like 5min or something. Right now trying to just get it to work using the virtual switch since I figured easier to test

Going back to the idea with CATT, that is done more like a service you call as needed. Is there anyway to do this with CC Dash? So rather than the listening or based on static times, its something I can call when I want it? As i mentioned above I tried this with catt but didnt seem to like kiosk mode and I didnt go back and further test it. Since CC Dash uses catt I wonder if that might be something thats possible and that youd consider for a future enhancement?

Anyhow I will loop back on the others. Thanks again man I really appreciate you taking the time on this. I also will upgrade to latest HA from yesterday before I do to check the camera stuff :)

Roachforlife commented 8 months ago

Here is a screenshot of running both status and info (catt) when playing something on YOUTUBE

image

Roachforlife commented 8 months ago

Here is another running status and info when I called the WYZE CAM via Google Home on the device

image

Roachforlife commented 8 months ago

Last one, a screenshot of status/info when casting my NEST 1stgen Doorbell (Nest Hello) via Google Home to the display

image

Roachforlife commented 8 months ago

Sorry just kidding, figured would be helpful 2 more. So this is a screenshot of the lenovo display doing nothing other than cycling pictures via google photos

image

Roachforlife commented 8 months ago

Last one, here is when its casting the dashboard via your integration (sorry I have the info and status backwards on this one)

image

Roachforlife commented 8 months ago

Just to circle back to a question posted sort in between the previous posts. Assuming I am using the 'state' method of getting this to work, should I ALSO be including the 'devices' section in the yaml? Below is what I have now. It seems like it wants to run at all times (although other times not running at all, very weird) Definitely does not seem like it cares about my virtual toggle I made as turning it on or off doesnt seem to go anything. The way the code is listed on the github I wasnt sure if the "#..." signified I should be including the top portion of the code for 'devices'. Hopefully when you see my code below youll know what i mean.

continuously_casting_dashboards:
  logging_level: debug
  cast_delay: 45
  start_time: "00:00"
  end_time: "23:59"
  devices:   <<----- UNSURE IF THIS SECTION SHOULD BE EXCLUDED WHEN USING STATE TRIGGERS
    "Giuseppe":
      - dashboard_url: "http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk"
        volume: 3
  #...
  state_triggers:
    "Giuseppe":
        - entity_id: "input_boolean.turn_dashcast_on_off"
          to_state: "on"
          dashboard_url: "http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk"
          time_out: 1200
          force_cast: true
Zipties commented 8 months ago

Just to circle back to a question posted sort in between the previous posts. Assuming I am using the 'state' method of getting this to work, should I ALSO be including the 'devices' section in the yaml? Below is what I have now. It seems like it wants to run at all times (although other times not running at all, very weird) Definitely does not seem like it cares about my virtual toggle I made as turning it on or off doesnt seem to go anything. The way the code is listed on the github I wasnt sure if the "#..." signified I should be including the top portion of the code for 'devices'. Hopefully when you see my code below youll know what i mean.

continuously_casting_dashboards:
  logging_level: debug
  cast_delay: 45
  start_time: "00:00"
  end_time: "23:59"
  devices:   <<----- UNSURE IF THIS SECTION SHOULD BE EXCLUDED WHEN USING STATE TRIGGERS
    "Giuseppe":
      - dashboard_url: "http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk"
        volume: 3
  #...
  state_triggers:
    "Giuseppe":
        - entity_id: "input_boolean.turn_dashcast_on_off"
          to_state: "on"
          dashboard_url: "http://192.168.19.50:8123/dashboard-dashcast/default_view/default_view?kiosk"
          time_out: 1200
          force_cast: true

Did you ever figure this out? I cant get state_triggers to work and am wondering the same as you

Roachforlife commented 8 months ago

Unfortunately not. Hoping to hear from b0mbays soon

skewll commented 8 months ago

I'm in the same boat. Without the devices, I don't even get logs. Trying to make an input_boolean to turn the cast on. An option to end cast on state would be nice to.

Roachforlife commented 8 months ago

Can I ask, did you have a yaml similar to mine, with BOTH the devices section AND state_triggers section? Or just the state triggers section? I think the devices part may be required but I wasnt sure based on the wiki if its just additive. This may be standard in HA world but I am just learning everyday.

Havent heard from the dev in a bit. I did start exploring DashCast which this is based on i bellieve. Seems to work in a more purposely push way (ie I press a button on a, well, button, and it casts at that moment) so not as good as something always listening like the state triggers but hopefully soon we'll hear back and can make cont casting work!

skewll commented 8 months ago

I assumed I could use just the state_triggers since I didn't want the devices. No luck, no logs nothing seems to fire that way. With devices, it didn't test much other then my state_triggers. I had 1 devices, 3 state triggers for 3 different sensors/devices to see if I could get it to load and then trigger the other two state devices, nothing happens when the states change on the two sensors that were not also listed under the devices section.

UPDATE: I actually do see the logs of the state change on the sensor listed under state triggers firing, but it doesn't actually cast.

On Thu, Mar 28, 2024, 1:26 PM Roachforlife @.***> wrote:

Can I ask, did you have a yaml similar to mine, with BOTH the devices section AND state_triggers section? Or just the state triggers section? I think the devices part may be required but I wasnt sure based on the wiki if its just additive. This may be standard in HA world but I am just learning everyday.

Havent heard from the dev in a bit. I did start exploring DashCast which this is based on i bellieve. Seems to work in a more purposely push way (ie I press a button on a, well, button, and it casts at that moment) so not as good as something always listening like the state triggers but hopefully soon we'll hear back and can make cont casting work!

— Reply to this email directly, view it on GitHub https://github.com/b0mbays/continuously_casting_dashboards/issues/48#issuecomment-2026055033, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARQFDKDX2LNEJQFXWGPRVALY2R4HVAVCNFSM6AAAAABD6LIHFOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRWGA2TKMBTGM . You are receiving this because you commented.Message ID: @.***>

labaland commented 6 months ago

I see that Google Cast exists and I can call it to push to my Lenovo Display, however for some reason it doesnt like my Mushroom Cards. I also see you can base things based on state. Was hoping to make a simple automation for a Button I have that when I press it will use dashcast to push to my screen so I can manually turn on and off. Is this possible? Thanks

Works for me with this: https://github.com/AlexxIT/DashCast

service: dash_cast.load_url
data:
  url: http://192.168.1.4:8123/g-home/vader
  entity_id: media_player.boxen
  force: force
Roachforlife commented 6 months ago

I see that Google Cast exists and I can call it to push to my Lenovo Display, however for some reason it doesnt like my Mushroom Cards. I also see you can base things based on state. Was hoping to make a simple automation for a Button I have that when I press it will use dashcast to push to my screen so I can manually turn on and off. Is this possible? Thanks

Works for me with this: https://github.com/AlexxIT/DashCast

service: dash_cast.load_url
data:
  url: http://192.168.1.4:8123/g-home/vader
  entity_id: media_player.boxen
  force: force

Thanks. I have, for the moment, gone to DashCast as well which seems to be working okay. I do like the idea of this always listening though so I hope it is further supported/enhanced.

b0mbays commented 6 months ago

I'm in the same boat. Without the devices, I don't even get logs. Trying to make an input_boolean to turn the cast on. An option to end cast on state would be nice to.

Hey all, apologies I missed many of these messages. I have just added a new feature to control the casting globally with a boolean entity state. Could that resolve your issue?

The setup is explained here - ensure you have updated to 1.3.2

Roachforlife commented 6 months ago

I'm in the same boat. Without the devices, I don't even get logs. Trying to make an input_boolean to turn the cast on. An option to end cast on state would be nice to.

Hey all, apologies I missed many of these messages. I have just added a new feature to control the casting globally with a boolean entity state. Could that resolve your issue?

The setup is explained here - ensure you have updated to 1.3.2

I will plan some time over the next few days to check, thanks! Going to back further up in the thread I think you were going to look into adding some items to change what was considered 'in use' such as the youtube app for example. (when not using the force command). And equally as important, and sorry I may just be dumb but I still never understand if using the state method if you still need the beginning part of the yaml. Not sure if the examples are meant to be an extension of the yaml or the full yaml. (I saw the ... and thought maybe its an addon but I didnt know). Since I couldnt get it working I just assumed I was doing it wrong but some clarity would help this noob :) Thanks again for checking on us!