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?