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

You could use a condition, but you’ll need to duplicate your automations AFAIK

condition:
    condition: template
    value_template: "{{ 'something-you-need' in trigger.event.data.card_uri }}"

Hi .

Having problems getting Magic Cards and Hassio working together.

I’ve got a freshly installed a PiZero and using the guide to install Magic Cards in docker.

I’ve created the follow json files
actions.json


{
  "type": "home_assistant",
  "host": "192.168.x.x",
  "port": "8123",
  "ssl": false,
  "verify_ssl": false,  
  "password: "mypassword"
}

(I’ve also tried "token: “mylonglivedtoken)”

config.json

{
  "room": "Living Room",
  "input_device": "event0",
  "spotify": {
    "clientID": "myid",
    "clientSecret": "mysecret"
  }
}

I’m not sure I understand what I need to do for Home Assistant side of things? I know I will have to create an automation but do I need to create an entity or install a plugin or even add to the config.yaml?

On my PiZero magic cards loads and i can see the web interface on port 5000.
I’ve created card for testing.

using the docker logs --timestamps --follow magic-cards
i can see the following error when i read a card

2020-10-31T16:30:59.362811777Z [1] undefined:7
2020-10-31T16:30:59.364317723Z [1]   "password: "myPassword"
2020-10-31T16:30:59.387236901Z [1]                 ^
2020-10-31T16:30:59.388680849Z [1]
2020-10-31T16:30:59.388894841Z [1] SyntaxError: Unexpected token P in JSON at position

I get the same error if I’m using the token and it points to a random letter.

Any help would be greatly apricated.
Many Thanks

Also noticed if I create a card I can’t fill in the action field. Its just blank.

Thanks

In the docs I see “token” is preferred over of “password”. Maybe “password” doesn’t work anymore with latest HA. MagicCards docs is from feb 2019, so a lot has changed on HA side. You can create a Long-Lived Access Token on the profile page. I have configured it using a token.

I’m not sure I understand what I need to do for Home Assistant side of things? I know I will have to create an automation but do I need to create an entity or install a plugin or even add to the config.yaml?

On the HA side you only need to capture the event magic_card_scanned.
See Dev Tools > Events
image

Hi!
I was wondering if someone had any tips on a rfid reader that works with this? This would be really cool to have at home. The reader proposed on the github page doesn’t exist anymore

/M

Nooow I noticed the links. Sorry about that. I found a reader there

I have a reader that worked. Generic one from aliexpress.
But can’t seen to get the whole thing working anymore. Don’t think the issue is the reader, but rather magiccards in combination with (newer) HA. Still need to look into it.
I would suggest to look into building your own with esphome though. The magic cards project is not maintained anymore. There is no integration with the native ‘cards’ on HA.

@DavidDeSloovere
Hi David,
Have you been able to reprogram your RFID reader as mentioned by Jon Maddox?

I tried to download the RFID-software using the link on GitHub, but that link (Dropbox - File Deleted) doesn’t work anymore.

I’ve bought 5 of these Amazon.ca and never had to program any of them

Never had to program the USB reader.
When I connected it to my Windows machine and did some tests, instead of numbers is got soemthing line "ç!èçtéèà.
That’s because I’m on azerty and caps lock was not on. That’s all.

I’m working on a lightweight alternative to magic cards. Would just call the ‘tags’ api. No front-end like magic cards. If there is a developer here who want to help, let me know.

I think I saw a post using tags api to do this.

edit

I have figured out most of what needs to be done.
My setup is an USB RFID card reader, hooked up to a PI zero W, that is obviously not the machine where HA runs on (Intel NUC, not that it matters).
I have created a docker image with some code.
I can already get the code from a scanned card.
Now just have to push that code to HA. Clean up the code, publish and create official container.
I’m planning on using MQTT for communication with HA because that’s supposed to support discovery so the tags gets displayed in the UI also. Could also just send the ‘tag scanned’ event over websockets, but no discovery for that one afaik.

To anyone reading this,

  • 1/ what is your USB card reader connected to (or planned on being connected to)? I’m building the docker image for multi-arc, so it might work on other PI models.
  • 2/ are you ok with this being shipped as docker image? Command to run the image will be in the readme.
  • 3/ are you ok with MQTT being used to communicate to HA? Over 1/3 has the MQTT integration.

If you can come up with a name for this new application, let me know!

r20d-usb ksz v1 plugged into raspberry pi 400
both 2-3, not sure, but i can handle with it… will need little more time, i’m newbie.

How do I create and edit a config.json file?
I have no clue!

Having problem creating an automation which reads the data from the scanned card and pass it on to media_player.spotify to play the relevant song.

When I scan a card I get the following data in the “magic_card_scanned” event -

Event 0 fired 1:39 PM:
{
    "event_type": "magic_card_scanned",
    "data": {
        "card_code": "0000314284",
        "card_type": "album",
        "card_arturl": "https://i.scdn.co/image/ab67616d0000b2734e2aa94e199e50bc8e10646f",
        "card_title": "Dil Se (Original Motion Picture Soundtrack)",
        "card_subtitle": "A.R. Rahman",
        "card_uri": "spotify:album:54NUwj7U1MOhA1ZGbnhiMz",
        "magic_cards_room": "Office"
    },
    "origin": "REMOTE",
    "time_fired": "2022-05-02T08:09:12.793694+00:00",
    "context": {
        "id": "43fc5c85a55945c08e686ae244ce4c6a",
        "parent_id": null,
        "user_id": "dd676a1912a24e2dab3d42cedda30267"
    }
}

Now, what should be my automation to play a song based on the data captured from the event?
my media player is: media_player.spotify_poras_chaudhary

Thanks!

Okay, googled my way around it…
Here’s how it’s done in Terminal (MacOS)!

vi config.json

Then just paste whatever goes into the config and press

ESC DD

Escape key + Shift D Shift D
to save and exit the vim editor…

Follow the same steps for making an actions.json

Hey, I have finally found a software that just look like it. I’ve hosted it here: RFID software.zip - Google Drive

Anybody know how to have this integration work with tags in HA.
This is an awesome project with a very nice frontend for managing cards.
It would be great if we can get it to work with HA.