Skip to content

Instantly share code, notes, and snippets.

@mistic100
Last active October 19, 2025 14:56
Show Gist options
  • Select an option

  • Save mistic100/c10abbc7768d77d115242aa1d190e83b to your computer and use it in GitHub Desktop.

Select an option

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 NowPlaying"
scan_interval: 30
command: >-
curl http://<SERVER_ADDRESS>/jellyfin/Sessions\?ApiKey\=<API_KEY> | jq '
(.[] | select(.UserName == "<USERNAME>") | select(.NowPlayingItem) | select(.PlayState.IsPaused == false)) // {}
| {
type: .NowPlayingItem?.Type,
name: (
if .NowPlayingItem?.SeriesName then [.NowPlayingItem.SeriesName, .NowPlayingItem.SeasonName, .NowPlayingItem.Name] | join(" - ")
elif .NowPlayingItem?.AlbumArtist then [.NowPlayingItem.AlbumArtist, .NowPlayingItem.Album] | join(" - ")
else .NowPlayingItem?.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