I did it. I defeated the horrible Google Home "cast-start" prompt sound!

Is it just me or not. My time pattern trigger every 2 minutes does not always fire every 2 minutes:

image

2 Likes

are you playing something else on your GH? If so it’ll stop the automation from running if you’ve set conditions (which you should have)

No. Nothing else is running. It looks like it misses 2 minute pattern

Hi @majkers, reading you in Error reading from socket / communicating with socket for cast speakers · Issue #47923 · home-assistant/core · GitHub I think you aready found this:

It’s not triggering because the google home goes “unavailable” due to that bug.

I’ve updated the automation so it also triggers when chromecast becomes available.

alias: Keep Google Home Alive
description: ''
trigger:
  - platform: time_pattern
    minutes: /2
  - platform: state
    entity_id: media_player.home
    from: unavailable
    to: idle
  - platform: state
    entity_id: media_player.home
    from: unavailable
    to: 'off'
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: media_player.home
        state: 'off'
      - condition: state
        entity_id: media_player.home
        state: idle
action:
  - service: media_player.play_media
    entity_id: media_player.home
    data:
      media_content_id: 'media-source://media_source/local/silence.mp3'
      media_content_type: music
mode: single

Not sure if this will fix the problem, I’m going to try and see. Please let me know of the result if you also give it a try.

Edit: It works! Even with minutes: /4 :slight_smile:

2 Likes

Ok. I will check it tomorrow. Thanks

I did something similar in Node-Red using castv2. It sometimes chops the first few milliseconds of the audio file but it works flawlessly otherwise.

[
    {
        "id": "a83ecdca.0284d",
        "type": "tab",
        "label": "Chromecasts",
        "disabled": false,
        "info": ""
    },
    {
        "id": "72464afe.6563b4",
        "type": "group",
        "z": "a83ecdca.0284d",
        "name": "Living Space",
        "style": {
            "label": true
        },
        "nodes": [
            "3ea772dd.97674e",
            "dcd90f8b.ee59e",
            "dd3e647e.a391d8",
            "21c1abf0.d9eee4",
            "485e304c.7a19a",
            "5758539e.daa58c",
            "5d3e039b.68968c",
            "ba2bd794.c6d828",
            "1c1ed4cb.d1a82b",
            "913bf8bc.33a198",
            "bec880d7.27689",
            "51717c9e.2c5444",
            "1ac46e06.e468d2",
            "c8a79924.20f038",
            "7d7593ef.a1574c",
            "455d55b2.23812c",
            "565da0e8.05956"
        ],
        "x": 324,
        "y": 209,
        "w": 1837,
        "h": 282
    },
    {
        "id": "3ea772dd.97674e",
        "type": "function",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Mute",
        "func": "msg.payload = {\n    type: \"MUTE\",\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 500,
        "y": 275,
        "wires": [
            [
                "dcd90f8b.ee59e"
            ]
        ]
    },
    {
        "id": "dcd90f8b.ee59e",
        "type": "castv2-sender",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "",
        "connection": "9b0075f1.3a9588",
        "x": 705,
        "y": 300,
        "wires": [
            [
                "1ac46e06.e468d2"
            ]
        ]
    },
    {
        "id": "dd3e647e.a391d8",
        "type": "switch",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Playing",
        "property": "payload.playerState",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "PLAYING",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1085,
        "y": 300,
        "wires": [
            [
                "51717c9e.2c5444"
            ]
        ]
    },
    {
        "id": "21c1abf0.d9eee4",
        "type": "link in",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Send to - Living Space Chromecast",
        "links": [
            "d7bf184b.c8e788"
        ],
        "x": 365,
        "y": 300,
        "wires": [
            [
                "3ea772dd.97674e",
                "dcd90f8b.ee59e"
            ]
        ]
    },
    {
        "id": "485e304c.7a19a",
        "type": "function",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Seek Zero",
        "func": "msg.payload = {\n    type: \"SEEK\",\n    time: 0 // Time to seek to in seconds\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1670,
        "y": 400,
        "wires": [
            [
                "ba2bd794.c6d828"
            ]
        ]
    },
    {
        "id": "5758539e.daa58c",
        "type": "function",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Pause",
        "func": "msg.payload = {\n    type: \"PAUSE\"\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1650,
        "y": 300,
        "wires": [
            [
                "ba2bd794.c6d828"
            ]
        ]
    },
    {
        "id": "5d3e039b.68968c",
        "type": "function",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Play",
        "func": "msg.payload = {\n    type: \"PLAY\"\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1850,
        "y": 450,
        "wires": [
            [
                "ba2bd794.c6d828"
            ]
        ]
    },
    {
        "id": "ba2bd794.c6d828",
        "type": "castv2-sender",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "",
        "connection": "9b0075f1.3a9588",
        "x": 2055,
        "y": 350,
        "wires": [
            []
        ]
    },
    {
        "id": "1c1ed4cb.d1a82b",
        "type": "debug",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1095,
        "y": 250,
        "wires": []
    },
    {
        "id": "913bf8bc.33a198",
        "type": "switch",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Paused",
        "property": "payload.playerState",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "PAUSED",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1085,
        "y": 350,
        "wires": [
            [
                "c8a79924.20f038"
            ]
        ]
    },
    {
        "id": "bec880d7.27689",
        "type": "switch",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Finished",
        "property": "payload.idleReason",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "FINISHED",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1085,
        "y": 400,
        "wires": [
            [
                "7d7593ef.a1574c"
            ]
        ]
    },
    {
        "id": "51717c9e.2c5444",
        "type": "trigger",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Limit events",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "payl",
        "duration": "0",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1445,
        "y": 300,
        "wires": [
            [
                "5758539e.daa58c"
            ]
        ]
    },
    {
        "id": "1ac46e06.e468d2",
        "type": "switch",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Has Value",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "nnull"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 895,
        "y": 300,
        "wires": [
            [
                "dd3e647e.a391d8",
                "bec880d7.27689",
                "913bf8bc.33a198",
                "1c1ed4cb.d1a82b"
            ]
        ]
    },
    {
        "id": "c8a79924.20f038",
        "type": "trigger",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Limit events",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "payl",
        "duration": "0",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1445,
        "y": 350,
        "wires": [
            [
                "455d55b2.23812c",
                "565da0e8.05956",
                "485e304c.7a19a"
            ]
        ]
    },
    {
        "id": "7d7593ef.a1574c",
        "type": "function",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Reset",
        "func": "\nmsg.reset = true;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1225,
        "y": 400,
        "wires": [
            [
                "c8a79924.20f038",
                "51717c9e.2c5444"
            ]
        ]
    },
    {
        "id": "455d55b2.23812c",
        "type": "function",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "Unmute",
        "func": "msg.payload = {\n    type: \"UNMUTE\"\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 1660,
        "y": 350,
        "wires": [
            [
                "ba2bd794.c6d828"
            ]
        ]
    },
    {
        "id": "565da0e8.05956",
        "type": "delay",
        "z": "a83ecdca.0284d",
        "g": "72464afe.6563b4",
        "name": "",
        "pauseType": "delay",
        "timeout": "100",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 1670,
        "y": 450,
        "wires": [
            [
                "5d3e039b.68968c"
            ]
        ]
    },
    {
        "id": "9b0075f1.3a9588",
        "type": "castv2-connection",
        "name": "",
        "target": "Living Space speaker",
        "host": "",
        "port": "8009"
    }
]

Input Payload:

msg.payload = {
    type: "MEDIA",
    media: {
        url: "https://storage.googleapis.com/gilfoyle/the-skypark/v1/common/sounds/effects/kaching.mp3",
        contentType: "audio/mp3",
        streamType: "LIVE",
    }
}

Hi Carlos, I have several google minis around the house. I was wondering if there’s a smart way (maybe with templates) to reproduce this automation to all minis (maybe creating a group?) instead of add as many triggers and conditions for every mini.

What’s your thought?

1 Like

Sorry, I have yet to learn how to parameterise an automation like that ;(

@everyone :eyes:

I don’t know if it is even possible. Templating is SO POWERFUL but so complicated. You need to be a jedi master to use it eheheh

I made this automation to keep alive many google minis. I tested in debug trace console and the error is

Error: Template rendered invalid entity IDs

It’s “strange” because I take this layout from this page (last example)

alias: Mantieni tutti i Google Home Mini attivi
description: ''
trigger:
  - platform: state
    entity_id:
      - media_player.corridoio
      - media_player.cucina
      - media_player.disimpegno
      - media_player.bagno_principale
      - media_player.bagno_secondario
      - media_player.google_home_mini
    to: 'off'
    for: '00:00:10'
    from: 'on'
  - platform: state
    entity_id:
      - media_player.corridoio
      - media_player.cucina
      - media_player.disimpegno
      - media_player.bagno_principale
      - media_player.bagno_secondario
      - media_player.google_home_mini
    from: unavailable
    to: idle
  - platform: state
    entity_id:
      - media_player.corridoio
      - media_player.cucina
      - media_player.disimpegno
      - media_player.bagno_principale
      - media_player.bagno_secondario
      - media_player.google_home_mini
    from: unavailable
    to: 'off'
action:
  - service: media_player.volume_set
    target:
      entity_id: '{{ trigger.to_state.entity_id}}'
    data:
      volume_level: 0
  - service: media_player.turn_on
    target:
      entity_id: '{{ trigger.to_state.entity_id}}'
  - service: media_player.play_media
    target:
      entity_id: '{{ trigger.to_state.entity_id}}'
    data:
      media_content_id: 'http://192.168.2.101:8123/local/1sec.mp3'
      media_content_type: music
  - delay:
      hours: 0
      minutes: 0
      seconds: 10
      milliseconds: 0
  - service: media_player.volume_set
    target:
      entity_id: '{{ trigger.to_state.entity_id}}'
    data:
      volume_level: '{{states(''sensor.period_of_day_volume'')|float}}'
mode: queued
max: 10

I also tried changing to

entity_id: '{{ trigger.to_state.entity_id}}'

No results.

any hint?

replace trigger.to_state.entity_id with trigger.entity_id
That should work better

By the way you could simplify your automation by removing one block:

  - platform: state
    entity_id:
      - media_player.corridoio
      - media_player.cucina
      - media_player.disimpegno
      - media_player.bagno_principale
      - media_player.bagno_secondario
      - media_player.google_home_mini
    from: unavailable
    to: idle
  - platform: state
    entity_id:
      - media_player.corridoio
      - media_player.cucina
      - media_player.disimpegno
      - media_player.bagno_principale
      - media_player.bagno_secondario
      - media_player.google_home_mini
    from: unavailable
    to: 'off'

becomes

  - platform: state
    entity_id:
      - media_player.corridoio
      - media_player.cucina
      - media_player.disimpegno
      - media_player.bagno_principale
      - media_player.bagno_secondario
      - media_player.google_home_mini
    from: unavailable
- id: mantieni_google_home_mini_attivi_hub

    alias: Mantieni tutti i Google Home Mini attivi

    description: ''

    trigger:

      - platform: state

        entity_id: >-

          media_player.corridoio,media_player.cucina,media_player.disimpegno,media_player.bagno_principale,media_player.bagno_secondario,media_player.google_home_mini

        to: 'off'

        for: '00:00:10'

      - platform: state

        entity_id: >-

          media_player.corridoio,media_player.cucina,media_player.disimpegno,media_player.bagno_principale,media_player.bagno_secondario,media_player.google_home_mini

        from: unavailable

      - platform: state

        entity_id: >-

          media_player.corridoio,media_player.cucina,media_player.disimpegno,media_player.bagno_principale,media_player.bagno_secondario,media_player.google_home_mini

        to: 'off'

        for: '00:00:10'

        from: idle

      - platform: state

        entity_id: >-

          media_player.corridoio,media_player.cucina,media_player.disimpegno,media_player.bagno_principale,media_player.bagno_secondario,media_player.google_home_mini

        to: idle

        for: '00:00:10'

        from: 'on'

    action:

      - service: media_player.volume_set

        data:

          volume_level: 0

          entity_id: '{{ trigger.entity_id }}'

      - service: media_player.turn_on

        data:

          entity_id: '{{ trigger.entity_id }}'

      - service: media_player.play_media

        data:

          media_content_id: 'http://192.168.2.101:8123/local/1sec.mp3'

          media_content_type: music

          entity_id: '{{ trigger.entity_id }}'

      - delay:

          hours: 0

          minutes: 0

          seconds: 2

          milliseconds: 0

      - service: media_player.volume_set

        data:

          volume_level: "{{states('sensor.period_of_day_volume')|float}}"

          entity_id: '{{ trigger.entity_id }}'

    mode: queued

    max: 10

trigger.entity_id do the trick.

Than you

1 Like

So question for @lolouk44 , @CarlosGS and @Emphyrio ; does this also work for Google/Nest devices with a screen? E.g. my Nest Hub with picture frame is beneath my TV. i would not want it to switch to a different view all of the time.

Well yes and no. Yes it will work and not play the connection sound, but no because it’ll stop displaying the photo and display the media player screen instead.what you probably want to do instead is have a script that will bring the vol to 0, connect with a 1 sec, then set the vol to whichever number you then play your announcement.
This will mean a delay, and the announcement will anyway stop the photo display

Oh magic ! Exactly what i am searching ! Thanks ! Work flawlessly. Only slow to start playing but worth it for not hearing the cast start sound :smiley:

1 Like

I tried this automation but the minis keep bleeping every 2 seconds. I do not have the sensor.period_of_day_volume and filled in 0.55 as volume. how did you define this sensor? In a script? And you don’t have the constant volume change bleepings?

Is it just me or is is something with 2021.12.2 version that google home mini stays in ‘playing’ state after playing 1 second sound for more or less 5 minutes so my automation to defeat this prompt sound is not working?

I created Google home mini stays in 'playing' state after playing 1 second sound for more or less 5 minutes · Issue #62007 · home-assistant/core · GitHub

For me have the same problem after update. “playing” always.

same here, which means the google mini turns off after 5 min and triggers the cast start sound :frowning:

Exactly. Unfortunately nothing is happening with my issue :frowning: