Created
June 15, 2025 10:22
-
-
Save mistic100/c10abbc7768d77d115242aa1d190e83b to your computer and use it in GitHub Desktop.
[Home Assistant] Jellyfin "now playing" sensor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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