Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 107565

Use of "Define Variable" action in an automation

$
0
0

I’m new to HA but not new to smart-home automation and just starting to write my first few HA automations. In a couple instances I would like to set a value for a variable as an action in an automation. The objective is to be able to then use the variable in other places in HA.

In the automation I am working on at present I want to use the variable to hold a text string which I hope to use on dashboards. In this case a sting of text used to give a custom greeting to a user as the title block of a dashboard.

For example my automation determines that my son forgot to run the dishwasher before leaving the house so when he returns I want his dashboard greeting to read “Don’t forget to start the dishwasher John.”

I have all the triggering and logic worked out but I am stuck on how to use the “Define Variable” action. I’ve been going over documentation and forum posts but so far I have not found the answer. In this case I want to create a variable called Greeting_John and set its value to the string “Don’t forget to start the dishwasher”

In the automation I selected the action “Define Variable” and I am presented with this YAML editor view:

I have found documentation on variables and several posts that discuss there use in automation. But I haven’t found a specific reference to the syntax needed for this Automation Action. I’m hoping a simple example of the correct syntax needed to create a string variable that can be used elsewhere in HA will help address this and spring board me into several other variations and uses of variables.

Any assistance or reference links would be greatly appreciated.

Thanks!!!
Tom G.

9 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 107565

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>