Script to resume Google Cast devices after they have been interrupted by any action

Hi @TheFes - awesome work !!!

I too unfortunately seem to have an error. I don’t really understand how to approach this - maybe you can shed some light.
So, I have an automation that tracks when me/my wife get home - announce this via the google kitchen display (google hub). If music is playing - Spotify/TuneIn - I want it to announce the TTS message - then resume the play of that track which it was playing.
So, the automation is:

alias: Vlad @ Home
description: Vlad arrives home
trigger:
  - entity_id: person.vlad_chiriloiu
    from: not_home
    platform: state
    to: home
condition:
  - condition: time
    before: "21:00:00"
    after: "07:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
  - condition: or
    conditions:
      - condition: state
        entity_id: sensor.sm_f936b_wifi_connection
        state: XXXX
      - condition: state
        entity_id: sensor.sm_f936b_wifi_connection
        state: XXXXX
action:
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - data:
      message: Vlad a ajuns acasa !
      title: Notificare Home Assistant
    service: notify.mobile_app_sm_g780f
  - service: notify.mobile_app_sm_a536b
    data:
      message: Vlad a ajuns acasa !
      title: Notificare Home Assistant
  - data:
      message: Vlad a ajuns acasa !
      title: Notificare Home Assistant
    service: notify.mobile_app_sm_f936b
  - scene: scene.vlad_is_home
  - service: script.google_home_resume
    data:
      action:
        - service: media_player.volume_set
          data:
            volume_level: 0.5
          target:
            entity_id: media_player.kitchen_google_display
        - service: tts.cloud_say
          data:
            message: Bine ai venit acasă Vlad. Sper că ai o zi bună !
            entity_id: media_player.kitchen_google_display
      target:
        entity_id: media_player.kitchen_google_display
  - delay: "00:01:00"
  - service: light.turn_off
    data: {}
    target:
      entity_id:
        - light.desk_led
        - light.kitchen_led
mode: single

As per your instructions in the documentation - I deleted all previous GoogleHome scripts/automations - created a folder - inside created the .yaml file - copied the script (latest version 2013) and adjusted the initial part to match my setup:

homeassistant:
  customize:
    script.google_home_resume:
      # enter settings for the script here, all settings are optional, you can remove sections if you don't need them
      # always leave the line with "settings: &settings" in!
      settings: &settings
        primary_spotcast: vlad_chiriloiu
        radio_data:
          Europa FM:
            picture: "http://192.168.000.000:8123/local/pictures/radio/europa_fm.png"
            title: "Just Music"
          Magic FM:
            picture: "http://192.168.000.000:8123/local/pictures/radio/magic_fm.png"
            title: "WE. LOVE. MUSIC."
          Pro FM:
            picture: "http://192.168.000.000:8123/local/pictures/radio/pro_fm.png"
            title: "MUSIC MATTERS"
          DIGI FM:
            picture: "http://192.168.000.000:8123/local/pictures/radio/digi_fm.jpg"
            title: "NO ALTERNATIVE"
        speaker_groups:
          media_player.all_house:
            - media_player.kids_bedroom_speaker
            - media_player.kitchen_google_display
            - media_player.office_speaker
            - media_player.bedroom_speaker
            - media_player.living_room_speaker
        default_volume_level: 0.25
        dummy_player: media_player.vlc_telnet
        default_resume_delay:
          seconds: 20
        max_runtime:
          minutes: 10
        # settings for automation
        enable_automation: true
        dashboard_cast: true
        announce_volume_automation: 0.4
      # settings for voice script
      voice_settings: &voice_settings
        check_for_title: "White Noise"
        use_resume: true

When I trigger the above automation to test it - it runs up to the google resume script - it cuts the song - plays the TTS message, then it throws the following errors:

Logger: custom_components.spotcast.spotcast_controller
Source: custom_components/spotcast/spotcast_controller.py:234
Integration: Spotcast (documentation, issues)
First occurred: 5:30:37 PM (1 occurrences)
Last logged: 5:30:37 PM

Could not find device Kitchen Google Display from hass.data

###########

Logger: homeassistant.components.script.google_home_resume_helper
Source: helpers/script.py:409
Integration: Script (documentation, issues)
First occurred: 5:30:37 PM (6 occurrences)
Last logged: 5:30:37 PM

00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Resume needed?: Resume playing: Spotify?: Error executing script. Error for repeat at pos 2: Could not find device with name Kitchen Google Display
00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Resume needed?: Error executing script. Error for choose at pos 2: Could not find device with name Kitchen Google Display
00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Error executing script. Error for if at pos 9: Could not find device with name Kitchen Google Display
00 - Google Home Resume - Helper Script: If at step 2: Error executing script. Error for parallel at pos 1: Could not find device with name Kitchen Google Display
00 - Google Home Resume - Helper Script: Error executing script. Error for if at pos 2: Could not find device with name Kitchen Google Display

###########

Logger: homeassistant
Source: custom_components/spotcast/spotcast_controller.py:88
Integration: Spotcast (documentation, issues)
First occurred: 5:30:37 PM (1 occurrences)
Last logged: 5:30:37 PM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 462, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 923, in _async_if_step
    await self._async_run_script(if_data["if_then"])
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/trace.py", line 252, in async_wrapper
    await func(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1025, in _async_parallel_step
    raise result
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1017, in async_run_with_trace
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 923, in _async_if_step
    await self._async_run_script(if_data["if_then"])
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 896, in _async_choose_step
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/trace.py", line 252, in async_wrapper
    await func(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 813, in _async_repeat_step
    await async_run_sequence(iteration, extra_msg)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 795, in async_run_sequence
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1798, in _execute_service
    await self._hass.async_add_executor_job(
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/spotcast/__init__.py", line 190, in start_casting
    spotify_device_id = spotcast_controller.get_spotify_device_id(
  File "/config/custom_components/spotcast/spotcast_controller.py", line 234, in get_spotify_device_id
    spotify_cast_device = SpotifyCastDevice(
  File "/config/custom_components/spotcast/spotcast_controller.py", line 62, in __init__
    self.castDevice = self.getChromecastDevice(device_name)
  File "/config/custom_components/spotcast/spotcast_controller.py", line 88, in getChromecastDevice
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Could not find device with name Kitchen Google Display

What is puzzling is that the device - Kitchen Google Display is present - and working via Spotcast as well as well as via Spotify
image


image

I am sorry for the long post - but I wanted to have a background on what I am trying to achieve and what’s not working

Thank you very much for any hint on what may be that’s not configured/setup properly for it to work

I see you were playing Spotify.
Could you also send the trace of the helper script? I suspect this is a Spotify issue also discussed earlier above, where Spotify can’t match the device ID.
That needs to be solved in Spotcast, I can’t really do anything here.

The trace of the helper script will confirm if this is the case.

@lostprophet the same applies to you, this is caused by Spotcast.

For me this helped:
fondberg/spotcast#365 (comment)

The adjusted files are also on my repo: HA-configuration/custom_components/spotcast at main · TheFes/HA-configuration · GitHub

You can give that a try, if it doesn’t work please create an issue on the spotcast repo, or try the topic on the HA community forum.

:rotating_light: SPOTIFY RESUME ISSUES :rotating_light:

There are currently issues with resuming Spotify, this is not caused by the script, but something which is caused by Spotify, which makes Spotcast unable to perform the resume.
The issue you will see (as error in the trace of the helper script, or your log, will be something like Error executing script. Error for if at pos 2: Could not find device with name Kitchen Google Display

For me the suggestions provided in this spotcast issue on GitHub helped. I’ve done these changes in my spotcast files, and for me resume works fine now. The changed files can be found here.

If that doesn’t work, you might wat to try the changes from this spotcast PR. Haven’t applied those mysef, because for me it seems to work now.

I had the same issue, applying changes in spotcast files here worked for me.

Thanks for the pointer once more, it’s working! :slight_smile: Also tried tunein and that also worked swimmingly, thanks so much for all your assistance! Enjoy the coffee!

Final question if I may: in your sample config you have defined radio stations, this doesn’t seem to be a requirement as it worked for me without defining any. What is the benifit of defining them in the script settings?

Well, TuneIn usually has the Radio Channel, eg Christmas Radio as the artist, and then the actual artist and song title eg Wham - Last Christmas as the title displayed on the screen (or in the attributes of the media_player entity).

These are updated by TuneIn, but when the TuneIn stream is interested, that won’t work anymore.
That will mean that hours later, the title will still be Wham - Last Christmas and the respective album art will be displayed.

To avoid that, I created a variable to provide some generic data for frequently used streams, so it will use the logo and slogan of the radio channel instead of the song and album art at the time of the interruption.

1 Like

Hi @TheFes - thank you very much for your suggestions.
Unfortunately for me neither worked.
I replaced the files (spotify_controller and spotcast_controller) with the ones from your mention earlier, same errors.
I edited the files accordingly as per the post suggested (including the init file from Wait for cast device to boot before failing by Ionshard · Pull Request #366 · fondberg/spotcast · GitHub )
I changed only the lines from Cast device not launching properly, but works if timeout is ignored · Issue #365 · fondberg/spotcast · GitHub - the initial advice - exact same error.
Each change was accompanied by a HA restart to make sure the files are re-compiled again.

It just does not want to work for me :frowning: I am getting the same - cannot find device error message.

Sorry, but there is really nothing I can do. This is an issue in the Spotcast integration.

I had the same problem, TheFes’s files not helping, threfore I combined both posts you mention - and finally working without any problem :slight_smile:

Here is my spotcast fork.

3 files are changed only (as a combination of those 2 posts):
init.py
spotcast_controller.py
spotify_controller.py

1 Like

Thanks, I will add this to the alert in the start post.

@manazer I added a link to your repo in the start post, so it can be added as a custom repo in HACS. If you don’t want that, let me know and I will remove it :slight_smile:

Hi @Manazer ,

Thank you for the quick idea. I changed the 3 files - as per your post, deleted the cache - restarted HA and now the error changed when I re-tried to run the automation:

Logger: homeassistant.components.script.google_home_resume_helper
Source: helpers/script.py:409
Integration: Script (documentation, issues)
First occurred: 11:23:02 AM (6 occurrences)
Last logged: 11:23:02 AM

00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Resume needed?: Resume playing: Spotify?: Error executing script. Service not found for repeat at pos 2: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Resume needed?: Error executing script. Service not found for choose at pos 2: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Error executing script. Service not found for if at pos 9: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: If at step 2: Error executing script. Service not found for parallel at pos 1: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: Error executing script. Service not found for if at pos 2: Unable to find service spotcast.start

############

Logger: homeassistant
Source: core.py:1702
First occurred: 11:23:02 AM (1 occurrences)
Last logged: 11:23:02 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 462, in _async_run
    return await self.script.async_run(script_vars, context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 923, in _async_if_step
    await self._async_run_script(if_data["if_then"])
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/trace.py", line 252, in async_wrapper
    await func(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1025, in _async_parallel_step
    raise result
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1017, in async_run_with_trace
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 923, in _async_if_step
    await self._async_run_script(if_data["if_then"])
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 896, in _async_choose_step
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/trace.py", line 252, in async_wrapper
    await func(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 813, in _async_repeat_step
    await async_run_sequence(iteration, extra_msg)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 795, in async_run_sequence
    await self._async_run_script(script)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1029, in _async_run_script
    await self._async_run_long_action(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 648, in _async_run_long_action
    long_task.result()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1524, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 409, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 453, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1702, in async_call
    raise ServiceNotFound(domain, service) from None
homeassistant.exceptions.ServiceNotFound: Unable to find service spotcast.start

It seems that it does not have a reply from one of the definitions - maybe ?

Something went wrong with the changes, spotcast can’t be loaded now (and therefor the service spotcast.start is not available).

I loaded the repo @manazer created myself, and I have the same issue. Seems something is not completely right here:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 928, in async_process_component_config
    platform = p_integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 744, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 761, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/spotcast/__init__.py", line 44, in <module>
    from .helpers import async_wrap, get_cast_devices, get_spotify_devices, get_spotify_media_player
ImportError: cannot import name 'get_spotify_media_player' from 'custom_components.spotcast.helpers' (/config/custom_components/spotcast/helpers.py)

I tried to apply the changes myself in a fork, but this also didn’t work. Seems there is something wrong with the changes from the PR

Hmm… in my case it is still working

I did not use custom repo - only those 3 files replaced manually.

Spotcast v3.6.30
Home Assistant 2023.1.1
Supervisor 2022.12.1
Frontend 20230104.0 - latest

Will you help my traces of scripts somehow?

I’m on the same versions (all latest).
But when I apply the changes (I assume those in your spotcast repo are the ones changed) I get the errors. I also tried to apply them myself with the same error.

For now I’m back to only the changes from the issue, not those of the PR.

Finally! With the changes from the spotcast PR referred in the first post it’s now working like a charm! Thank you for the effort!

Hi, I’m also in the same boat with spotcast not working correctly. How did you clear the cache? I tried the spotcast fork above and got this error:

Logger: homeassistant.components.script.google_home_resume_helper
Source: helpers/script.py:409 
Integration: Scripts (documentation, issues) 
First occurred: 09:38:17 (6 occurrences) 
Last logged: 09:38:17

00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Resume needed?: Resume playing: Spotify?: Error executing script. Service not found for repeat at pos 2: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Resume needed?: Error executing script. Service not found for choose at pos 2: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: If at step 2: Parallel action at step 1: parallel 1: Error executing script. Service not found for if at pos 9: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: If at step 2: Error executing script. Service not found for parallel at pos 1: Unable to find service spotcast.start
00 - Google Home Resume - Helper Script: Error executing script. Service not found for if at pos 2: Unable to find service spotcast.start

After restart I also get this error when checking config:

Component error: spotcast - cannot import name 'get_spotify_media_player' from 'custom_components.spotcast.helpers' (/config/custom_components/spotcast/helpers.py)

Strangely, I removed the Spotcast fork back to the original, updated to latest version and spotify just resumed after an announment. Hopefully its resolved…somehow

By clearing cache I meant deleted the cache folder from the custom_components/spotcast - and restart HA - to reload the files.

1 Like

Strange.
For me the only working solution is combined one - issue 365 + PR 366.
Combined here and installed as a custom repo (GitHub - Manazer/spotcast: Spotcast custom component - combined issue #365 (suggestion 1356797204) & PR #366).

Issue 365:

PR 366: Wait for cast device to boot before failing by Ionshard · Pull Request #366 · fondberg/spotcast · GitHub

Everything working with Spotcast v3.7.0 published yesterday
:+1: :100:

1 Like