Google Home devices as media_player creates multiple errors in the log and duplicate media_player entity names

The past months I have seen many errors like these


2019-07-03 18:51:42 ERROR (Thread-17) [pychromecast.socket_client] [Announcements:42096] Error reading from socket.
2019-07-03 18:51:42 ERROR (Thread-12) [pychromecast.socket_client] [Announcements:42659] Error reading from socket.
2019-07-03 18:51:42 ERROR (Thread-18) [pychromecast.socket_client] [Announcements:42386] Error reading from socket.
2019-07-03 18:51:42 WARNING (Thread-11) [pychromecast.socket_client] [Office Speaker:8009] Error communicating with socket, resetting connection
2019-07-03 18:51:42 WARNING (Thread-18) [pychromecast.socket_client] [Announcements:42386] Error communicating with socket, resetting connection
2019-07-03 18:51:42 WARNING (Thread-12) [pychromecast.socket_client] [Announcements:42659] Error communicating with socket, resetting connection
2019-07-03 18:51:42 WARNING (Thread-17) [pychromecast.socket_client] [Announcements:42096] Error communicating with socket, resetting connection
2019-07-03 18:51:42 ERROR (Thread-11) [pychromecast.socket_client] [Office Speaker:8009] Failed to connect to service Google-Home-2ca72751449f7c59a5a72d7bd8fc2f80._googlecast._tcp.local., retrying in 5.0s
2019-07-03 18:51:42 ERROR (Thread-17) [pychromecast.socket_client] [Announcements:42096] Failed to connect to service Google-Cast-Group-c43685fe3438477ebf1309705a714e7b._googlecast._tcp.local., retrying in 5.0s
2019-07-03 18:51:42 ERROR (Thread-18) [pychromecast.socket_client] [Announcements:42386] Failed to connect to service Google-Cast-Group-f4050582dd87411ea99259d1cdb2dd51._googlecast._tcp.local., retrying in 5.0s
2019-07-03 18:51:42 ERROR (Thread-12) [pychromecast.socket_client] [Announcements:42659] Failed to connect to service Google-Cast-Group-CFF3A68035CB4620AE67C64D6D70FA69-1._googlecast._tcp.local., retrying in 5.0s

But it seemed to not matter too much - HA reconnects to the devices and normally most of my 7 Google Home devices do the talking when my automations run.

But lately I noticed (cannot say exactly when this started) that it fails in a new way.

I get these tracebacks


2019-07-03 19:49:37 ERROR (MainThread) [homeassistant.components.automation] Error while executing automation automation.someone_at_the_front_door_rf. Unknown error for call_service at pos 2: 
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 393, in action
    await script_obj.async_run(variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 89, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 119, in service_handler
    context=service.context)
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 183, in async_turn_on
    raise err
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 178, in async_turn_on
    kwargs.get(ATTR_VARIABLES), context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 131, in async_run
    await self._handle_action(action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 210, in _handle_action
    action, variables, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 299, in _async_call_service
    context=context
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 89, in async_call_from_config
    domain, service_name, service_data, blocking=blocking, context=context)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1150, in async_call
    self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1172, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 194, in handle_service
    required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 316, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 339, in _handle_service_platform_call
    await func(entity, data)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/cast/media_player.py", line 930, in play_media
    self._chromecast.media_controller.play_media(media_id, media_type)
  File "/usr/local/lib/python3.7/site-packages/pychromecast/controllers/media.py", line 523, in play_media
    callback_function=app_launched_callback)
  File "/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py", line 935, in launch_app
    self.update_status(lambda response:
  File "/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py", line 926, in update_status
    callback_function=callback_function_param)
  File "/usr/local/lib/python3.7/site-packages/pychromecast/controllers/__init__.py", line 84, in send_message
    self.namespace, data, inc_session_id, callback_function)
  File "/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py", line 725, in send_platform_message
    inc_session_id, callback_function_param)
  File "/usr/local/lib/python3.7/site-packages/pychromecast/socket_client.py", line 719, in send_message
    str(self.port) + " is connecting...")
pychromecast.error.NotConnected: Chromecast 192.168.1.112:42659 is connecting...

Another symptom is this…
I have a media_player device which is a group called Announcements. This group is created in the Google Home app and it is used for all my announcements using the “google_translate” tts platform.

This creates an entity called “media_player.announcements”.

As these issues happen HA has started creating many “media_announcements_number” entities.

In just 12 hours I got 10 of them created and they pop up faster than I can delete them using the entity_registry. There is something that has gotten worse in the latest HA versions OR some new bug has been pushed out to the Google Home devices that make them fail in a new way.

Am I the only one that seems this? If you have the same problem then you are flooded with these errors in the log and you have the same kind of multiple entities.

I do not see any duplications of the individual Google home devices but then I have no automations that only speak to one device. I always announce in the entire house.

Note that I have updated the config with the breaking change so I correctly use google_translate and not the old google_say and the thing normally works so I doubt my config is wrong. It is the connection between HA and the devices OR HA and Google that breaks periodically and then comes back up and HA is not good at handling that

I am away travelling the next to days so if someone wants me to experiement with something than it will be when I am back Friday night

1 Like

Hello,

I have a similar issue - chromecast connection fails at some point.
Context: I have a google home and a google home hub. The latter is the one that generates errors

2019-07-02 04:05:19 WARNING (Thread-5) [pychromecast.socket_client] [192.168.0.140:8009] Heartbeat timeout, resetting connection
2019-07-02 04:05:26 ERROR (Thread-5) [pychromecast.socket_client] [192.168.0.140:8009] Failed to connect, retrying in 5.0s
2019-07-02 04:18:46 WARNING (Thread-6) [pychromecast.socket_client] [192.168.0.141:8009] Heartbeat timeout, resetting connection
2019-07-02 04:18:53 ERROR (Thread-6) [pychromecast.socket_client] [192.168.0.141:8009] Failed to connect, retrying in 5.0s

I also get authentication errors at other times. Is it possible that these are linked?

2019-07-02 12:12:16 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 192.168.0.141
2019-07-02 15:16:39 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from 192.168.0.141

Running 0.93.1 in docker.

This started for me yesterday, my Google Home’s are not included though but my two Sony TVs running Android are.
I’m a bit fed up with warnings and errors spamming the log, I always try to fix errors and warnings but it is so damn inconsistent.
All the spamming makes it really hard to track down what’s going on, and when errors appear for no apparent reason it’s even harder.

I can live with the errors if I know they are just normal noise.
All Google device reset themselves every day. They get firmware updates or they just fall on their butt. Fact is - they are unavailable a few seconds every day. This gives errors when HA looses connection but it always reconnect. It is quite many HA versions ago (many months) since I last saw a Google device that disconnected and did not reconnect

The problem is with the speaker groups. For some reason HA also looses connection with the speaker group I have defined. I only have one which includes all my Google Home devices and I use it for announcements and it works great

But my media_player.announcements gets duplicates several times a day each time a device is not available for a few seconds. You get media_player.announcements_1, media_player.announcements_2, media_player.announcements_3 etc

Each day I sit and delete these devices. I left it alone for a few days and I ended up with 39 bogus devices.

This is really really annoying. Not just triggering OCD. It is real trouble that you have to clean up because I am sure that eventually you will have hundreds of these and something will go wrong

I realized that with me too. A change point for manually discovering and integrating google home without integrating with the group you create and miss. It even created a media group with all Google devices, but doesn’t tune in when playing audio.

Did you ever resolve this as I have the same issue under 0.105.5.

The same for me to.
Lots of ghost group entities are being created, but not the big amount as stated by @KennethLavrsen

Another thing I noticed is that when I give a google voice command to one of my nest mini’s to start casting to the group, It seems all is ok at start, but no stream will get played at the end. This functions way better when I cast to the group using my android phone.
Obviously, the above has nothing to do with home assistant, but maybe there could be a link…