Przycisk do odczytania ostatniego odcinka podcastu i włączenia następnego

Cześć,

mam napisany odtwarzacz ze stacjami radiowymi oraz z odcinkami podcastu. Do niego mam belkę z wyborem numeru odcinka. Podpowiedzcie proszę jak zrobić przycisk “Następny odcinek”. Rozumiem, że trzeba by odczytać ustawiony stan z numerem odcinka z nagłówka, “dodać jeden” i uruchomić skrypt włączający?
Karta z “radio”:

views:
  - title: Home
    cards:
      - type: vertical-stack
        cards:
          - type: entities
            entities:
              - entity: input_text.powiedz_to
              - entity: input_number.mediaplayer_glosnosc
              - entity: input_select.mediaplayer_glosnik
            state_color: false
            footer:
              type: buttons
              entities:
                - entity: script.radio_wznow
                  name: Wznów
                  icon: mdi:play-box
                - entity: script.radio_pauza
                  name: Pauza
                  icon: mdi:pause-box
                - entity: script.radio_stop
                  name: Stop
                - entity: script.volume_down
                  name: Ciszej
                  icon: mdi:volume-minus
                - entity: script.volume_up
                  name: Głośniej
                  icon: mdi:volume-plus
          - type: horizontal-stack
            cards:
              - show_state: false
                show_name: true
                camera_view: auto
                name: ESKA
                type: picture-entity
                entity: script.eska_play
                image: >-
                  https://myradioonline.pl/public/uploads/radio_img/radio-eska/play_250_250.jpg
                tap_action:
                  action: toggle
              - show_state: false
                show_name: true
                camera_view: auto
                name: RMF MAXXX
                type: picture-entity
                entity: script.nowy_skrypt_2
                image: >-
                  https://myradioonline.pl/public/uploads/radio_img/rmf-maxxx/play_250_250.jpg
                tap_action:
                  action: toggle
              - show_state: false
                show_name: true
                camera_view: auto
                name: RMF
                type: picture-entity
                entity: script.rmf_fm_play
                image: https://www.rmf.fm/inc/img/rmf-fm-logo.jpg?3
                tap_action:
                  action: toggle
          - type: horizontal-stack
            cards:
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.antyradio_play
                image: https://hejsmart.pl/ha/antyradio.png
                name: Antyradio
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.radio_zet_play
                image: https://hejsmart.pl/ha/radiozet.png
                name: Radio Zet
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.zlote_przeboje_play
                image: https://hejsmart.pl/ha/zloteprzeboje.png
                name: Złote Przeboje
          - type: horizontal-stack
            cards:
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.radio_pogoda_play
                image: >-
                  https://myradioonline.pl/public/uploads/radio_img/radio-pogoda/play_250_250.png
                name: Złote Przeboje
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.radio_katowice_play
                image: >-
                  http://www.radio.katowice.pl/assets/files/img/Polskie-Radio-Katowice-Logo.png
                name: Radio Katowice
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.vox_fm_play
                image: >-
                  https://cdn.music.smcloud.net/t/cover/d7a6833c-766d-48dc-b642-bd0dd11ea5ba_VOX_WRH_500x500_500x500.jpg
                name: VOX Fm
          - type: horizontal-stack
            cards:
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.radio_dzieciom
                image: >-
                  https://static.wirtualnemedia.pl/media/top/PolskieRadioDzieciom-logo655.png
                name: Radio dzieciom
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.dzem_radio
                image: https://us0-cdn.onlineradiobox.com/img/l/1/45771.v7.png
                name: Tylko Polskie Przeboje
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.hip_hop_klasyk
                image: >-
                  https://d3kle7qwymxpcy.cloudfront.net/images/broadcasts/90/92/26800/1/c175.png
                name: Hip Hop Klasyk
          - type: horizontal-stack
            cards:
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.podcast_kulfon
                image: >-
                  https://i.scdn.co/image/97b77ff0571c29aa49559d77ae1f0bccb13fd661
                name: Kulfon i Monika
              - show_state: false
                show_name: true
                type: picture
                image: >-
                  https://www.download.net.pl/uploaded/News_2019_1/youtube-music/youtube-music.jpg
                tap_action:
                  action: navigate
                  navigation_path: /test-panel
              - show_state: false
                show_name: true
                camera_view: auto
                type: picture-entity
                tap_action:
                  action: toggle
                entity: script.kolysanki
                image: https://static.mytuner.mobi/media/tvos_radios/bwyff28wugak.png
          - type: vertical-stack
            cards:
              - type: entities
                entities:
                  - entity: input_select.kulfonpodcast_odcinek
          - type: vertical-stack
            cards:
              - type: media-control
                entity: media_player.salon_2
              - type: media-control
                entity: media_player.kuchnia
              - type: media-control
                entity: media_player.lazienka
              - type: media-control
                entity: media_player.pokoj_dzieci
              - type: media-control
                entity: media_player.ytube_music_player

Inputselect do wyboru numeru odcinka:

kulfonpodcast_odcinek:
  name: Odcinek
  icon: mdi:human-capacity-increase
  options:
    - "1"
    - "2"
    - "3"
    - "4"
    - "5"
    - "6"
    - "7"
    - "8"
    - "9"
    - "10"
    - "11"
    - "12"
    - "13"
    - "14"
    - "15"
    - "16"
    - "17"
    - "18"
    - "19"
    - "20"
    - "21"
    - "22"
    - "23"
    - "24"
    - "25"
    - "26"
    - "27"
    - "28"
    - "29"
    - "30"
    - "31"
  initial: "1"

Skrypt z adresami podcastów:

podcast_kulfon:
  alias: Podcast Kulfon
  sequence:
    - service: media_player.volume_set
      data:
        entity_id:
          '{% if is_state("input_select.mediaplayer_glosnik", "Salon") %} media_player.salon_2
          {% elif is_state("input_select.mediaplayer_glosnik", "Kuchnia") %} media_player.kuchnia
          {% elif is_state("input_select.mediaplayer_glosnik", "Łazienka") %} media_player.lazienka
          {% elif is_state("input_select.mediaplayer_glosnik", "pokoj dzieci") %} media_player.pokoj_dzieci  {%
          elif is_state("input_select.mediaplayer_glosnik", "Wszędzie") %} media_player.wszystkie_glosniki
          {% endif %}

          '
        volume_level: '{{ states("input_number.mediaplayer_glosnosc") }}'
    - service: media_player.play_media
      data:
        entity_id:
          '{% if is_state("input_select.mediaplayer_glosnik", "Salon") %} media_player.salon_2
          {% elif is_state("input_select.mediaplayer_glosnik", "Kuchnia") %} media_player.kuchnia
          {% elif is_state("input_select.mediaplayer_glosnik", "Łazienka") %} media_player.lazienka
          {% elif is_state("input_select.mediaplayer_glosnik", "pokoj dzieci") %} media_player.pokoj_dzieci  {%
          elif is_state("input_select.mediaplayer_glosnik", "Wszędzie") %} media_player.wszystkie_glosniki
          {% endif %}

          '
        media_content_id:
          "{% if is_state(\"input_select.kulfonpodcast_odcinek\", \"1\")
          %} https://static.prsa.pl/45042d72-fa3e-4db9-ad69-474d14ce9a4d.mp3 {% elif
          is_state(\"input_select.kulfonpodcast_odcinek\", \"2\") %} https://static.prsa.pl/1d3f8a73-1c66-49ab-951e-45e4076f4b9e.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"3\") %} https://static.prsa.pl/ff4c89d3-9192-4e1b-84d8-a99da86dc734.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"4\") %} https://static.prsa.pl/bcdc15bf-2abd-4c9f-a131-4fc0bae853fd.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"5\") %} https://static.prsa.pl/28d5033b-237b-4825-9dfb-1220dcc4eafa.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"6\") %} https://static.prsa.pl/f27a1a83-bced-42fd-a1a3-0c56dcdfe142.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"7\") %} https://static.prsa.pl/1ac050d7-a587-4c27-8751-230c65669869.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"8\") %} https://static.prsa.pl/c1a4826f-a6ab-4e4c-956c-8076c19eab53.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"9\") %} https://static.prsa.pl/d9fcd3b2-07ee-448b-b9eb-a429f8a95a00.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"10\") %} https://static.prsa.pl/8980a8ff-16b7-4b98-9285-94b1ab2abbe4.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"11\") %} https://static.prsa.pl/45042d72-fa3e-4db9-ad69-474d14ce9a4d.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"12\") %} https://static.prsa.pl/45042d72-fa3e-4db9-ad69-474d14ce9a4d.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"13\") %} https://static.prsa.pl/45042d72-fa3e-4db9-ad69-474d14ce9a4d.mp3
          {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"14\") %} https://static.prsa.pl/45042d72-fa3e-4db9-ad69-474d14ce9a4d.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"15\") %} https://static.prsa.pl/45042d72-fa3e-4db9-ad69-474d14ce9a4d.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"16\") %} https://static.prsa.pl/649159a3-9d59-4a31-8d0d-857ab70610e7.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"17\") %} https://static.prsa.pl/dcffa0e6-3b95-46fe-ad60-e98f51345bd8.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"18\") %} https://static.prsa.pl/3f1b427c-c77e-4395-8d08-9ce52e561956.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"19\") %} https://static.prsa.pl/d5b55fb1-c5a1-4a05-bb42-849bc98fcbb9.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"20\") %} https://static.prsa.pl/a96a3547-8d21-42a2-ac27-86f73857ee72.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"21\") %} https://static.prsa.pl/af193832-befa-4b3d-9e0c-3330a413e15c.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"22\") %} https://static.prsa.pl/3955aa9d-5261-4e62-80b4-ad244bc1e259.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"23\") %} https://static.prsa.pl/322ec298-b25b-4468-8d53-a0ec37fc1ece.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"24\") %} https://static.prsa.pl/30d42a7b-f6fd-42a4-b6d6-9c82b3f63ef0.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"25\") %} https://static.prsa.pl/341032c9-e5c9-4057-a7bb-f5b56726b5bc.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"26\") %} https://static.prsa.pl/a4ebb949-8e16-4eb1-bf25-d2dbbd4a6fb3.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"27\") %} https://static.prsa.pl/cc46fa01-efbf-4e5b-8c78-6d6c2ae2f33b.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"28\") %} https://static.prsa.pl/96559e72-b2bf-43f1-9ae9-5ef4aeedf6d9.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"29\") %} https://static.prsa.pl/d640d14d-4167-4f12-bb0a-cb8be3ea7393.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"30\") %} https://static.prsa.pl/80fdfe5b-cd40-48a3-90cd-ffe20d8cab72.mp3
          \ {% elif is_state(\"input_select.kulfonpodcast_odcinek\", \"31\") %} https://static.prsa.pl/5c7877bc-455f-4d60-a914-1b9bcdbe11c3.mp3
          \ {% endif %} \n"
        media_content_type: music
        extra:
          thumb: https://i.scdn.co/image/97b77ff0571c29aa49559d77ae1f0bccb13fd661
  mode: single

:thinking:

Skrypt który doda (“+1”- następny), teoretycznie powinien działać

alias: Następny odcinek podcastu
sequence:
  - service: input_select.select_next
    data:
      entity_id: input_select.kulfonpodcast_odcinek
  - service: script.podcast_kulfon
mode: single

Jeśli nie zadziała to może skrypt z szablon template który to doda do odczytanej wartości “+1”.

Przykład:

alias: Następny odcinek podcastu
sequence:
  - service: input_select.select_option
    data:
      entity_id: input_select.kulfonpodcast_odcinek
      option: >
        {% set teraz_jest = states('input_select.kulfonpodcast_odcinek') | int %}
        {% set nastepny = teraz_jest + 1 %}
        {% if nastepny > 31 %} 1 {% else %} {{ nastepny }} {% endif %} 

Następnie przycisk przypisać do tego skryptu np. entity-button

type: entity-button
entity: script.nastepny_odcinek_podcastu
name: Następny odcinek podcastu
icon: mdi:arrow-right

Pierwszy Twój sposób zadziałał od razu :slight_smile: Niepotrzebnie kombinowałem z ponownym wyborem głośników w skrypcie i z media.next.track.
Dziękuję za pomoc - teraz będę mógł to dodać do przycisków akcji dla młodego :slight_smile: