Skip to content

bushvin/hass-integrations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Home Assitant integrations

Additional integrations for Home Assistant

badge_mastodon

Mopidy

badge_version badge_issues badge_hacs_pipeline

This is a platform integration for Mopidy Music Servers

Installation

Please look at the Mopidy installation & configuration instructions to set up a Mopidy Server.

HACS

  1. Install HACS
  2. Go to any of the sections (integrations, frontend, automation).
  3. Click on the 3 dots in the top right corner.
  4. Select "Custom repositories"
  5. Add the URL to the repository.
  6. Select the correct category.
  7. Click the "ADD" button.
  8. Go to Home Assistant settings -> Integrations and add Mopidy
  9. Restart HA

Manual

  1. Clone this repository
  2. Copy custom_components/mopidy to your Home Assistant instance on <config dir>/custom_components/

Setup

zeroconf

Your Mopidy Servers can be detected and added to Home Assistant through zeroconf.

GUI

  1. Go to the Integrations page and click + ADD INTEGRATION
  2. Select Mopidy in the list of integrations
  3. Fill out the requested information. Make sure to enter your correct FQDN or IP address. Using localhost, 127.0.0.1, ::1 or any other loopback address will disable Mopidy-Local artwork.
  4. Click Submit.

Repeat the above steps to add more Mopidy Server instances.

Manual Configuration

  1. add a media player to your home assistant configuration (<config dir>/configuration.yaml):
media_player:
- name: <mopidy identifier>
  host: <FQDN or IP address>
  port: <port if different from 6680>
  platform: mopidy
  1. Restart your Home assistant to make changes take effect.

Configuration

- name: <mopidy name>      # The name of your Mopidy server.
  host: <fqdn/ip address>  # The FQDN or IP address of your Mopidy Server, do not use ::1, localhost or 127.0.0.1
  port: <port number>      # The port number of the Mopidy Server, default: 6680
  platform: mopidy         # specify mopidy platform

Services

Service mopidy.get_search_result

This service was originally developed by Daniele Ricci

Search media based on keywords and return them for use in a script or automation.

Note: One of the keyword fields must be used: keyword, keyword_album, keyword_artist, keyword_genre or keyword_track_name

Service data attribute Optional Description Example
entity_id no String or list of entity_ids to search and return the result to.
exact yes String. Should the search be an exact match false
keyword yes String. The keywords to search for. Will search all track fields. Everlong
keyword_album yes String. The keywords to search for in album titles. From Mars to Sirius
keyword_artist yes String. The keywords to search for in artists. Queens of the Stoneage
keyword_genre yes String. The keywords to search for in genres. rock
keyword_track_name yes String. The keywords to search for in track names. Lazarus
source yes String. URI sources to search. local, spotify and tunein are the only supported options. Make sure to have these extensions enabled on your Mopidy Server! Separate multiple sources with a comma (,). local,spotify
Example

The service is to be used as a normal service returning some data into a variable. The result is actually a dictionary with keys corresponding to the media player entities used as targets in the service call. Every item has in turn a result attribute containing the list of actual media IDs matching the search parameters.

script:
  search_and_play_music:
    fields:
      [...]
    sequence:
      - action: mopidy.get_search_result
        data:
          keyword_artist: "Some music artist"
          keyword_track_name: "Some song title"
          source: local
        target:
          entity_id: "media_player.music"
        response_variable: music_tracks # result will be returned into this variable
      - if: "{{ music_tracks['media_player.music'].result|length > 0 }}"
        then:
          - action: media_player.play_media
            data:
              media_content_id: "{{ music_tracks['media_player.music'].result[0] }}"
              media_content_type: music
            target:
              entity_id: "media_player.music"

Service media_player.play_media

The media_content_id needs to be formatted according to the Mopidy URI scheme. These can be easily found using the Developer tools.

When using the play_media service, the Mopidy Media Player platform will attempt to discover your URL when not properly formatted. Currently supported for:

  • Youtube

Service mopidy.restore

Restore a previously taken snapshot of one or more Mopidy Servers

The playing queue is snapshotted

Service data attribute Optional Description
entity_id no String or list of entity_ids that should have their snapshot restored.

Service mopidy.search

Search media based on keywords and add them to the queue. This service does not replace the queue, nor does it start playing the queue. This can be achieved through the use of media_player.clear_playlist and media_player.media_play

Note: One of the keyword fields must be used: keyword, keyword_album, keyword_artist, keyword_genre or keyword_track_name

Service data attribute Optional Description Example
entity_id no String or list of entity_ids to search and return the result to.
exact yes String. Should the search be an exact match false
keyword yes String. The keywords to search for. Will search all track fields. Everlong
keyword_album yes String. The keywords to search for in album titles. From Mars to Sirius
keyword_artist yes String. The keywords to search for in artists. Queens of the Stoneage
keyword_genre yes String. The keywords to search for in genres. rock
keyword_track_name yes String. The keywords to search for in track names. Lazarus
source yes String. URI sources to search. local, spotify and tunein are the only supported options. Make sure to have these extensions enabled on your Mopidy Server! Separate multiple sources with a comma (,). local,spotify

Service mopidy.set_consume_mode

Set the mopidy consume mode for the specified entity

Service data attribute Optional Description
entity_id no String or list of entity_ids to set the consume mode of.
consume_mode no True to enable consume mode, False to disable

Service mopidy.snapshot

Take a snapshot of what is currently playing on one or more Mopidy Servers. This service, and the following one, are useful if you want to play a doorbell or notification sound and resume playback afterwards.

Warning: This service is controlled by the platform, this is not a built-in function of Mopidy Server! Restarting Home Assistant will cause the snapshot to be lost.

Service data attribute Optional Description
entity_id no String or list of entity_ids ito take a snapshot of.

Notes

Due to the nature of the way Mopidy provides thumbnails of the media, proxying them through Home Assistant is very resource intensive, causing delays. Therefore, I have decided to not proxy the art when using the Media Library for the time being.

Testers