Magic Cards - Queue music, play movies, or trigger events with RFID cards

Also @maddox - I initially had an error getting Docker to start. Seems like a bug in docker v18.9. This fixed it by downgrading to 18.6. Just in the event anyone else asks.

sudo apt-get install docker-ce=18.06.1~ce~3-0~raspbian

1 Like

ok, intersting this thread, but what about card readers? is there a reader battery sourced maybe on zigbee/zwave protocol?
i want to use cards to arm/disarm my alarm

A very low security alarm!

1 Like

Alright I’m clearly more stunned than I thought. What version of windows does the demo.exe tool work under? I’ve tried both windows 7 and 10 and get this same error in both

Hi
I have the docker version installed and running, but it seems it keeps restarting:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f1a045b3c3d7 jonmaddox/magic-cards “/usr/bin/entry.sh s…” 2 minutes ago Up 33 seconds 0.0.0.0:5000->5000/tcp magic-cards

Anyone have an idea of how that might be? I am pretty lost where I stand right now :confused:

Perhaps

docker logs f1a045b3c3d7

I’ll try that out ASAP. Thanks

My log looks like this. I don’t know what yarn is, though. Is it a part of magic cards?

Starting Magic Cards...
    [0] $ cd server && yarn start
    [1] $ cd scanner && yarn start
    [0] $ node server.js
    [1] $ node scanner.js
    [1] internal/modules/cjs/loader.js:550
    [1]     throw err;
    [1]     ^
    [1]
    [1] Error: Cannot find module '/usr/src/app/scanner/actions/../../config/config.json'
    [1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [1]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [1]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [1]     at require (internal/modules/cjs/helpers.js:11:18)
    [1]     at Object.<anonymous> (/usr/src/app/scanner/actions/Action.js:1:84)
    [1]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [1]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [1]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] yarn scanner exited with code 1
    --> Sending SIGTERM to other processes..
    [0] internal/modules/cjs/loader.js:550
    [0]     throw err;
    [0]     ^
    [0]
    [0] Error: Cannot find module '/usr/src/app/server/../config/config.json'
    [0]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [0]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [0]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [0]     at require (internal/modules/cjs/helpers.js:11:18)
    [0]     at Object.<anonymous> (/usr/src/app/server/server.js:7:16)
    [0]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [0]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [0]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [0]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] yarn server exited with code SIGTERM
    error Command failed with exit code 1.
    Starting Magic Cards...
    [0] $ cd server && yarn start
    [1] $ cd scanner && yarn start
    [0] $ node server.js
    [1] $ node scanner.js
    [1] internal/modules/cjs/loader.js:550
    [1]     throw err;
    [1]     ^
    [1]
    [1] Error: Cannot find module '/usr/src/app/scanner/actions/../../config/config.json'
    [1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [1]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [1]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [1]     at require (internal/modules/cjs/helpers.js:11:18)
    [1]     at Object.<anonymous> (/usr/src/app/scanner/actions/Action.js:1:84)
    [1]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [1]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [1]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] yarn scanner exited with code 1
    --> Sending SIGTERM to other processes..
    [0] internal/modules/cjs/loader.js:550
    [0]     throw err;
    [0]     ^
    [0]
    [0] Error: Cannot find module '/usr/src/app/server/../config/config.json'
    [0]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [0]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [0]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [0]     at require (internal/modules/cjs/helpers.js:11:18)
    [0]     at Object.<anonymous> (/usr/src/app/server/server.js:7:16)
    [0]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [0]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [0]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [0]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] yarn server exited with code SIGTERM
    error Command failed with exit code 1.
    Starting Magic Cards...
    [0] $ cd server && yarn start
    [1] $ cd scanner && yarn start
    [0] $ node server.js
    [1] $ node scanner.js
    [1] internal/modules/cjs/loader.js:550
    [1]     throw err;
    [1]     ^
    [1]
    [1] Error: Cannot find module '/usr/src/app/scanner/actions/../../config/config.json'
    [1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [1]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [1]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [1]     at require (internal/modules/cjs/helpers.js:11:18)
    [1]     at Object.<anonymous> (/usr/src/app/scanner/actions/Action.js:1:84)
    [1]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [1]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [1]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] yarn scanner exited with code 1
    --> Sending SIGTERM to other processes..
    [0] internal/modules/cjs/loader.js:550
    [0]     throw err;
    [0]     ^
    [0]
    [0] Error: Cannot find module '/usr/src/app/server/../config/config.json'
    [0]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [0]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [0]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [0]     at require (internal/modules/cjs/helpers.js:11:18)
    [0]     at Object.<anonymous> (/usr/src/app/server/server.js:7:16)
    [0]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [0]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [0]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [0]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] yarn server exited with code SIGTERM
    error Command failed with exit code 1.
    Starting Magic Cards...
    Starting Magic Cards...
    [0] $ cd server && yarn start
    [1] $ cd scanner && yarn start
    [0] $ node server.js
    [1] $ node scanner.js
    [1] internal/modules/cjs/loader.js:550
    [1]     throw err;
    [1]     ^
    [1]
    [1] Error: Cannot find module '/usr/src/app/scanner/actions/../../config/config.json'
    [1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [1]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [1]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [1]     at require (internal/modules/cjs/helpers.js:11:18)
    [1]     at Object.<anonymous> (/usr/src/app/scanner/actions/Action.js:1:84)
    [1]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [1]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [1]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] yarn scanner exited with code 1
    --> Sending SIGTERM to other processes..
    [0] internal/modules/cjs/loader.js:550
    [0]     throw err;
    [0]     ^
    [0]
    [0] Error: Cannot find module '/usr/src/app/server/../config/config.json'
    [0]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    [0]     at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    [0]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [0]     at require (internal/modules/cjs/helpers.js:11:18)
    [0]     at Object.<anonymous> (/usr/src/app/server/server.js:7:16)
    [0]     at Module._compile (internal/modules/cjs/loader.js:654:30)
    [0]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [0]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [0]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
        at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] yarn server exited with code SIGTERM
    error Command failed with exit code 1.
    Starting Magic Cards...
    Starting Magic Cards...
    [0] $ cd server && yarn start
    [1] $ cd scanner && yarn start
    [1] $ node scanner.js
    [0] $ node server.js
    [1] internal/modules/cjs/loader.js:676
    [1]     throw err;
    [1]     ^
    [1]
    [1] SyntaxError: /usr/src/app/config/config.json: Unexpected token } in JSON at position 47
    [1]     at JSON.parse (<anonymous>)
    [1]     at Object.Module._extensions..json (internal/modules/cjs/loader.js:673:27)
    [1]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [1]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    [1]     at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [1]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [1]     at require (internal/modules/cjs/helpers.js:11:18)
    [1]     at Object.<anonymous> (/usr/src/app/scanner/actions/Action.js:1:84)
    [1]     at Module._compile (internal/modules/cjs/loader.js:654:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] error Command failed with exit code 1.
    [1] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [1] yarn scanner exited with code 1
    --> Sending SIGTERM to other processes..
    [0] internal/modules/cjs/loader.js:676
    [0]     throw err;
    [0]     ^
    [0]
    [0] SyntaxError: /usr/src/app/config/config.json: Unexpected token } in JSON at position 47
    [0]     at JSON.parse (<anonymous>)
    [0]     at Object.Module._extensions..json (internal/modules/cjs/loader.js:673:27)
    [0]     at Module.load (internal/modules/cjs/loader.js:566:32)
    [0]     at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    [0]     at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    [0]     at Module.require (internal/modules/cjs/loader.js:598:17)
    [0]     at require (internal/modules/cjs/helpers.js:11:18)
    [0]     at Object.<anonymous> (/usr/src/app/server/server.js:7:16)
    [0]     at Module._compile (internal/modules/cjs/loader.js:654:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] error Command failed with exit code 1.
    [0] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    [0] yarn server exited with code SIGTERM
    error Command failed with exit code 1.
    Starting Magic Cards...

Sorry for long post.

This means it can’t find your config file. Did you add it and edit it? You might not be mounting your config directory into your docker container correctly when you bring it up.

You might want to read through the docker installation instructions again.

Paste in here what you’re using to launch it.

You mean in the config.json?

{
  "room": "Sia",
  "input_device": "event0",
}

I created the folders, and inside the config folder, I created the actions.json and config.json. I removed the spotify part, as I will not be using spotify at all. Only for homeassistant events.

After that, I ran the docker run command, pasted in from the docs, after making sure the card reader was registered as event0:

docker run \
  --name magic-cards \
  --restart=always \
  -d \
  -p 5000:5000 \
  -v `pwd`/config:/usr/src/app/config \
  --device=/dev/input/event0 \
  jonmaddox/magic-cards

Now that I check, I suddently have a config folder under mig magic-cards/config/
That seems odd.

Got it!
I did not get from the docs Spotify was required in config.json.

I deleted the old container and created a new, to make sure the second config folder was out of the out of the picture again. Have it up running now.
Will start playing around with it. Thanks for your assistance, that made me realize the error. Learning is a wonderful thing ;D

Answering my own question - this was solved with help from user emmdubbleyou over on the magic cards spectrum forum:

If you are using Spotify or Apple music to play a song/album, I think the key to your issue might be in the URI field when you are creating the card. If you want the song/album to play immediately upon scanning the card, use ‘now’ instead of ‘queue’ in the URI field.

1 Like

Hi again, I’ve managed to get things up and running. I’m running the magic-cards docker install on a raspberry pi and the node-sonos-http-api as a docker container on my synology (couldn’t get it to work on raspberry pi).

I’ve set up a card, but I can’t get it to play. The magic-cards docker log says:

[0] Finding card... [0] Found card: Acoustic Favorites. Processing... [0] Processing action: Sonos [0] Calling: http://192.168.1.58:5005/Speaker%20Piano/repeat/all [0] Calling: http://192.168.1.58:5005/zones [0] (node:92) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'uuid' of undefined [0] at SonosAction.forcePlaylistPlayback (/usr/src/app/scanner/actions/SonosAction.js:59:70) [0] at &lt;anonymous&gt; [0] at process._tickCallback (internal/process/next_tick.js:182:7) [0] (node:92) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) [0] (node:92) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. [0] null

Never mind! I got it working by using the room in the config file as the “Living Room” (the coordinator). YAYYYYYY it’s working thanks so much!

Any ideas on how to make it work with multiple RFID readers around the house?

Easy, 1 setup for every area in your house, lol. You need a computer to relay the info, not just the reader. The Pi IS the computer. That’s what’s so great about it’s price.

Dumb question maybe, bu how do I upgrade the docker installation?
Just by running:

cd ~/magic-cards
docker run \
  --name magic-cards \
  --restart=always \
  -d \
  -p 5000:5000 \
  -v `pwd`/config:/usr/src/app/config \
  --device=/dev/input/event0 \
  jonmaddox/magic-cards

?

i am using a long lived access token from within hassio exclusively for magic cards but I run into an 401 error. Magic Cards Docker Logs show me this:

[1] Read Card ID: 0800437578
[1] Finding card…
[1] Found card: I Love My '90s Hip-Hop. Processing…
[1] Processing action: Home Assistant
[1] 401: Unauthorized

and Hassio Logs show me this:

2019-05-10 11:08:17 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from MY.IP.ADDRESS

Any idea what might be causing that issue?

Just a side note: i just changed the actions.json by switching from password to token. Do I need to do a full upgrade of magic cards docker files as well? if so, how?

I just tried reinstalling but still having the same issue.

I run into an 401 error identical to the one I posted before.

This is my config.json:

{
“Home Assistant”: {
“type”: “home_assistant”,
“host”: “MYDOMAIN.duckdns.org”,
“port”: “443”,
“ssl”: true,
“verify_ssl”: false,
“token”: “MYLONGLIVEDACCESSTOKEN”
}
}

Any idea, what might be going wrong?

i also tried using the IP address and the error message looks like this, although Verify SSL is set to FALSE:

[1] Read Card ID: 0800437578
[1] Finding card…
[1] Found card: I Love My '90s Hip-Hop. Processing…
[1] Processing action: Home Assistant
[1] { FetchError: request to https://MYIPADDRESS:8123/api/events/magic_card_scanned failed, reason: Hostname/IP does not match certificate’s altnames: IP: MYIPADDRESS is not in the cert’s list:
[1] at ClientRequest. (/usr/src/app/scanner/node_modules/node-fetch/lib/index.js:1393:11)
[1] at ClientRequest.emit (events.js:180:13)
[1] at TLSSocket.socketErrorListener (_http_client.js:395:9)
[1] at TLSSocket.emit (events.js:180:13)
[1] at emitErrorNT (internal/streams/destroy.js:64:8)
[1] at process._tickCallback (internal/process/next_tick.js:178:19)
[1] message: 'request to https://MYLOCALIPADDRESS:8123/api/events/magic_card_scanned failed, reason: Hostname/IP does not match certificate's altnames: IP: MYIPADDRESS is not in the cert's list: ',
[1] type: ‘system’,
[1] errno: ‘ERR_TLS_CERT_ALTNAME_INVALID’,
[1] code: ‘ERR_TLS_CERT_ALTNAME_INVALID’ }

another update:
i added legacy auth via api password within my hassio config and changed the actions.json token entry to password with the according hassio password. this way, magic cards works as it should.

nevertheless, the token approach is the preferred solution of course but it does not seem to work. @maddox is there something wrong with the repo?