Coder Social home page Coder Social logo

node-sonos-nfc's Introduction

Node.js CI

Background

I wanted a way for my pre-smartphone daughter to select and play music in our house. There are companies that build purpose-built players for kids that utilize cards to control what they play, but they're expensive and represent another thing that we have to keep around. We already pay a monthly fee to stream pretty much anything -- why pay more? Why get another crappy speaker?

Snooping around, I found Sonos Vinyl Emulator, which does exactly what I want. Put a pre-programmed card (or anything else you can stick a NFC NTAG sticker on) near a cheap NFC card reader, and voilà, your chosen music plays from Apple Music or Spotify. Cards can also be programmed with commands, like skip track, adjust volume, turn on shuffle, etc, and are portable between rooms (if you care to setup multiple Vinyl Emulators). I imagined that making the cards themselves could be a fun activity, and with NTAG213 stickers <$15 for 50, we could make a bunch. There is also a nice aesthetic to controlling your streaming service with physical media -- the impetus behind Vinyl Emulator in the first place.

Sadly, newer versions of the recommended and widely available ACR122U card reader are not currently compatible with NFCpy, a library that Vinyl Emulator uses under the hood to talk to the reader. It turns out the ACR122U isn't really recommended for general NFC applications, since even though it has a chip inside that is capable of the full NFC suite of tricks, that chip is managed by an onboard controller that is not. The ACR122U is, however, a quite good smart card reader/writer via the PC/SC standard -- essentially a subset of NFC -- because that's what it was built for, and there are good PC/SC libraries available for most platforms and languages.

Thus, I decided to build something compatible with Sonos Vinyl Emulator from the ground up using Node.js and the nfc-pcsc library, which should support the wide range of card readers/writers that speak PC/SC, and absolutely does support the ACR122U. Anyone using Vinyl Emulator can use this code for new controllers and their existing cards should work exactly the same. This might be useful, for example, if someone buys a second ACR122U and finds, as I did, that it doesn't work with NFCpy.

Going forward, maybe I (and who knows, others?) can add additional features beyond reading the card and playing a song or executing another Sonos command. It might be useful, for example, to add a front-end for programming the cards easily without having to know the details of the Sonos API or how to find the album, track, or playlist code from your service of choice.

For those parents out there with Sonos and kids, let me just say that this thing is a hit with kids at least as young 4.

Install

You need a computer

The basic setup here involves a PC/SC card reader attached to a computer on the same network as your Sonos. The computer could be any computer that runs Node.js (so, any computer) and has drivers available for your card reader (depends on the card reader). If you have the ACR122U, you can use pretty much any computer with USB and networking capability. A popular option if you don't want to hook up to an existing computer is to purchase a Raspberry Pi. I think pretty much any model will do if it can properly power the card reader. I've used a version 3 and 4. There is a super cheap and tiny Pi Zero that could probably run the software but may struggle to source enough power for the card reader when it's actually reading cards. Check out the Raspberry Pi documentation if you want to setup a Raspberry Pi.

Card reader setup

This program uses the [nfc-pcsc] library to read (and someday?) write to PC/SC compatible smart card readers. The library is tested with the ACR122U but should work with any PC/SC compatible reader. Instructions here are mainly focused on ACR122U because that's what has been tested.

Make sure your card reader can be detected by your system by installing drivers as needed. For ACR122U on Ubuntu/Debian/Raspberry Pi OS:

$ sudo apt install libacsccid1

You also need to make sure your computer can speak PC/SC. In Ubuntu/Debian, install PC/SC libraries and daemon. You'll need to have a suitable build environment setup, e.g. have gcc installed. See the node-pcsclite instructions if you have any issues.

$ sudo apt install libpcsclite1 libpcsclite-dev pcscd

If you're running a version of Linux, your computer may try to use the nfc kernel module to talk to tyour ACR122U. You don't want it to do this, so make sure the nfc and enabling modules are not loaded. In Ubuntu/Debian/Raspberry Pi OS, blacklist pn533, pn533_usb, nfc modules so that they don't hijack the card reader.

$ printf '%s\n' 'pn533' 'pn533_usb' 'nfc' | sudo tee /etc/modprobe.d/blacklist-nfc.conf

To make sure everything is square, it's probably a good idea to reboot. In Ubuntu/Debian/Raspberry Pi OS:

$ sudo reboot

Setup Node

Install node and npm, e.g. download or follow the official instructions, so that you can run this code. On Ubuntu/Debian/Raspberry Pi OS, I do this:

$ curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
$ sudo apt-get install -y nodejs

Setup this code

Install git and clone this repo. In Ubuntu/Debian/Raspberry Pi OS,

$ sudo apt install git
$ git clone https://github.com/ryanolf/node-sonos-nfc.git

Install dependencies via npm. If you're following along in Ubuntu/Debian/Raspberry Pi OS, the commands are

$ cd node-sonos-nfc
$ npm install

For simplicity, sonos-http-api, needed for this program to work, is included as a dependency, though you don't need to use it if you already have an http api running elsewhere.

If you DO want to use the included Sonos HTTP API, you'll need to configure it. Rename the usersettings.json.example to usersettings.json and edit it to your liking. You'll need to set the spotify and/or apple sections to your credentials. You can also set the http section to your liking. The defaults should work fine for most people.

Run all the time

To run continuously and at boot, you'll want to run under some supervisor program. There are lots of options, like systemd (built-in already), supervisord, and pm2. I have found pm2, recommended by the author of Vinyl Emulator, to be very easy to use. To have pm2 spin-up sonos_nfc at boot and keep it running, install pm2 globally:

$ sudo npm install -g pm2

and spin-up sonos_nfc and sonos-http-api:

$ pm2 start npm -- run start-all

Then, to configure your system to run the startup, follow the instructions given when you run

$ pm2 startup

e.g.

$ sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi

If you already have the http API running elsewhere, you can direct this program to that server via the usersettings.json (rename it from .example and update to how you would like to use) and instead run just this program via npm start, so replace the pm2 start command above with

$ pm2 start npm -- start

Debug

You can monitor the process output to see what's going on. If you're using pm2, you can see the process output via

$ pm2 log

Programming cards

Card record format

The cards are programmed per the instructions at Sonos Vinyl Emulator. One minor difference with this program compared to Vinyl Emulator is that this program turns off shuffle, repeat, and crossfade whenever new music is queued by default. This is configurable in usersettings.json, you can turn off this behaviour by adding and/or setting reset_repeat, reset_shuffle and, reset_crossfade parameters to False. You can also enable cross fade, shuffle, or repeat on a card-by-card basis by adding records to enable these features to the card.

Writing cards

You can probably use the card reader/writer you plan to use to write the cards using software like NFC Tools on your Mac or PC. I like to use my iPhone. Most modern smartphones can read and write NFC with the right app.

It's important that before you write, the card is properly erased and formatted. On my iPhone, I format the cards for NDEF using "NXP Tagwriter." Once the cards are formatted, I use NFC Tools on iOS to write the record(s).

node-sonos-nfc's People

Contributors

ashenshugarret avatar codybrom avatar mattijsbliek avatar ryanolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-sonos-nfc's Issues

Unable to install

Hi there,

I'm following the guide to install, this and get this error during npm install.
This is on a Raspberry Pi 2.

PS: I'm not a technical person and simply trying to follow the step-by-step instructions!

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '[email protected]',
npm WARN EBADENGINE required: { node: '>=4.0.0', npm: '^2.0.0' },
npm WARN EBADENGINE current: { node: 'v20.11.0', npm: '10.2.4' }
npm WARN EBADENGINE }
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Package renamed to peak-readable.
npm WARN deprecated [email protected]: request-promise has been deprecated because it extends the now deprecated request package, see request/request#3142
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
npm ERR! code 1
npm ERR! path /home/ricardo/node-sonos-nfc/node_modules/@pokusew/pcsclite
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/home/ricardo/node-sonos-nfc/node_modules/@pokusew/pcsclite/build'
npm ERR! CXX(target) Release/obj.target/pcsclite/src/addon.o
npm ERR! make: Leaving directory '/home/ricardo/node-sonos-nfc/node_modules/@pokusew/pcsclite/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | linux | arm
npm ERR! gyp info find Python using Python version 3.9.2 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/ricardo/node-sonos-nfc/node_modules/@pokusew/pcsclite/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/root/.cache/node-gyp/20.11.0/include/node/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/root/.cache/node-gyp/20.11.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/root/.cache/node-gyp/20.11.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/ricardo/node-sonos-nfc/node_modules/@pokusew/pcsclite',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../../../nan/nan.h:176,
npm ERR! from ../src/pcsclite.h:4,
npm ERR! from ../src/addon.cpp:1:
npm ERR! ../../../nan/nan_callbacks.h:55:23: error: 'AccessorSignature' is not a member of 'v8'
npm ERR! 55 | typedef v8::Localv8::AccessorSignature Sig;
npm ERR! | ^~~~~~~~~~~~~~~~~
npm ERR! ../../../nan/nan_callbacks.h:55:40: error: template argument 1 is invalid
npm ERR! 55 | typedef v8::Localv8::AccessorSignature Sig;
npm ERR! | ^
npm ERR! In file included from ../src/pcsclite.h:4,
npm ERR! from ../src/addon.cpp:1:
npm ERR! ../../../nan/nan.h: In function 'void Nan::SetAccessor(v8::Localv8::ObjectTemplate, v8::Localv8::String, Nan::GetterCallback, Nan::SetterCallback, v8::Localv8::Value, v8::AccessControl, v8::PropertyAttribute, Nan::imp::Sig)':
npm ERR! ../../../nan/nan.h:2549:16: error: no matching function for call to 'v8::ObjectTemplate::SetAccessor(v8::Localv8::String&, void (&)(v8::Localv8::Name, const v8::PropertyCallbackInfov8::Value&), void (&)(v8::Localv8::Name, v8::Localv8::Value, const v8::PropertyCallbackInfo&), v8::Localv8::Object&, v8::AccessControl&, v8::PropertyAttribute&, Nan::imp::Sig&)'
npm ERR! 2549 | , signature);
npm ERR! | ^
npm ERR! In file included from /root/.cache/node-gyp/20.11.0/include/node/v8-function.h:15,
npm ERR! from /root/.cache/node-gyp/20.11.0/include/node/v8.h:33,
npm ERR! from /root/.cache/node-gyp/20.11.0/include/node/node.h:73,
npm ERR! from ../../../nan/nan.h:56,
npm ERR! from ../src/pcsclite.h:4,
npm ERR! from ../src/addon.cpp:1:
npm ERR! /root/.cache/node-gyp/20.11.0/include/node/v8-template.h:809:8: note: candidate: 'void v8::ObjectTemplate::SetAccessor(v8::Localv8::String, v8::AccessorGetterCallback, v8::AccessorSetterCallback, v8::Localv8::Value, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'
npm ERR! 809 | void SetAccessor(
npm ERR! | ^~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/20.11.0/include/node/v8-template.h:814:22: note: no known conversion for argument 7 from 'Nan::imp::Sig' {aka 'int'} to 'v8::SideEffectType'
npm ERR! 814 | SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
npm ERR! | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/20.11.0/include/node/v8-template.h:816:8: note: candidate: 'void v8::ObjectTemplate::SetAccessor(v8::Localv8::Name, v8::AccessorNameGetterCallback, v8::AccessorNameSetterCallback, v8::Localv8::Value, v8::AccessControl, v8::PropertyAttribute, v8::SideEffectType, v8::SideEffectType)'
npm ERR! 816 | void SetAccessor(
npm ERR! | ^~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/20.11.0/include/node/v8-template.h:821:22: note: no known conversion for argument 7 from 'Nan::imp::Sig' {aka 'int'} to 'v8::SideEffectType'
npm ERR! 821 | SideEffectType getter_side_effect_type = SideEffectType::kHasSideEffect,
npm ERR! | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! In file included from ../../../nan/nan.h:56,
npm ERR! from ../src/pcsclite.h:4,
npm ERR! from ../src/addon.cpp:1:
npm ERR! ../src/addon.cpp: At global scope:
npm ERR! /root/.cache/node-gyp/20.11.0/include/node/node.h:1172:7: warning: cast between incompatible function types from 'void ()(v8::Localv8::Object)' to 'node::addon_register_func' {aka 'void ()(v8::Localv8::Object, v8::Localv8::Value, void*)'} [-Wcast-function-type]
npm ERR! 1172 | (node::addon_register_func) (regfunc),
npm ERR! | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! /root/.cache/node-gyp/20.11.0/include/node/node.h:1206:3: note: in expansion of macro 'NODE_MODULE_X'
npm ERR! 1206 | NODE_MODULE_X(modname, regfunc, NULL, 0) // NOLINT (readability/null_usage)
npm ERR! | ^~~~~~~~~~~~~
npm ERR! ../src/addon.cpp:9:1: note: in expansion of macro 'NODE_MODULE'
npm ERR! 9 | NODE_MODULE(pcsclite, init_all)
npm ERR! | ^~~~~~~~~~~
npm ERR! make: *** [pcsclite.target.mk:124: Release/obj.target/pcsclite/src/addon.o] Error 1
npm ERR! gyp ERR! build error
npm ERR! gyp ERR! stack Error: make failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Linux 6.1.21-v7+
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/ricardo/node-sonos-nfc/node_modules/@pokusew/pcsclite
npm ERR! gyp ERR! node -v v20.11.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

Doc guidance: Multiple commands on NFC tag

Hi there - apologies if this is the wrong pathway to raise such query.

I read in the README section under Card record format:

You can enable cross fade, shuffle, or repeat on a card-by-card basis by adding records to enable these features to the card.

The question I have is, how exactly do I do that?

What I'm looking to do is clear the queue and decide on a per-card basis whether to enable shuffle etc.

Is there any information anywhere that helps to provide guidance on how to do this?

Thanks

[0] ReadError: Read operation failed: Status code: 0x6300

Hi raynolf,

I am getting an error message when reading NFC cards ("ReadError: Read operation failed: Status code: 0x6300"). Reader is recognized, as you can see in the log. When holding a card to the reader, it beeps/ LED color changes, but content can not be read. Tried with multiple cards - always same error. Reading with Win10/ NFC Tools or Android/ NFC tools does not show any issues.

Do you have any advise?

Regards

PM2 LOG - seems to come up nicely:

as@raspberrypi:~ $ pm2 log
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/home/as/.pm2/pm2.log last 15 lines:
PM2 | 2021-02-24T10:32:00: PM2 log: PM2 version : 4.5.4
PM2 | 2021-02-24T10:32:00: PM2 log: Node.js version : 15.9.0
PM2 | 2021-02-24T10:32:00: PM2 log: Current arch : arm
PM2 | 2021-02-24T10:32:00: PM2 log: PM2 home : /home/as/.pm2
PM2 | 2021-02-24T10:32:00: PM2 log: PM2 PID file : /home/as/.pm2/pm2.pid
PM2 | 2021-02-24T10:32:00: PM2 log: RPC socket file : /home/as/.pm2/rpc.sock
PM2 | 2021-02-24T10:32:00: PM2 log: BUS socket file : /home/as/.pm2/pub.sock
PM2 | 2021-02-24T10:32:00: PM2 log: Application log path : /home/as/.pm2/logs
PM2 | 2021-02-24T10:32:00: PM2 log: Worker Interval : 30000
PM2 | 2021-02-24T10:32:00: PM2 log: Process dump file : /home/as/.pm2/dump.pm2
PM2 | 2021-02-24T10:32:00: PM2 log: Concurrent actions : 2
PM2 | 2021-02-24T10:32:00: PM2 log: SIGTERM timeout : 1600
PM2 | 2021-02-24T10:32:00: PM2 log: ===============================================================================
PM2 | 2021-02-24T10:32:00: PM2 log: App [npm:0] starting in -fork mode-
PM2 | 2021-02-24T10:32:00: PM2 log: App [npm:0] online

/home/as/.pm2/logs/npm-error.log last 15 lines:
/home/as/.pm2/logs/npm-out.log last 15 lines:
0|npm | > concurrently --kill-others "npm start" "npm explore sonos-http-api -- npm start"
0|npm |
0|npm | [0]
0|npm | [0] > [email protected] start
0|npm | [0] > node sonos_nfc.js
0|npm | [0]
0|npm | [0] Control your Sonos with NFC cards. Searching for PCSC-compatible NFC reader devices...
0|npm | [0] ACS ACR122U 00 00 device attached
0|npm | [1]
0|npm | [1] > [email protected] start
0|npm | [1] > node server.js
0|npm | [1]
0|npm | [1] 2021-02-24T09:32:29.615Z INFO Could not find file /home/as/vinyl/node-sonos-nfc/node_modules/sonos-http-api/settings.json
0|npm | [1] 2021-02-24T09:32:30.745Z INFO Presets loaded: {}
0|npm | [1] 2021-02-24T09:32:36.161Z INFO http server listening on 0.0.0.0 port 5005

When holding a NFC card to the reader, log shows the following lines:

0|npm | [0] ACS ACR122U 00 00 detected TAG_ISO_14443_3 with UID 73984171
0|npm | [0]
0|npm | ReadError: Read operation failed: Status code: 0x6300
0|npm | [0]
0|npm | ACS ACR122U 00 00: TAG_ISO_14443_3 with UID 73984171 removed

Are contributions welcome?

Hey 👋

I'm planning to build a Raspberry Pi system based on this project, and I'd happily contribute some code. Before doing so, I thought it easiest to discuss first to see what you think 🙂

Would love to get your input on having the following changes:

  • Add Prettier to the codebase to avoid syntax discussions. Created a PR here.
  • Add reset_playback_options_on_queue setting like described in the existing README.
  • Add option to stop playback when card is removed from reader.
  • Replace console.log by a proper logger which doesn't output info messages in production.
  • Split up process_sonos_command.js and sonos_nfc.js so individual parts can be unit tested.
  • Add Jest and some tests.
  • Convert project to Typescript? Happy to do so, not sure if this is desirable from your perspective.

Let me know what you think. All the best,

Mattijs

Unable to play after alexa has played music

Hi there - I'm posting here, but don't know if this should go to one of the underlying libraries. I've noticed a specific scenario which seems to be generating an error when trying to play something using the NFC tag reader.

The issues invovles when music is already playing that was triggered by a request via Alexa and then attempts made to play via nfc tag reader.

Steps to recreate

  1. Reset sonos and raspberry pi.
  2. Play something through the nfc tag - all works fine (see logs below)
  3. Ask alexa to play something e.g. 'Alexa, play Kings of leon'. Music switches and plays new request.
  4. Remove the nfc tag and replace it. Errors with a comment about setting crossfade.
  5. nfc approach will continue to fail, even when the music stopped, until I use the sonos app to choose something manually from spotify/mylibrary.
  6. After manually setting, add the nfc tag, works all fine.

Logs

From pm2 log

1. Add an nfc tag after resetting sonos and raspberry pi

0|npm  | [0] ACS ACR122U 00 00 detected TAG_ISO_14443_3 with UID 041ea9b2ed6c81
0|npm  | [0] 
0|npm  | Read from NFC tag with message:  spotify:user:spotify:playlist:37i9dQZF1DWVFJtzvDHN4L
0|npm  | [0] Detected 'spotify' service request
0|npm  | [0] Resetting repeat
0|npm  | [0] Resetting shuffle
0|npm  | [0] 
0|npm  | Resetting crossfade
0|npm  | [0] Clearing Sonos queue
0|npm  | [0] Fetching URL via HTTP api: http://localhost:5005/Sun Room/spotify/now/spotify:user:spotify:playlist:37i9dQZF1DWVFJtzvDHN4L
0|npm  | [0] 
0|npm  | Sonos API reports:  { status: 'success' }
0|npm  | [0] 
0|npm  | Read from NFC tag with message:  command:shuffle/on
0|npm  | [0] Detected 'command' service request
0|npm  | [0] Fetching URL via HTTP api: http://localhost:5005/Sun Room/shuffle/on
0|npm  | [0] Sonos API reports:  { status: 'success' }
0|npm  | [0] 
0|npm  | Read from NFC tag with message:  command:next
0|npm  | [0] Detected 'command' service request
0|npm  | [0] Fetching URL via HTTP api: http://localhost:5005/Sun Room/next
0|npm  | [0] 
0|npm  | Sonos API reports:  { status: 'success' }

2. Logs after playing something via alexa and then re-tagging the nfc tag

0|npm  | [0] 
0|npm  | ACS ACR122U 00 00: TAG_ISO_14443_3 with UID 041ea9b2ed6c81 removed
0|npm  | [0] 
0|npm  | ACS ACR122U 00 00 detected TAG_ISO_14443_3 with UID 041ea9b2ed6c81
0|npm  | [0] 
0|npm  | Read from NFC tag with message:  spotify:user:spotify:playlist:37i9dQZF1DWVFJtzvDHN4L
0|npm  | [0] Detected 'spotify' service request
0|npm  | [0] Resetting repeat
0|npm  | [0] 
0|npm  | Resetting shuffle
0|npm  | [0] 
0|npm  | Resetting crossfade
0|npm  | [1] 
0|npm  | 2022-08-25T22:11:52.981Z ERROR 
0|npm  | [1]   Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control
0|npm  | [1]     at Object.invoke (/home/pi/node-sonos-nfc/node_modules/sonos-discovery/lib/helpers/soap.js:99:10)
0|npm  | [1]     at /home/pi/node-sonos-nfc/node_modules/sonos-discovery/lib/models/Player.js:682:19
0|npm  | [0] Error: Unexpected response while turning crossfade off: 500

3. Logs after changing song int he sonos app, then re-tagging the nfc tag

0|npm  | [0] ACS ACR122U 00 00: TAG_ISO_14443_3 with UID 041ea9b2ed6c81 removed
0|npm  | [0] 
0|npm  | ACS ACR122U 00 00 detected TAG_ISO_14443_3 with UID 041ea9b2ed6c81
0|npm  | [0] Read from NFC tag with message:  spotify:user:spotify:playlist:37i9dQZF1DWVFJtzvDHN4L
0|npm  | [0] Detected 'spotify' service request
0|npm  | [0] Resetting repeat
0|npm  | [0] 
0|npm  | Resetting shuffle
0|npm  | [0] 
0|npm  | Resetting crossfade
0|npm  | [0] 
0|npm  | Clearing Sonos queue
0|npm  | [0] Fetching URL via HTTP api: http://localhost:5005/Sun Room/spotify/now/spotify:user:spotify:playlist:37i9dQZF1DWVFJtzvDHN4L
0|npm  | [0] 
0|npm  | Sonos API reports:  { status: 'success' }
0|npm  | [0] 
0|npm  | Read from NFC tag with message:  command:shuffle/on
0|npm  | [0] Detected 'command' service request
0|npm  | [0] Fetching URL via HTTP api: http://localhost:5005/Sun Room/shuffle/on
0|npm  | [0] 
0|npm  | Sonos API reports:  { status: 'success' }
0|npm  | [0] Read from NFC tag with message:  command:next
0|npm  | [0] Detected 'command' service request
0|npm  | [0] Fetching URL via HTTP api: http://localhost:5005/Sun Room/next
0|npm  | [0] 
0|npm  | Sonos API reports:  { status: 'success' }

Notes on hardware set up

Just in case it helps to narrow down, this is my set up:

  • Sonos Play:1 (older model with no voice assistant)
  • Amazon echo dot 1st generation - paired with the Sonos as the primary speaker.
  • Raspberry Pi 3 Model B Rev 1.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.