Assign an Area to a Script

I want to assign an Area to a Script, but i can’t.

Why would I want to do that? Because for Google Assistant integration, scenes (in Google Assistant, scripts are published as scenes) need to be assigned to a room so that other household members can call them. For example, with voice match enabled, my wife can’t set the “entertaining” scene unless I set the scene’s room. Doesn’t even matter which room. No idea why this is, but whatever - it works.

Problem is I can’t assign a room to a script - it says “This entity does not have a unique ID” when I try. It doesn’t look like you can assign areas via yaml, unless i’m wrong. Not sure why Automations and Scenes have unique IDs but Scripts don’t.

Anyone?

I’m trying to avoid scripts in favor of scenes where possible for this reason, but some “scenes” need to call services (start roomba, play sleep sounds etc).

IIRC areas (rooms) cannot be accessed via automations or scripting in any meaningful way. I’ve read a few posts that talk about this. I could be wrong, of course.

I came across this HACS extension that opens some things up regarding room assignments and being able to automate based on room, but I haven’t used it so I can’t speak to if it will do what you want or not.

From what I’ve see, it’s one of the only extensions that does anything with rooms.

I’ve worked around this for now in a super hacky way: I create a blank scene, assign it to a room, publish that to Google Assistant, and then create an automation that triggers on the scene:

alias: Call services when the bedtime scene activates
trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.bedtime

This works great from Google Assistant but its cluttered and feels unnecessary. It would be really great if we could assign script to rooms directly, or at least through the Cloud Google Assistant UI

Did you ever find a better solution to this?

For what it’s worth I ran into this issue today as well. Following the directions here: Google Assistant: Scenes available for main user, but not other household members - #3 by bradymholt I added the room to the entities via entity_config:

google_assistant:
...
  entity_config:
    script.vacuum_kitchen:
      expose: true
      room: "None"
...

I have a strong dislike of this solution as it requires me to explicitly declare each individual script in entity_config then restart every time it changes. I would prefer to be able to use exposed_domains for “script” and then assign rooms to the scripts in Home Assistant. Or, at least be able to configure the google_assistant integration to use a default “room” for all entities that cannot have areas assigned. At it’s core this looks like a Google bug, non-roomed entities should be shared with all household users. Why they would treat these differently I cannot fathom. But it’s a bug I think Home Assistant could give us a more reasonable work around for.

In the meantime, using entity_config: room: seems to be a viable solution, as long as things aren’t changing regularly, and personally I like this better than the one proposed above.

1 Like

Wow, this also fixed the issue for me. My wife hasn’t been able to run the Night Night script for 2+ years when going to bed. I can’t believe it just needed a room/area assigned! My Google config is in the frontend so not in yaml. In case anyone has this issue I was able to assign a room fine in the GUI:

image

After syncing entities to Google I could then see the Script when trying to Edit a scene within an Action/Routine.

1 Like

Hi Craig,

I’ve tried this, in google home i have a room named “House”, on the scene i assign it to “House” in area, just like you did in the screen shot. I’ve rebooted HA and still I am not seeing the scene on my wife phone. Does this still work for you?

Hi Lars

I have just double checked this on my wifes phone and it is still working as expected.

On her phone if I go to Scenes I see this:

Note there is only one script showing with an area of ‘Hallway’. But if I check the same on my phone I see loads more scripts:

The only difference for the Night Night script is that it has an area assigned which shows in the screenshot. How does this show on your phone? Do you see the House prefix before the script name?

Understand this is a old post but I was still having issues getting GH to see a script both in my my GH and my Wife’s GH so this is what I did to fix it. Background: I had made a script in HA that would issue what google would think was a verbal command ( Perform action ‘Text-to-speech (TTS): Say a TTS message with cloud’ on living room nesthub ) I then went into GH made a Household automation and used my HA script as the action. Worked great except it would only work if I gave GH the command. The automation showed up in the Wife’s GH but the action was blank and the option to select that script (called a scene in GH) was not there. Prerequisites are 1. You need to have the Google SDK integration installed in HA. ( if you are using the script in a different manner then you need to adjust) 2. You need to expose the devices, script, etc., to your voice assistant from HA. 3. In HA you need to add your devices, scripts, etc. to a Area. 4. You need to have added HA to your GH using the Works with google option. 5. This is out of order but it should go without saying after any change you make in HA you should do a reboot and in GH you should tell it it to Sync all devices. OK lots of background if you have done all of things I mentioned and still do not see the script in GH…Welcome to my personal Hell! Here is your magic bullet. Not required but while screaming obscenities at my Google speaker and the wife’s phone I checked (This part IS REQUIRED) her phone to see if HA had been added to it using the aforementioned “Works with Google” It. Had. Not. Been. *Side note -The HA companion app was on her phone. Once I added HA using the works with option, did the sync my devices thing, then FINALLY the script, again called a scene in GH was there. I added it as a action and it worked. Understand when I added HA to her phone I had to sign in to MY Nabu Casa account. Not going to pretend I understand why that was needed but it worked! Hope this helps some of you.