I checked, and by un-commenting the config I’d previously used with Last FM, and I got this in the logs:
Tue Jul 23 2019 09:44:18 GMT-0400 (Eastern Daylight Time)
lastfm: Error on device update!
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 261, in _async_add_entity
await entity.async_device_update(warning=False)
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 377, in async_device_update
await self.hass.async_add_executor_job(self.update)
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/lastfm/sensor.py”, line 84, in update
last = self._user.get_recent_tracks(limit=2)[0]
File “/usr/local/lib/python3.7/site-packages/pylast/init.py”, line 2364, in get_recent_tracks
limit, self, self.ws_prefix + “.getRecentTracks”, cacheable, params
File “/usr/local/lib/python3.7/site-packages/pylast/init.py”, line 2785, in _collect_nodes
doc = sender._request(method_name, cacheable, params)
File “/usr/local/lib/python3.7/site-packages/pylast/init.py”, line 1132, in _request
return _Request(self.network, method_name, params).execute(cacheable)
File “/usr/local/lib/python3.7/site-packages/pylast/init.py”, line 965, in execute
response = self._download_response()
File “/usr/local/lib/python3.7/site-packages/pylast/init.py”, line 954, in _download_response
self._check_response_for_errors(response_text)
File “/usr/local/lib/python3.7/site-packages/pylast/init.py”, line 984, in _check_response_for_errors
raise WSError(self.network, status, details)
pylast.WSError: Login: User required to be logged in
I’m now using a templated sensor in combination with forked-daapd as a music server. I made a video to document how I implemented the music server in combination with home assistant. You can see it here. Any media player that’s connected with Home Assistant should work the same way.
The templated sensor configuration looks like this:
- platform: template
current_track:
value_template: >
{% if is_state('media_player.music_server','playing') %}
{{ state_attr('media_player.music_server', 'media_artist') ~ ": " ~ state_attr('media_player.music_server', 'media_title') }}
{% endif %}