cancel
Showing results for 
Search instead for 
Did you mean: 

How to use variables in script editor?

Ula
Community Member

I am using new script editor for automation. My goal is to get a part of the `eventData` in `assistant.event.OkGoogle` as a variable, but couldn't get it to work. I couldn't really find a complete example of variables being used.

Can you share a complete script where a variable is defined and used only with `assistant.event.OkGoogle` starter and `assistant.command.Broadcast` action for simplicity?

I'm not sure if this is even possible. Having a complete example of variable usage in documentation can make it clear their capabilities.

7 REPLIES 7

Prafulla
Googler
Googler

Hi @Ula - thanks for your question. Variables are not yet supported in the script editor but I would encourage you to vote on the relevant idea in this thread where other users are also suggesting similar ideas. 

Ula
Community Member

Thanks for your quick response.

Just to be clear, I can see variables are documented here. Are they not supported for cases like mine, or not supported at all? 

Yes, variables are in early stages of implementation. We will update our documented examples when they are fully available. Your use case of dynamically storing part of `eventData` in a variable is not yet supported.

cchien
Community Member

It looks like the documentation about variables only shows how they can be defined, and have default values, but there is no example as to how to assign a value to a variable, say from a value we got from a sensor. Is it ready at all? Any update would be appreciated. Thanks.

Zappos
Community Member

Any update on when the documentation might be ready? I'm keen to use variables. I want to use one to create a reference to a device (so I can change the device assigned to the variable and then use the variable throughout the script. Saves having to change every occurance of the device name. But I can't see how to assign a value to the variable , specifically a device. 

yeah +1, any timeline that can be provided?

benet
Community Member

https://developers.home.google.com/automations/schema/basics#variables

I can find variables in your documentation - but for me it does not work yet. Is this feature activated at all?