Skip to content

Instantly share code, notes, and snippets.

@mistic100
Created June 15, 2025 10:22
Show Gist options
  • Save mistic100/c10abbc7768d77d115242aa1d190e83b to your computer and use it in GitHub Desktop.
Save mistic100/c10abbc7768d77d115242aa1d190e83b to your computer and use it in GitHub Desktop.
[Home Assistant] Jellyfin "now playing" sensor
# Creates a binary sensor with the name and type of the currently playing item as attributes
# Replace <SERVER_ADDRESS>, <API_KEY> and <USERNAME>
- sensor:
name: "Jellyfin User 1"
scan_interval: 30
command: >-
curl http://<SERVER_ADDRESS>/jellyfin/Sessions\?ApiKey\=<API_KEY> | jq '
(.[] | select(.UserName == "<USERNAME>")) // {} | .NowPlayingItem // {}
| {
type: .Type,
name: (
if .SeriesName then [.SeriesName, .SeasonName, .Name] | join(" - ")
elif .AlbumArtist then [.AlbumArtist, .Album] | join(" - ")
else .Name
end
)
}
| map_values(if . == "" then null else . end)'
json_attributes:
- type
- name
value_template: "{% if value_json.name is none %}off{% else %}on{% endif %}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment