I believe
docker pull jonmaddox/magic-cards
I believe
docker pull jonmaddox/magic-cards
Is it possible to implement this with an NFC reader and tags/cards? If so, how much more involved would it be?
Thanks!
Iām using this format for URI to play spotify album
spotify/now/spotify:album:1To7kv722A8SpZF789MZy7
Iām using my:
You should be able to browser to that URL in the browser. Probably ignoring the warning about the cert. And get to see home assistant. i.e. https://192.168.0.99:8123 If you canāt browse that, I would assume magic cards canāt connect to the api either.
Hello @maddox. This looks awesome. I want to do this for my kid so he can select the music to play on Alexa / Spotify.
Few questions regarding this before I purchase everything.
Also, regarding the installation with HA, you say āpoint at it in your Home Assistant Installā. Do you mean in the configurator.yaml?
Finally, when I add the automation in HA, does it means that it will automatically extract the URL of the spotify song/album I want and play it automatically? (is it the āURIā field in the āCreate cardā interface?)
Sorry, Iām not too technical so not super sure what Iām doing
Thanks
As long as it can read RFID and presents itself as a keyboard, it should work. One thing to make sure of is that it spits out the same codes on all platforms. I personally keep one at my desk to create the cards in the Magic Cards UI. So I can just make a card there, then scan a physical card, and done.
That means I have a scanner plugged into macOS and Linux. So itās important they output the same codes.
Nope. They can be read only. You just need their unique ID.
Read the install docs, itāll show you how to set it up for Home Assistant.
No. It sends along a unique string. You can make it anything you want. You set this URI in the card when you make it. The card has a unique ID that your automation needs to be able to decode and do something with. Itās just sending a simple string. You get to make up that string.
Hello mate.
Iāve got the same issue as you. Did you solve it?
Edit: I just found this: https://github.com/maddox/magic-cards/issues/26
Some people say you can go on without this step. Some readers are properly configured already. Iāll try and let you know
I think this could be quite cool implemented with QR codes - easier to print than a RFID card. Plonk it through the laminator and away you do.
Just an idea, I love this integration.
I ended up not needing to get the tool working as all three readers I bought were already setup to read the portion of the card I wanted. Basically there are 2 versions of this reader out there. One that reads the 1st 10 digits and one that reads the last 8.
Hey guys.
So far so good regarding the installation. I have just one issue.
1/ when I try to create a card with Spotify URL, it doesnāt autofill. I have an error in browser console āSyntaxError: Unexpected token e in JSON at position 0ā. In the logs of docker I have
2019-10-29T13:17:51.687718606Z [0] Something went wrong when retrieving an access token { [WebapiError: Bad Request] name: 'WebapiError', message: 'Bad Request', statusCode: 400 }
2019-10-29T13:18:15.281413678Z [0] (node:73) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
Anything I have done wrong here?
My config.json seems to be ok regarding the tutorial.
EDIT: I have a second issue with my automation to trigger the music on my Amazon Echo device
Here is what I have entered
- alias: Play song from Magic Cards
trigger:
- platform: event
event_type: magic_card_scanned
event_data:
card_type: "song"
action:
- service: media_player.select_source
data_template:
entity_id: media_player.spotify
source: #name of my Amazon Alexa device
- service: media_player.play_media
data_template:
entity_id: media_player.spotify
media_content_type: playlist
media_content_id: trigger.event.data.card_uri
Seems like the automation triggers (in the logs), but nothing really happens after, so I guess itās the action section that is not good.
cc @maddox for the 1st point if you have any idea
Thanks
For the second issue, I found out what was happening. Home Assistant only manages Album/Playlist URI I have setup a card with an album URI and it works.
Really too bad, wanted to make cards for my kid to play specific kids songs. Anyone has ever done this in another way?
And you have your Spotify developer stuff set up correctly?I wonder if the code has gone bad with changes from Spotify. I donāt have a Magic Cards setup right now as Iāve recently moved, so I canāt test it. Does this Spotify work for anyone else?
Card URIs can be anything you want. It just happens that the album and artist URI thatās being filled in for you match what your spotify media player component uses. If you can figure out what it uses for a single song, enter that as the card URI in the magic cards ui.
For the second issue, Iāve found the solution. Basically the media_content_type: must be āmusicā for track URI and āplaylistā for albums
Thanks once again for your work because itās pretty straightforward and itās gonna be fun playing around with this.
Regarding the autofill, seems all my conf is alright. Will triple check but itās not a big deal anyway
Any chance you had a look into it?
I can give you all information needed. Glad to help on this
pfff. Iām having hard times on figuring out these logs:
20-01-14T20:31:32.311865355Z [0] Finding card...
2020-01-14T20:31:32.312461349Z [0] Found card: Take From Me. Processing...
2020-01-14T20:31:32.338074113Z [0] Processing action: Home Assistant
2020-01-14T20:31:32.338325111Z [0] { FetchError: request to https://MYLOCALIP:8123/api/events/magic_card_scanned failed, reason: write EPROTO 3070067880:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:
2020-01-14T20:31:32.338457109Z [0]
2020-01-14T20:31:32.338576108Z [0] at ClientRequest.<anonymous> (/usr/src/app/scanner/node_modules/node-fetch/lib/index.js:1393:11)
2020-01-14T20:31:32.338700107Z [0] at ClientRequest.emit (events.js:180:13)
2020-01-14T20:31:32.338816106Z [0] at TLSSocket.socketErrorListener (_http_client.js:395:9)
2020-01-14T20:31:32.338933105Z [0] at TLSSocket.emit (events.js:180:13)
2020-01-14T20:31:32.339049104Z [0] at onwriteError (_stream_writable.js:431:12)
2020-01-14T20:31:32.339170103Z [0] at onwrite (_stream_writable.js:453:5)
2020-01-14T20:31:32.339287102Z [0] at _destroy (internal/streams/destroy.js:39:7)
2020-01-14T20:31:32.339404101Z [0] at TLSSocket.Socket._destroy (net.js:548:3)
2020-01-14T20:31:32.339521100Z [0] at TLSSocket.destroy (internal/streams/destroy.js:32:8)
2020-01-14T20:31:32.339637099Z [0] at WriteWrap.afterWrite [as oncomplete] (net.js:846:10)
2020-01-14T20:31:32.339756097Z [0] message: 'request to https://10.0.4.80:8123/api/events/magic_card_scanned failed, reason: write EPROTO 3070067880:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:827:\n',
2020-01-14T20:31:32.341059085Z [0] type: 'system',
2020-01-14T20:31:32.341243084Z [0] errno: 'EPROTO',
2020-01-14T20:31:32.341374083Z [0] code: 'EPROTO' }
2020-01-14T20:31:32.341492081Z [0] null
My actions.json looks like this:
{
"Home Assistant": {
"type": "home_assistant",
"host": "MYLOCALIP",
"port": "8123",
"ssl": true,
"verify_ssl": false,
"token": "MYTOKEN"
}
}
When I browse to https://MYLOCALIP:8123/api/events/magic_card_scanned, firefox complains about
Secure Connection Failed
An error occurred during a connection to MYLOCALIP:8123. SSL received a record that exceeded the maximum permissible length.
Error code: SSL_ERROR_RX_RECORD_TOO_LONG
Iām using nginx reverse proxy addon. Probably making things over-complicated with this addon.
Anybody a clue?
Thanks in advance
Do you actually have a cert attached to that reverse proxy? I see youāre using https
and thereās an openssl error, this might be the issue. Try just http
.
Hey Maddox, Iāll try just http again tomorrow and let you know. Thank you for your quick reply!
Allright, i tried http using this config in actions.json:
{
"Home Assistant": {
"type": "home_assistant",
"host": "MYLOCALIP",
"port": "8123",
"ssl": false,
"verify_ssl": false,
"token": "MYLONGLIVEDTOKEN"
}
}
I can access my home assistant, using http://MYLOCALIP:8123; it gives me the login screen.
I used a chrome extension āpostmanā to send a POST request to http://MYLOCALIP:8123/api/events/magic_card_scanned
It returns a 401 unauthorized. I guess this means my HA restful-api is reachable.
Unfortunately I still find these errors in my magic-home log:
2020-01-15T19:55:56.274495233Z [0] Finding card...
2020-01-15T19:55:56.274769300Z [0] Found card: Take From Me. Processing...
2020-01-15T19:55:56.274913335Z [0] Processing action: Home Assistant
2020-01-15T19:55:56.275045368Z [0] Error [ERR_INVALID_PROTOCOL]: Protocol "http:" not supported. Expected "https:"
2020-01-15T19:55:56.275173399Z [0] at new ClientRequest (_http_client.js:132:11)
2020-01-15T19:55:56.275299430Z [0] at request (http.js:41:10)
2020-01-15T19:55:56.275431462Z [0] at /usr/src/app/scanner/node_modules/node-fetch/lib/index.js:1375:15
2020-01-15T19:55:56.275558493Z [0] at new Promise (<anonymous>)
2020-01-15T19:55:56.275689526Z [0] at fetch (/usr/src/app/scanner/node_modules/node-fetch/lib/index.js:1367:9)
2020-01-15T19:55:56.275817557Z [0] at HomeAssistantAction.request (/usr/src/app/scanner/actions/HomeAssistantAction.js:50:12)
2020-01-15T19:55:56.275944588Z [0] at HomeAssistantAction.process (/usr/src/app/scanner/actions/HomeAssistantAction.js:7:10)
2020-01-15T19:55:56.276072619Z [0] at CardProcessor.processCard (/usr/src/app/scanner/CardProcessor.js:55:23)
2020-01-15T19:55:56.276197650Z [0] at CardProcessor.process (/usr/src/app/scanner/CardProcessor.js:19:10)
2020-01-15T19:55:56.276324681Z [0] at Object.<anonymous> (/usr/src/app/scanner/testCard.js:5:15)
2020-01-15T19:55:56.276506726Z [0] null
It must me something obvious that Iām missing here.
Did you create a token for a normal user? Tokens only actually work for admin users.
I found this out the hard way too.
@Tokast Regarding autofill:
I can confirm that with this config.json autofill works for me:
{
"room": "Living Room",
"input_device": "event0",
"spotify": {
"clientID": "MY_ID",
"clientSecret": "MY_SECRET"
}
}
If I paste the spotify web URL from a song Iād like to add, autofill works for me.
I paste for example https://open.spotify.com/album/4tf6qaCdmsaydU8uuguVOZ
Probably this isnāt going to help you. Maybe your generated development credentials for Spotify are wrong?