Home_assistant_cast - casting base_url but not server_port value?

Are there any debugging/informational options that can be configured for the service?

Answering myself for the benefit of any others needing this information. It was obtained from a Github issue. Many thanks to the original submitter.

# Provide diagnostic information
logger:
  default: info
  logs:
    homeassistant.components.generic: debug
    pychromecast: debug
    pychromecast.discovery: debug
    pychromecast.socket_client: debug

First info the Chromecast Ultra device is not 100% recognized:

2019-10-01 19:59:32 DEBUG (SyncWorker_17) [pychromecast] _get_chromecast_from_host ('192.168.1.174', 8009, 'c3396d5a-0834-7b39-9205-e4c4d016e613', 'Unknown model name', 'ChromecastUltra1517')

Finally, identified the source of the cast failing issue. The URL being submitted to the chromecast is using the base_url value from the http: configuration, without appending the server_port value. In this case, the base_url is my DuckDNS domain name.

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
http:
  base_url: https://mysite.duckdns.org
  server_port: 8123
  ssl_certificate: /ssl/certfile.pem
  ssl_key: /ssl/privkey.pem

and this is what’s logged as being sent to the ChromecastUltra device. Note the base_url portion of the URL string does not include the server_port value.

2019-10-01 19:59:32 DEBUG (Thread-10) [pychromecast.socket_client] [192.168.1.174:8009] Sending: Message urn:x-cast:com.google.cast.tp.connection from sender-0 to 9ed4e77e-aaa7-40d1-8432-ae3ea729e005: {'type': 'CONNECT', 'origin': {}, 'userAgent': 'PyChromecast', 'senderInfo': {'sdkType': 2, 'version': '15.605.1.3', 'browserVersion': '44.0.2403.30', 'platform': 4, 'systemVersion': 'Macintosh; Intel Mac OS X10_10_3', 'connectionType': 1}}
2019-10-01 19:59:32 DEBUG (Thread-10) [pychromecast.socket_client] [192.168.1.174:8009] Sending: Message urn:x-cast:com.google.cast.media from sender-0 to 9ed4e77e-aaa7-40d1-8432-ae3ea729e005: {'type': 'GET_STATUS', 'requestId': 3}
2019-10-01 19:59:32 DEBUG (Thread-10) [pychromecast.socket_client] [192.168.1.174:8009] Received: Message urn:x-cast:com.google.cast.media from 9ed4e77e-aaa7-40d1-8432-ae3ea729e005 to sender-0: {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 8, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'https://mysite.duckdns.org/api/hls/065f40d375457544606f88787102629394698243d3717738429dd76f56022b3a/playlist.m3u8', 'streamType': 'BUFFERED', 'contentType': 'application/vnd.apple.mpegurl', 'metadata': {}}, 'currentItemId': 1, 'idleReason': 'ERROR'}], 'requestId': 3}
2019-10-01 19:59:32 DEBUG (Thread-10) [pychromecast.controllers] Media:Received status {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 8, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'https://mysite.duckdns.org/api/hls/065f40d375457544606f88787102629394698243d3717738429dd76f56022b3a/playlist.m3u8', 'streamType': 'BUFFERED', 'contentType': 'application/vnd.apple.mpegurl', 'metadata': {}}, 'currentItemId': 1, 'idleReason': 'ERROR'}], 'requestId': 3}

Lastly, I’m not going to ping the great and mighty balloob, but because he is the author of the github pychromecast integration, I’ll at least mention his user name here. If anyone has suggestions on the best way to remedy this issue, I would be most grateful.

Follow-up: What I did was create a new issue in Github.

components/cast/home_assistant_cast.py

Line 43 uses only base_url and does not check server_port value

41    async def handle_show_view(call: core.ServiceCall):
42        """Handle a Show View service call."""
43        hass_url = hass.config.api.base_url

@balloob - please consider this addition to the codebase - many, many thanks.

41    async def handle_show_view(call: core.ServiceCall):
42        """Handle a Show View service call."""
43        hass_url = hass.config.api.base_url
new
new       if hass.config.api.server_port is not None:
new           hass_url = hass.config.api.base_url + ":" + hass.config.api.server_port

I edited my configuration.yaml file this morning, adding :8123 port number to the base_url value. The port number is now properly reflected in the debug HA log, but the ChromecastUltra is still rejecting it with an error. :frowning: For the benefit of anyone interested, I opened and dumped the .HLS file it’s sending to the Chromecast. The log file and HLS file contents are shown below:

2019-11-17 11:19:57 DEBUG (Thread-9) [pychromecast.socket_client] [192.168.1.174:8009] Received: Message urn:x-cast:com.google.cast.media from 93078160-dc2c-44b2-abbb-81a26b79c19d to *: {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 1, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'https://my-site.duckdns.org:8123/api/hls/d9fea5e8d5dff66d272fca5165a34402041ed505326057c5548331faa1791e3f/playlist.m3u8', 'streamType': 'BUFFERED', 'contentType': 'application/vnd.apple.mpegurl', 'metadata': {}}, 'currentItemId': 1, 'extendedStatus': {'playerState': 'LOADING', 'media': {'contentId': 'https://my-site.duckdns.org:8123/api/hls/d9fea5e8d5dff66d272fca5165a34402041ed505326057c5548331faa1791e3f/playlist.m3u8', 'streamType': 'BUFFERED', 'contentType': 'application/vnd.apple.mpegurl', 'metadata': {}}}, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
2019-11-17 11:19:57 DEBUG (Thread-9) [pychromecast.controllers] Media:Received status {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 1, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'https://my-site.duckdns.org:8123/api/hls/d9fea5e8d5dff66d272fca5165a34402041ed505326057c5548331faa1791e3f/playlist.m3u8', 'streamType': 'BUFFERED', 'contentType': 'application/vnd.apple.mpegurl', 'metadata': {}}, 'currentItemId': 1, 'extendedStatus': {'playerState': 'LOADING', 'media': {'contentId': 'https://my-site.duckdns.org:8123/api/hls/d9fea5e8d5dff66d272fca5165a34402041ed505326057c5548331faa1791e3f/playlist.m3u8', 'streamType': 'BUFFERED', 'contentType': 'application/vnd.apple.mpegurl', 'metadata': {}}}, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
2019-11-17 11:19:58 DEBUG (Thread-9) [pychromecast.socket_client] [192.168.1.174:8009] Received: Message urn:x-cast:com.google.cast.media from 93078160-dc2c-44b2-abbb-81a26b79c19d to *: {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 1, 'playbackRate': 1, 'playerState': 'BUFFERING', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'currentItemId': 1, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
2019-11-17 11:19:58 DEBUG (Thread-9) [pychromecast.controllers] Media:Received status {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 1, 'playbackRate': 1, 'playerState': 'BUFFERING', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'currentItemId': 1, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
2019-11-17 11:19:58 DEBUG (Thread-9) [pychromecast.socket_client] [192.168.1.174:8009] Received: Message urn:x-cast:com.google.cast.media from 93078160-dc2c-44b2-abbb-81a26b79c19d to sender-0: {'requestId': 13, 'type': 'LOAD_FAILED', 'detailedErrorCode': 300}
2019-11-17 11:19:58 DEBUG (Thread-9) [pychromecast.socket_client] [192.168.1.174:8009] Message unhandled: Message urn:x-cast:com.google.cast.media from 93078160-dc2c-44b2-abbb-81a26b79c19d to sender-0: {'requestId': 13, 'type': 'LOAD_FAILED', 'detailedErrorCode': 300}


#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:130
#EXTINF:3.0000,
./segment/130.ts
#EXTINF:3.0000,
./segment/131.ts
#EXTINF:3.0000,
./segment/132.ts