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

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?

the 401 is caused because I couldn’t find out how to add the token in the Chrome extension. I only send a empty POST request to the home assistant api. It was just to test if the api was ‘listening’.

Just created a new token, double checked admin rights. Same behavior.
Tried to add api: to home assistant configuration.yaml, no effect. Tried to remove my base_url on the http: component, no effect.

I’ll think about it over night :slight_smile: Maybe I can come up with something different to try.

Got it!

for me (using nginx reverse proxy) magic-cards only worked not using my local IP, but using the external URL:
actions.json:

{
  "Home Assistant": {
    "type": "home_assistant",
    "host": "MYURL",
    "port": "443",
    "ssl": true,
    "verify_ssl": true,
    "token": "MYTOKEN"
  }
}

Now getting my automations right and modifying my selfmade reader to fit in the raspberry and the reader:

Thanks Maddox!

I am triying to install via the docker intructions and coming up with
sudo git clone [email protected]:maddox/magic-cards-docker.git
Cloning into ‘magic-cards-docker’…
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

any ideas ??

I don’t see that command in the docker instructions.

Sorry I have tried it with sudo and without on the docker install when I try to clone the repo I get the following message. Many thanks for your help

[email protected]:~ $ git clone [email protected]:maddox/magic-cards-docker.git
Cloning into ‘magic-cards-docker’…
The authenticity of host ‘github.com (140.82.118.3)’ can’t be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘github.com,140.82.118.3’ (RSA) to the list of known hosts.

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[email protected]:~ $

Clone & Set Up Configs

Clone down the repo.

git clone [email protected]:maddox/magic-cards-docker.git

Cloning github is NOT part of the docker instructions!

Docker Install
Docker Stars Docker Pulls

Installing using Docker is the easiest path. You'll need to make sure you have Docker installed on your Pi first.

Install Docker
Installing Docker is as easy as a couple of commands:

curl -sSL https://get.docker.com/ | sh
If you are using a Raspberry Pi Zero W, there is an issue with Docker 18.09.1 that prevents Docker from properly installing. The current workaround is to downgrade to Docker 18.06.1, by using the following command:

sudo apt-get install docker-ce=18.06.2~ce~3-0~raspbian
Once it's installed, run this command so your pi user can use Docker.

sudo usermod -G docker pi
Log out of your Pi and back in so your user has permissions to use Docker.

Create Configuration
To run the Docker container, you need to do a couple things first. Create a directory for it to run in, set up your configuration, and then run the command to load up the container.

cd ~/
mkdir magic-cards
cd magic-cards
mkdir config
cd config
After that, you should be in the config directory. Read the standalone docs to learn how to configure Magic Cards. While you read that, you may want to pull down the image because this takes a while (docker pull jonmaddox/magic-cards)

Run Container
Once you've set up your configuration, navigate back to the magic-cards directory and load the Docker container:

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
This will download the image (if not already present), and create and run the container on port 5000 with the config directory you specified so it knows how to run. You may need to edit the device param to properly map to the input device Magic Cards will be reading from for your card reader. You can read about that in the standalone docs.

After that, the container will start up. It may take a little bit. It's just a little Raspberry Pi after all.

sorry I had been following this https://github.com/maddox/magic-cards-docker

[email protected]:~ $ mkdir magic-cards
[email protected]:~ $ cd magic-cards
[email protected]:~/magic-cards $ mkdir config
[email protected]:~/magic-cards $ cd config
[email protected]:~/magic-cards/config $ docker pull jonmaddox/magic-cards
Using default tag: latest
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/create?fromImage=jonmaddox%2Fmagic-cards&tag=latest: dial unix /var/run/docker.sock: connect: permission denied
[email protected]:~/magic-cards/config $

Following the other install and still get the permission refused I have enabled the user and logged out but I will fully check my end many thanks

If you can’t run docker commands, you probably forgot this step

sudo usermod -G docker pi

followed by log out and back in. To make sure you are in the docker group run

id

[email protected]:~ $ sudo usermod -G docker pi
[email protected]:~ $ id
uid=1000(pi) gid=1000(pi) groups=1000(pi),995(docker)
[email protected]:~ $ git clone [email protected]:maddox/magic-cards-docker.git
Cloning into ‘magic-cards-docker’…
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[email protected]:~ $ [email protected]:~ $ sudo usermod -G docker pi
[email protected]:~ $

Many thanks for your help I have done that step and numerous re installs of the os etc but no joy.

git is not a docker command. I told you how to fix docker.

Moving on to git, try

git clone  https://github.com/maddox/magic-cards

Many thanks, I have gone through the steps no probs with Docker it was the step in the tutorial step 4 https://github.com/maddox/magic-cards-docker I have tried on two different systems and networks but seems to be a permission issue.

OK so it works now?

No Sorry no it does not work I have tried to get it going but have the permission error. I cannot download part 4 on the tutorial. I have left it now and will try again in a few days but cannot get pass the permission issue. I have loaded a new sd card different networks etc. Updated my keys etc but I just cant get it to download. Thanks for your help.

Did you try the git clone command I gave you in this post? Magic Cards - Queue music, play movies, or trigger events with RFID cards

Hi yes I did sorry and same problem, I have managed to get it sorted through another program I have used the esprfid progam and a 8266 and MC522 and home assistant and have it all working now many thanks.

Hi,

does anyone use Magic Card with SSL encryption? For me it only works without encryption.
How is your config?