Skip forward/rewind x seconds on media_player (Chromecast)?

Hi!

I want to have an automation action that rewinds my Chromecast 30 seconds with an MQTT trigger.

What is the best way of achieving this in HA?

Hi jakobve! I have also thought about this, did you solve it? :slight_smile:

Old topic but I don’t think this has been answered previously. So here’s script that can seek Chromecast with relative amounts

alias: Chromecast Seek
fields:
  seek_amount:
    name: Seek Amount
    description: In seconds. Can be negative.
    selector:
      text:
sequence:
  - service: media_player.media_play_pause
    data: {}
    target:
      entity_id: media_player.esan_chromescast_ultra
  - delay:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 500
  - service: media_player.media_seek
    data:
      seek_position: >-
        {{ state_attr("media_player.esan_chromescast_ultra",
        "media_position")|int + (seek_amount|default(-30)|int(-30)) }}
    target:
      entity_id: media_player.esan_chromescast_ultra

mode: single
icon: mdi:fast-forward

The media_player.media_play_pause at the start might seem weird but it was required to get up to date current position from the chromecast attribute.

1 Like

This script unfortunately do not work for me. It only pauses playback. It does not seek. Also tried removing the pause part but still no go. I am using it in a blueprint for the IKEA symfonisk gen 2 remote.

These are the relevant parts. Does anyone spot anything wrong here? (For info, I check if the chromecast is on and if it is I seek. If it is off I instead skip to the next or previous track on my bluesound player. This way the remote works with both depending on whether the chromecast is on or not.

next_press:
      - choose:
          - conditions:
              - condition: device
                device_id: d8ab84d64ad9cdf90dc94061270e7599
                domain: media_player
                entity_id: 1564d97505af4f049532b2efae35e8a9
                type: is_on
            sequence:
              - service: script.chromecast_seek_in_living_room
                data:
                  seek_amount: "5"
          - conditions:
              - condition: device
                device_id: d8ab84d64ad9cdf90dc94061270e7599
                domain: media_player
                entity_id: 1564d97505af4f049532b2efae35e8a9
                type: is_off
            sequence:
              - service: media_player.media_next_track
                metadata: {}
                data: {}
                target:
                  entity_id: media_player.bluesound_livingroom
    prev_press:
      - choose:
          - conditions:
              - condition: device
                device_id: d8ab84d64ad9cdf90dc94061270e7599
                domain: media_player
                entity_id: 1564d97505af4f049532b2efae35e8a9
                type: is_on
            sequence:
              - service: script.chromecast_seek_in_living_room
                metadata: {}
                data:
                  seek_amount: "-5"
          - conditions:
              - condition: device
                device_id: d8ab84d64ad9cdf90dc94061270e7599
                domain: media_player
                entity_id: 1564d97505af4f049532b2efae35e8a9
                type: is_off
            sequence:
              - service: media_player.media_previous_track
                metadata: {}
                data: {}
                target:
                  entity_id: media_player.bluesound_livingroom