NFC Kodi Media player

This is a media player for my Kids. It plays movies on Kodi with an nfc scanner. I know there are a lot of projects like this but searching the forum I did not see any examples of this particular setup. I’m sure there are other ways that might be better then what I have done, but I wanted to share anyways.

I have the Kodi app on my Shield tv. I wanted a tag to trigger a movie on the kodi. So I have the automation turn on the shield, launch the Kodi app, and then play the movie.

I had trouble with the timing on waiting for the kodi to turn on before trying to play a movie. I am a novice at home automation. I like to tinker, so I have experience copying and pasting bits of code here and there but I do not have a large understanding of it. I used the if/then action and it works pretty well now. I’m proud of this small accomplishment.
I used the Kodi integration, and the android tv integration.

This is the example for a movie.

alias: Fantasia
description: plays movie
trigger:
  - platform: tag
    tag_id: 04-26-A2-6A-0C-3A-81
condition: []
action:
  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.android_tv_192_168_0_108
  - service: media_player.select_source
    data:
      source: " org.xbmc.kodi"
    target:
      entity_id: media_player.android_tv_192_168_0_108
  - if:
      - condition: state
        entity_id: media_player.android_4
        state: "off"
    then:
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.android_4
            from: "off"
            to: idle
      - service: media_player.play_media
        target:
          entity_id: media_player.android_4
        data:
          media_content_id: "998"
          media_content_type: movie
        metadata:
          title: Fantasia
          thumbnail: >-
            
          media_class: movie
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: movie
              media_content_id: ""
    else:
      - service: media_player.play_media
        target:
          entity_id: media_player.android_4
        data:
          media_content_id: "998"
          media_content_type: movie
        metadata:
          title: Fantasia
          thumbnail: >-
            
          media_class: movie
          children_media_class: null
          navigateIds:
            - {}
            - media_content_type: movie
              media_content_id: ""
mode: single

This is an example of playing a random episode from a playlist on the kodi.

alias: Peppa Pig
description: |
  plays a peppa pig episode
trigger:
  - platform: tag
    tag_id: 1C-E4-72-0F
condition: []
action:
  - service: media_player.turn_on
    data: {}
    target:
      entity_id: media_player.android_tv_192_168_0_108
  - service: media_player.select_source
    target:
      entity_id: media_player.android_tv_192_168_0_108
    data:
      source: org.xbmc.kodi
  - if:
      - condition: state
        entity_id: media_player.android_4
        state: "off"
    then:
      - wait_for_trigger:
          - platform: state
            entity_id:
              - media_player.android_4
            from: "off"
            to: idle
      - service: kodi.call_method
        data:
          method: Playlist.Clear
          playlistid: 0
          entity_id: media_player.android_4
      - service: kodi.call_method
        data:
          method: Playlist.Add
          playlistid: 0
          item:
            recursive: true
            directory: special://profile/playlists/video/pig.xsp
        entity_id: media_player.android_4
      - service: kodi.call_method
        data:
          method: Player.Open
          item:
            playlistid: 0
            position: 0
        entity_id: media_player.android_4
    else:
      - service: kodi.call_method
        data:
          method: Playlist.Clear
          playlistid: 0
          entity_id: media_player.android_4
      - service: kodi.call_method
        data:
          method: Playlist.Add
          playlistid: 0
          item:
            recursive: true
            directory: special://profile/playlists/video/pig.xsp
        entity_id: media_player.android_4
      - service: kodi.call_method
        data:
          method: Player.Open
          item:
            playlistid: 0
            position: 0
        entity_id: media_player.android_4
mode: single

This works well for me. Disney infinity figures are great for this use. My 3 year old loves it.

1 Like

Hey, I have a PN532 NFC reader and am currently running CoreElect (based on Kodi) on a AM6B+. Could you pleeeeaaasse also help me set this up? This should be easier since the entire media player is just Kodi, no shield/android operating system or whatsoever. I’ve been dying trying to make this work. I also have about 150 tags. Thanks! You can DM me too if you want.

did you figure this out? You probably just need to select your media player then if its integrated into home assistant