Thank you for your donation!


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


[HOW-TO] Spotify Connect Web for Moode
Rafa,

I added a node in your node-red flow to write  into the currentsong.txt. This added a mechanism to wake up the Pi touchscreen LCD when it's blank due to inactivity. I have a lcd update python file just to turn on screen.

Now my setup is perfect :Smile The LCD goes blank when no music at some time. Then when I play either Moode or Spotify, the LCD would turn on and display the album art in cover view. 

Sharing my codes:

lcd_on.py
Code:
#!/usr/bin/python
import os, subprocess, time
os.environ['DISPLAY'] = ":0"
subprocess.call('xset s reset && xset dpms force on', shell=True)

Spotify Connect flow for Node Red
Code:
[{"id":"b574c915.994f78","type":"tab","label":"Spotify Connect Web","disabled":false,"info":"Quick and dirty interface to allow\nMoode Spotify Connect to report back\nto Moode and change the interface."},{"id":"898cb075.27c8f","type":"inject","z":"b574c915.994f78","name":"1 sec interval","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":380,"wires":[["93cd4f68.a21ab"]]},{"id":"93cd4f68.a21ab","type":"http request","z":"b574c915.994f78","name":"Spotify Status","method":"GET","ret":"obj","url":"http://localhost:4000/api/info/status","tls":"","x":380,"y":380,"wires":[["f9915bd3.344dc8"]]},{"id":"f9915bd3.344dc8","type":"function","z":"b574c915.994f78","name":"playStatus","func":"var previouslyPlaying = context.get('previouslyPlaying') || false;\nvar messages = [null, null, null];\n\nif (msg.payload.active) {\n    if ((flow.get('newClient') || !previouslyPlaying) && msg.payload.playing) {\n        flow.set('newClient', false);\n        context.set('previouslyPlaying', true);\n        messages[0] = {payload: '', action: 'start'};\n    }\n    \n    if (msg.payload.playing) {\n        messages[1] = {payload: '', action: 'playing'};\n    }\n    \n    \n    if (previouslyPlaying && !msg.payload.playing) {\n        context.set('previouslyPlaying', false);\n        messages[2] = {payload: '', action: 'stop'};\n    }\n}\n\nreturn messages;","outputs":3,"noerr":0,"x":550,"y":380,"wires":[["d7e04c5.b82e9b"],["f7eb964b.dbe888"],["e60b2be8.d67268"]],"outputLabels":["Start","Stop","Playing"]},{"id":"17d61a9f.7a4ee5","type":"http request","z":"b574c915.994f78","name":"Get Metadata","method":"GET","ret":"obj","url":"http://localhost:4000/api/info/metadata","tls":"","x":880,"y":360,"wires":[["66013ed4.6267e"]]},{"id":"66013ed4.6267e","type":"function","z":"b574c915.994f78","name":"isNewSong","func":"var previousTrack = flow.get('previousTrack') || '';\n\nif (previousTrack !== msg.payload.track_uri) {\n    flow.set('previousTrack', msg.payload.track_uri);\n    msg.action = 'newSong';\n    return msg;\n}\n\nreturn null;","outputs":1,"noerr":0,"x":1050,"y":360,"wires":[["269f4e32.46a112"]]},{"id":"13b40891.1e8bf7","type":"websocket out","z":"b574c915.994f78","name":"engine-spc-response","server":"2feef1d2.95f96e","client":"","x":1500,"y":420,"wires":[]},{"id":"d7e04c5.b82e9b","type":"function","z":"b574c915.994f78","name":"Start","func":"flow.set('previousTrack', '');\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":340,"wires":[["17d61a9f.7a4ee5"]]},{"id":"e60b2be8.d67268","type":"function","z":"b574c915.994f78","name":"Stop","func":"\nreturn msg;","outputs":1,"noerr":0,"x":710,"y":420,"wires":[["269f4e32.46a112"]]},{"id":"f7eb964b.dbe888","type":"function","z":"b574c915.994f78","name":"Playing","func":"\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":380,"wires":[["17d61a9f.7a4ee5"]]},{"id":"269f4e32.46a112","type":"function","z":"b574c915.994f78","name":"Format Output","func":"msg.payload = {\n    action: 'engineSpc:' + msg.action,\n    metadata: msg.payload\n};\n\nreturn msg;","outputs":1,"noerr":0,"x":1260,"y":420,"wires":[["13b40891.1e8bf7","1304fbd3.c85b54","a0dd72c9.4bc6"]]},{"id":"1304fbd3.c85b54","type":"debug","z":"b574c915.994f78","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1470,"y":480,"wires":[]},{"id":"96d83b9.3c07dc8","type":"websocket in","z":"b574c915.994f78","name":"Client","server":"2feef1d2.95f96e","client":"","x":150,"y":460,"wires":[["4fa19d46.c08404"]]},{"id":"4fa19d46.c08404","type":"function","z":"b574c915.994f78","name":"newClient","func":"flow.set('newClient', true);\nreturn null;","outputs":1,"noerr":0,"x":320,"y":460,"wires":[[]]},{"id":"feff1650.047f18","type":"file","z":"b574c915.994f78","name":"lcdOutput","filename":"/var/local/www/currentsong.txt","appendNewline":true,"createDir":false,"overwriteFile":"true","x":1700,"y":540,"wires":[[]]},{"id":"a0dd72c9.4bc6","type":"function","z":"b574c915.994f78","name":"extractMetaData","func":"msg.payload = {\n    artist: msg.payload.metadata.artist_name,\n    album: msg.payload.metadata.album_name,\n    title: msg.payload.metadata.track_name,\n}\nreturn msg","outputs":1,"noerr":0,"x":1500,"y":540,"wires":[["feff1650.047f18"]]},{"id":"2feef1d2.95f96e","type":"websocket-listener","z":"","path":"/engine-spc","wholemsg":"false"}]
Reply


Messages In This Thread
RE: Spotify Connect for Moode - by Tim Curtis - 04-06-2018, 07:34 PM
RE: Spotify Connect for Moode - by RafaPolit - 04-07-2018, 05:30 AM
RE: Spotify Connect for Moode - by deafnut - 04-07-2018, 08:01 PM
RE: Spotify Connect for Moode - by RafaPolit - 04-08-2018, 05:28 AM
RE: Spotify Connect for Moode - by gabmartini - 04-09-2018, 02:08 AM
RE: Spotify Connect for Moode - by pinkdot - 04-09-2018, 04:58 PM
RE: Spotify Connect for Moode - by airdronian - 04-17-2018, 09:01 PM
RE: Spotify Connect for Moode - by Tim Curtis - 04-09-2018, 02:18 AM
RE: Spotify Connect for Moode - by franz159 - 04-11-2018, 04:43 AM
RE: Spotify Connect for Moode - by JonPike - 05-03-2018, 01:59 AM
RE: Spotify Connect for Moode - by RafaPolit - 04-11-2018, 05:43 AM
RE: Spotify Connect for Moode - by jonners - 04-11-2018, 07:39 AM
RE: Spotify Connect for Moode - by gabmartini - 04-13-2018, 11:33 PM
RE: Spotify Connect for Moode - by pinkdot - 04-14-2018, 08:10 AM
RE: Spotify Connect for Moode - by Tim Curtis - 04-14-2018, 12:14 PM
RE: Spotify Connect for Moode - by RafaPolit - 04-17-2018, 10:10 PM
RE: Spotify Connect for Moode - by airdronian - 04-17-2018, 11:31 PM
RE: Spotify Connect for Moode - by gabmartini - 04-17-2018, 11:50 PM
RE: Spotify Connect for Moode - by airdronian - 04-18-2018, 12:13 AM
RE: Spotify Connect for Moode - by airdronian - 04-19-2018, 05:34 PM
RE: Spotify Connect for Moode - by Onionhead - 04-23-2018, 01:40 AM
RE: Spotify Connect for Moode - by pinkdot - 04-23-2018, 05:50 AM
RE: Spotify Connect for Moode - by RafaPolit - 04-23-2018, 06:18 PM
RE: Spotify Connect for Moode - by Onionhead - 04-23-2018, 06:35 PM
RE: Spotify Connect for Moode - by gabmartini - 04-27-2018, 11:31 PM
RE: Spotify Connect for Moode - by pinkdot - 04-28-2018, 07:48 AM
RE: Spotify Connect for Moode - by grasshopper - 04-29-2018, 10:26 AM
RE: Spotify Connect for Moode - by JonPike - 05-03-2018, 03:05 AM
RE: Spotify Connect for Moode - by grasshopper - 05-03-2018, 07:08 PM
RE: Spotify Connect for Moode - by JonPike - 05-16-2018, 01:33 AM
RE: Spotify Connect for Moode - by grasshopper - 05-17-2018, 07:00 PM
RE: Spotify Connect for Moode - by Me2018 - 01-22-2019, 02:40 PM
RE: Spotify Connect for Moode - by npetra - 08-28-2019, 05:18 PM
RE: Spotify Connect for Moode - by grasshopper - 01-17-2019, 12:00 PM
RE: Spotify Connect for Moode - by grasshopper - 04-29-2018, 10:38 AM
RE: Spotify Connect for Moode - by RafaPolit - 04-29-2018, 10:53 AM
RE: Spotify Connect for Moode - by aBrianH - 04-30-2018, 10:11 AM
RE: Spotify Connect for Moode - by RafaPolit - 05-01-2018, 03:59 AM
RE: Spotify Connect for Moode - by gabmartini - 05-02-2018, 03:43 AM
RE: Spotify Connect for Moode - by grasshopper - 05-02-2018, 06:11 PM
RE: Spotify Connect for Moode - by RafaPolit - 05-12-2018, 12:53 AM
RE: Spotify Connect for Moode - by Tim Curtis - 05-12-2018, 12:52 PM
RE: [HOW-TO] Spotify Connect Web for Moode - by ferdzb - 09-09-2018, 06:40 AM
Error when Spotify Connect Web - by IT-Andy52 - 09-06-2019, 08:54 AM
RE: Error when Spotify Connect Web - by RafaPolit - 09-25-2019, 07:39 PM

Forum Jump: