Page 1 of 2
Variable in expression
Posted: 30 Dec 2019 13:10
by coconutxyz
Hi guys I am stuck with trying to assign a variable inside an expression.
My current flow using hotword plugin
Condition: value = "meditate for {meditateduration} minutes"
Action: script : meditateduration = getDurationString(duration*60000)
Action: set timer {meditateduration}
As expected it doesn't work lol since the whole expression looks weird. Any help please..
Re: Variable in expression
Posted: 30 Dec 2019 14:06
by tsolignani
Post the flow please.
Re: Variable in expression
Posted: 30 Dec 2019 23:18
by coconutxyz
My bad
Re: Variable in expression
Posted: 31 Dec 2019 07:01
by tsolignani
It seems all wrong to me, what are you trying to do?
Re: Variable in expression
Posted: 31 Dec 2019 14:57
by coconutxyz
lmao is it that bad?
it works if i am using autovoice with the command (?:meditate|meditation) for (?<duration>[0-9]+) (?:minute|minutes) which i believe is regex.
then i will run a script to times the duration with 60000 to convert it to minutes then set a timer for the converted duration.
since i no longer use autovoice and changed to hotword plugin now, i am trying to assign a variable {meditateduration} within the expression using the hotword plugin whose variable is {value}.
Re: Variable in expression
Posted: 31 Dec 2019 15:01
by tsolignani
I'm not sure I understood what you said, anyway, I guess you cannot assign values to a variable into an expression but just evaluate it with a double equal sign, if you have to populate a variable you have to use a script.
Re: Variable in expression
Posted: 31 Dec 2019 17:39
by Micky Micky
You can assign variables in an expression but you still need something to check at the end.
Re: Variable in expression
Posted: 31 Dec 2019 17:48
by Micky Micky
The flow is confusing.
If the variable {value} that you are passed from elsewhere contains the number of minutes e.g. 1 then you can set the timer to:
{value}m
Hope this is of some help to you .
Re: Variable in expression
Posted: 31 Dec 2019 18:10
by Micky Micky
If the variable {value} contains the number within a message then regex is the way to extract just the number.
I don't understand regex, but this crude method works.
Code: Select all
value = "I said 12 minutes";
minutes = replace (join (findAll (value, "\\d"), ","), ",", "");
Good luck
Re: Variable in expression
Posted: 01 Jan 2020 05:28
by coconutxyz
thanks for everyone's help
still cant find the solution but i have included the full flow