# Home Assistant side of the Jellyfin "Lights Off Timer" plugin. # Put this in a package (e.g. /config/packages/jellyfin_lights.yaml, with # `homeassistant: packages: !include_dir_named packages` in configuration.yaml), # replace the webhook id, reload Timers and Automations, then set the plugin's # "Home Assistant webhook URL" to https:///api/webhook/. # # The plugin POSTs JSON: # {"event": "started"} playback (re)started -> cancel the countdown # {"event": "stopped", "cooldown_minutes": 15} playback stopped with the sleep timer on -> start it timer: movie_lights_off: name: Lights off after movie icon: mdi:movie-open-off restore: true automation: - id: jellyfin_lights_webhook alias: Jellyfin - playback started/stopped mode: queued triggers: - trigger: webhook # Anyone who knows this id can trigger it: use a long random string, keep it secret. webhook_id: CHANGE-ME-to-a-long-random-string allowed_methods: [POST] local_only: false # true if Jellyfin is on the same LAN as Home Assistant actions: - choose: - conditions: "{{ trigger.json.event == 'started' }}" sequence: - action: timer.cancel target: entity_id: timer.movie_lights_off - conditions: "{{ trigger.json.event == 'stopped' }}" sequence: - variables: minutes: "{{ (trigger.json.cooldown_minutes | default(15)) | int(15) }}" - action: timer.start target: entity_id: timer.movie_lights_off data: duration: "{{ '%02d:%02d:00' % (minutes // 60, minutes % 60) }}" - id: jellyfin_lights_off alias: Jellyfin - lights off after the movie triggers: - trigger: event event_type: timer.finished event_data: entity_id: timer.movie_lights_off actions: - action: light.turn_off target: entity_id: all # or list the lights you want data: transition: 30