Home Assistant release with the issue:
Running latest as of posting. 0.100.3
Last working Home Assistant release (if known):
Unknown. I know it worked some months ago but then a HA update broke it. I think it was the change from a component to an integration that broke it but I am not 100% sure on this.
Operating environment (Hass.io/Docker/Windows/etc.):
Running in docker container on an Unraid system.
Integration:
https://www.home-assistant.io/integrations/cast/
Description of problem:
Whenever I update Home Assistant or restart it I have to make sure all of my chromecast devices are powered up and available otherwise they will not show up in HA even when they get powered on.
When I look for the entity in the states list in the UI the entity does not exist in that list if the device was un-powered when home assistant started up.
All of my chromecast devices are plugged into TV's USB ports and only powered when the TV is turned on. I guess I could just have them always powered but that is a waste of electricity so I prefer this option.
This is really strange as it used to work perfectly. Something changed in the last couple months that caused it to stop working the way I want. I think it may have been when cast was moved into it's own component. It used to continually try to connect to the chromecast (would show up in log) but now it looks like it only tries once and gives up. Here is the single log row:
Wed Oct 23 2019 01:18:39 GMT-0600 (Mountain Daylight Time)
[192.168.1.30:8009] Failed to connect, retrying in 5.0s
When I powered on the chromecast after HA started nothing happened (no messages in log).
Problem-relevant configuration.yaml entries:
Casts manually configured:
cast:
media_player:
- host: 192.168.1.10
Traceback (if applicable):
Additional information:
Is anyone else having this problem? Just bought another Chromecast today and now I have three devices I have to go around and power on before I update/restart home assistant so they show up.
I would just have them powered all the time but that is a waste of energy and money (even if it is only a couple bucks a year per device).
Is anyone else having this problem?
Yes, I am having the same issue. Could not find any solution for this issue so far.
Just the work-around you mentioned:
I would just have them powered all the time
Do you know which PR caused this error?
@springstan I believe it broke when pychromecast did a major update a few months back (3.2.3 to 4.0.0 possibly).
It seems like it tries to connect when HA starts and says it will try again in a little bit but never tries to connect again (as far as I can tell in the log).
It seems like it tries to connect when HA starts and says it will try again in a little bit but never tries to connect again (as far as I can tell in the log).
I wil try to investigate this as well with my setup and then get back to you.
So I investigated this with my setup:
(zeroconf-ServiceBrowser__googlecast._tcp.local.) [homeassistant.components.cast.discovery] Discovered chromecast ChromecastInfo(...)
[homeassistant.components.cast.media_player] _async_create_cast_device: ChromecastInfo(...)
[homeassistant.components.cast.media_player] [media_player.xyz xyz(192.x.x.x:8009)] Received cast device connection status: CONNECTED
[homeassistant.components.cast.media_player] [media_player.xyz xyz(192.x.x.x:8009)] Cast device availability changed: CONNECTED
@skylord123 do you see anything that looks similar to this after setting the logger level for cast to debug?
@springstan looks like we are having the same problem. I set the log level and restarted home assistant and saw the exact same things you did (I updated before running this cycle so this was done on 0.101.3)
2019-11-16 16:12:06 DEBUG (Thread-5) [homeassistant.components.cast.media_player] [media_player.unnamed_device None (192.168.1.31:8009)] Cast device availability changed: CONNECTED
Even after it is connected the device still doesn't show up in my entity list. Just like you though the device is listed in the integration page before and after the device connects. The manufacturer and model are still unknown in the integration page after the chromecasts connect.
I'm curious what caused it to break.
I also want to note that when I have all Chromecast's powered on when home-assistant starts/restarts they are all detected just fine and I can then turn the devices off and it will successfully detect the device turning on/off after that. It only when they are offline when HA starts/restarts that it breaks.
I would guess it has something to do with how they are setup when HA starts up that isn't happening when the devices connect at a later time.
looks like we are having the same problem.
@skylord123 I do not think so, inaccurany on my part. I thought that I had this problem but after investigating I am certain that I do not have this problem anymore.
If my chromecast devices are off while starting Home Assistant, they will not be discovered and therefore are unavailable, are not displayed under the states tab but are listed under the cast integration devices.
However, if Home Assistant is already running and Chromecast devices that have been off are now turned on, they are automatically discovered and the logs I mentioned before prove and document this:
(zeroconf-ServiceBrowser__googlecast._tcp.local.) [homeassistant.components.cast.discovery] Discovered chromecast ChromecastInfo(...)
[homeassistant.components.cast.media_player] _async_create_cast_device: ChromecastInfo(...)
[homeassistant.components.cast.media_player] [media_player.xyz xyz(192.x.x.x:8009)] Received cast device connection status: CONNECTED
[homeassistant.components.cast.media_player] [media_player.xyz xyz(192.x.x.x:8009)] Cast device availability changed: CONNECTED
Again sorry for my bad wording and inaccuracy.
So it looks like you are they only one with this issue. Maybe your auto discovery stops or does not regularly in the background while Home Assistant is running? That would somewhat explain why you are having this issue.
@springstan do you have your chromecasts defined in your configuration.yaml file?
If not, do you mind giving it a shot and seeing if you get the same issue as me?
The only reason I think this is due to this thread that the user solved the problem by removing the chromecast config from the config file and using discovery instead:
https://community.home-assistant.io/t/help-with-chromecast-configuration-unamed-device/116778/3
(this user specifically had discovery disabled whereas I do not but I think the issue is the same).
@springstan do you have your chromecasts defined in your configuration.yaml file?
No I have not defined them in myconfiguration.yamlfile, instead I have set up the cast integration by going to the Integrations page inside the config panel.
Sure I can try that and will get back to you with the results as soon as possible.
I agree with your listed reason since it looks very logical to me and looking at the documentation the following sentence underlines that:
Cast devices can only be discovered if they are on the same subnet as Home Assistant. If this is not the case, you need to configure the IP address of the Cast device directly:
Which to me means that you only need to define this integration in your configuration.yaml file if the cast device is not on the same subnet.
I just tested this on my setup by removing the chromecast config from my configuration.yaml file and restarting Home Assistant. Once it restarted I waited a minute and turned on one of my chromecasts and it showed up right away.
This is an issue with using the cast config then. My devices are all on the same subnet as my HA setup I just had it configured in the file because that is how you used to have to do it and I just never changed over to discovery.
So this is a bug and will need to be fixed. I am glad I found a way to make it work but it will need to be fixed for people using the config for cast devices instead of discovery.
@skylord123 it is great to hear that this solved your issue! :)
I would not call it a bug since it is documented correctly and therefore using the config only handles devices on a separate subnet as described in the documentation. It was probably a breaking change that some users may have overread.
@springstan you sure it's not a bug? If I had my chromecasts on another subnet I would still want them to work without having to be powered when HA starts.
I also don't think people define their chromecasts in the config just because they are on another subnet. In some cases people just don't want to use discovery and only want specific devices inside HA (such as that link I posted earlier).
If for some odd reason this functionality is on purpose then it should be documented on the component page. I really do believe this is a bug though. It was working perfectly and just broke without any sort of changelog or notice about it (it should have been listed under breaking changes).
@skylord123 sorry with your explanation I would agree that this is a bug. Of course you would want to have them discovered automatically by Home Assistant regardless if they are on the same subent or not.
I understand the case with specifying them in the config, however what advantage does it bring if you specify them there?
Yes, absolutely agree with you if this is intended it should be made clear to all users via the documentation.
@springstan There are several reasons but one off the top of my head is in that link I sent you earlier:
https://community.home-assistant.io/t/help-with-chromecast-configuration-unamed-device/116778/3
This guy has the same issue as me and he is defining them manually using their IP address because he doesn't want to use built in discovery. Some people don't want to use discovery and would rather manually configure everything so random devices don't get added.
@skylord123 okay I understand your concern about this issue and can see why this is cannot stay as it is.
Is anyone the codeowner of this integration?
Any way to help fixing this? I am experiencing this issue too.
Discovery doesn't, for some reason, detect my chromecast audio, but when I put it in the config it has to be on to be detected when HA restarts.
I'm facing the same issue too, 1 hour after initiated home assistant I got:
2020-01-27 02:28:26 WARNING (zeroconf-ServiceBrowser__googlecast._tcp.local.) [zeroconf] Exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/zeroconf/__init__.py", line 2589, in send
bytes_sent = s.sendto(packet, 0, (real_addr, port))
PermissionError: [Errno 1] Operation not permitted
After this time also my history graphs stop updating
Just to note: #28838 is not an exact duplicate. My cast shows up as soon as I power it on. Here, as I take it, it won't show up even when powered on. But yes: likely the issues are connected...
PS: And I am on auto-discovery. Probably because I was forced to switch to that by your very bug. So, I now hope to resolve my issue by reverting to yaml configuration, as soon as yours is fixed.
@skylord123 Can you please confirm that by "when using config instead of discovery" you mean you have configured the IP / hostname of your casts manually in configuration.yaml:
cast:
media_player:
- host: 192.168.1.10
@skylord123 Can you please confirm that by "when using config instead of discovery" you mean you have configured the IP / hostname of your casts manually in
configuration.yaml:cast: media_player: - host: 192.168.1.10
That is correct. When I was using my config definition I was specifying the IP address manually just like your example.
Great, then PR33922 should solve this issue.