Variable in expression
Moderator: Martin
-
- Posts: 38
- Joined: 16 Sep 2019 12:51
Variable in expression
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..
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..
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Variable in expression
Post the flow please.
-
- Posts: 38
- Joined: 16 Sep 2019 12:51
Re: Variable in expression
My bad
- Attachments
-
- flow_Flow4_20191231_071649.xml
- (1.65 KiB) Downloaded 710 times
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Variable in expression
It seems all wrong to me, what are you trying to do?
-
- Posts: 38
- Joined: 16 Sep 2019 12:51
Re: Variable in expression
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}.
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}.
- tsolignani
- Posts: 187
- Joined: 12 Jan 2019 11:53
- Location: Vignola, Mo, Italy
- Contact:
Re: Variable in expression
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.
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Variable in expression
You can assign variables in an expression but you still need something to check at the end.
Crude but it works.
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Variable in expression
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 .
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 .
Crude but it works.
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: Variable in expression
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.
Good luck
I don't understand regex, but this crude method works.
Code: Select all
value = "I said 12 minutes";
minutes = replace (join (findAll (value, "\\d"), ","), ",", "");
Crude but it works.
-
- Posts: 38
- Joined: 16 Sep 2019 12:51
Re: Variable in expression
thanks for everyone's help
still cant find the solution but i have included the full flow
still cant find the solution but i have included the full flow