Enable/disable plugin automatically

Hi,

I am a very happy user of Volumio and the Volumio Spotify Connect2 plugin.
However, every now and then Volumio does not appear in Spotify as a device I can play my music on.
A very simple workaround I found to this issue is to head to the Plugins section in Volumio UI and toggle off and back on the Volumio Spotify Connect2 plugin, Volumio immediately reappears in the list of devices in Spotify.
This is simple to do but unfortunately cumbersome enough so that my wife will not bother and then ditch Volumio for Spotify playlist streaming usage.

I thought of making this automatic using Home Assistant (already setup at home), which would enable me to quickly disable/re-enable the plugin every hour or so, making sure that the plugin is not currently in use using automation conditions.
Unfortunately, I went through both the REST API and CLI functions and I cannot find anything related to enabling/disabling plugins remotely. Did I miss something?
Alternatively, could this be done using curl and a specific html link?

Cheers,
Alex

Or instead of treating symptoms, try and figure out why/what is happening? :wink:
The next time the device has disappeared, try and look at the logs to see if there is anything suspicious…

That would be even better.
I have not done much debugging so far.
I recently re-migrated to Volumio from Logitech Media Server that also had a plugin for Spotify that was disconnecting very very often. When I came back to Volumio, I found the Spotify to be quite stable comparatively and I thought well, this is probably as good as it gets.
Perhaps other users could report on the availability of their Volumio device in Spotify? If some did manage to have it available at all times then yes indeed it would make a lot of sense for me to try to debug.
Can you think of anything more useful than ‘journalctl’ for debugging of plugins or volumio in general?

There could be a few things at play here.
The underlying librespot library that even the Spotty LMS plug-in uses is a bit sensitive to network anomalies. I’ve tired to make it more robust by autoconnecting, but it really depends on the individual network setup.

So if you have signed in with your credentials and then don’t see the device, then we need to investigate more.
If you are using discovery (i.e multi-user) then normally it’s harder to debug. You’d need to check that your network setup isn’t dropping the mdns packets for some reason.

For quick stuff, journalctl is available from the the /dev page using the livelog feature

For VLS logs, you can enable the Debug toggle in the plugin settings and look at the isolated logs with:

# Volumio logs
journalctl -f -o cat
# vollibrespot logs
journalctl -f -o cat -u volspotconnect2.service

For a workaround, the daemon uses a raw socket for communication with the outside world. If you could attempt writing something from HA that can use it, I can add some more events/commands directly to VLS

Hi ashthespy,

Thanks a lot for your reply.
Although everything you say makes perfect sense, I am afraid my knowledge in networking and programming fields is going to be limiting to implement your recommendations.

I have literally no idea how to do that. :confused:
However, it took me a few days to reply to your post because I was waiting for the plugin to be not responding anymore, it has been quite stable over the last few days. Perhaps not a coincidence, my router rebooted a few hours ago and I cannot see Volumio in Spotify anymore. The router I am using has been provided by my ISP (BT in the UK) and it is quite annoying in the sense that it reboots every time it loses the internet connection and as a result devices on the local network cannot see each other for a few minutes.
For an even simpler explanation, does the plugin need to be restarted every time the internet connection is dropped?

This is interesting but not very talkative. Now that I lost connection with the plugin, it gives me a single line:
Failed to get data: Cannot assign requested address

Here again I am not sure how to proceed… Is there an existing way of communicating through this socket? As in, some script I could modify and tell HA to run automatically?

I really appreciate your help and I am sorry I cannot do much more to debug this as my IT skills are clearly showing their limits here.
Thanks