Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Trouble with REST command
#1
Hello,

I've belatedly got around to updating from v8.3.7 to v8.3.9, and I've found that a REST command that worked previously no longer does. I was using the below command from Home Assistant to reset Spotify connect, as a way to stop playback:

http://[moodeURL]/command/?cmd=restart-renderer.php%20--spotify

The above method isn't documented in the setup guide, but I found it among forum tips. Meanwhile, I can see you've recently updated the REST functionality, and I wondered if there's an alternative way to do this.

The REST commands can be very useful in Home Assistant. If you could point me towards any extra documentation on those, I'd be very grateful.

Thanks!
Reply
#2
There is no alternative in r839 because the command was inadvertently left out when REST was refactored.

You can edit the file /var/www/command/index.php and add the case 'restart_renderer' code block. Then use http://moode/command/?cmd=restart_renderer --spotify

Code:
    case 'libupd-submit.php':    // DEPRECATED: not used via http
        $result = sysCmd('/var/www/util/libupd-submit.php');
        echo 'Library update submitted';
        break;
    case 'restart_renderer':     // --bluetooth | --airplay | --spotify | --squeezelite | --roonbridge
        $result = sysCmd('/var/www/util/restart-renderer.php ' . getArgs($cmd));
        echo (empty($result) ? 'OK' : 'Missing or invalid argument');
        break;
    default: // MPD commands
        if (false === ($sock = openMpdSock('localhost', 6600))) {
            debugLog('command/index.php: Connection to MPD failed');
        } else {
            sendMpdCmd($sock, $_GET['cmd']);
            $resp = readMpdResp($sock);
            closeMpdSock($sock);
            echo json_encode(parseMpdRespAsJSON($resp), JSON_FORCE_OBJECT);
        }
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(04-04-2024, 11:33 AM)Tim Curtis Wrote: There is no alternative in r839 because the command was inadvertently left out when REST was refactored.

You can edit the file /var/www/command/index.php and add the case 'restart_renderer' code block. Then use http://moode/command/?cmd=restart_renderer --spotify

Code:
    case 'libupd-submit.php':    // DEPRECATED: not used via http
        $result = sysCmd('/var/www/util/libupd-submit.php');
        echo 'Library update submitted';
        break;
    case 'restart_renderer':     // --bluetooth | --airplay | --spotify | --squeezelite | --roonbridge
        $result = sysCmd('/var/www/util/restart-renderer.php ' . getArgs($cmd));
        echo (empty($result) ? 'OK' : 'Missing or invalid argument');
        break;
    default: // MPD commands
        if (false === ($sock = openMpdSock('localhost', 6600))) {
            debugLog('command/index.php: Connection to MPD failed');
        } else {
            sendMpdCmd($sock, $_GET['cmd']);
            $resp = readMpdResp($sock);
            closeMpdSock($sock);
            echo json_encode(parseMpdRespAsJSON($resp), JSON_FORCE_OBJECT);
        }

Thanks Tim, that worked nicely.

 Smile
Reply


Forum Jump: