Given that you have access to spotcast’s source-code, you are free to modify it to return whatever information you want in whatever format you need.
I don’t use spotcast so I will leave it to someone else to help you modify it. However, if I did use it, I wouldn’t change its code but simply create a python_script to extract the desired names and assign them to the input_select.
I believe the python_script will be something like this (which is untested and may require modifications):
devices = hass.states.get('sensor.chromecast_devices').attributes['devices_json']
options = []
for d in devices:
options.append(d['name'])
if len(options) > 0:
service_data = {'entity_id': 'input_select.spotcast_select', 'options': options}
hass.services.call('input_select', 'set_options', service_data)
It gets the devices_json attribute from sensor.chromecast_devices.
It creates an empty list called options.
It loops through the devices_json list and extracts the value of the key called “name”. It appends this value to the options list.
It checks if the options list contains items.
It creates a JSON string, called service_data, containing all the information needed for the set_options service.
Finally, it calls input_select.set_options using service_data.
If you don’t know how to use the python_script integration, here’s the documentation and feel free to ask me any questions to help you get it running.
EDIT
Replaced original, defective code with new, functional code.
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/python_script/__init__.py", line 196, in execute
exec(compiled.code, restricted_globals)
File "spotcastinput.py", line 5, in <module>
File "/usr/local/lib/python3.7/site-packages/RestrictedPython/Eval.py", line 35, in default_guarded_getitem
return ob[index]
TypeError: string indices must be integers
Edit:
I can confirm the last 2 lines of your code work, so it must be something in where it parses the data.
Edit 2:
Going to try to see what the output of the devices variable is. Let’s see…
Edit 3:
The error is when it tries to do the loop for d in devices
hmmm strange…
Edit 4:
The error is in the data spotcast returns. If I take away the devices = and replace it with just this