Page 1 of 1
"Create calendar event" start-end time question
Posted: 16 Jun 2017 04:10
by geirj
Hi. I have a question regarding creating a google calendar event..
I have two flows that I use for my car.
Flow1: Triggers when I connect to the blutooth stereo, then adjusts some volumes etc.
Flow2: Triggers when I disconect from the blotooth stereo, resets voluems etc.
Now, I would like to add an Action to Flow 2, that creates a google callendar event,
using the triggertime of Flow1 as the start time of the callendar event, and the triggertime of Flow2 the end time of the callendar event. How can I do this ?
I have several other usecases where I have a "start"&"stop" flow, where I would like to do the same, so any help with this would be highly appreciated
Thank's in advance

Re: "Create calendar event" start-end time question
Posted: 16 Jun 2017 10:30
by Bingwu
Hello geirj!
For example, you can use one or more global variables. (global_xxx) The name for the global variable can be freely chosen, the "global_" at the beginning is mandatory.
By using a global variable, you can use it (after execution) in all other flows.
Insert an
Action ->
Script in Flow1: global_triggertime_flow1 = triggertime
In Flow2 you create the
Action ->
Create Calendar Event.
Calender: [your calender]
Start/End Type: absolut
from: global_triggertime_flow1 (the triggertime from Flow1)
to: triggertime (the triggertime from Flow2)
...
Excuse me, my body uses a German UI and I the appropriate UI of Automagic.

I hope it is still understandable.
regards
Peter
Re: "Create calendar event" start-end time question
Posted: 16 Jun 2017 18:21
by geirj
Thank you so much for your reply Peter. It worked like a charm
One bonus question

,-
Do you know if it would be possible to adjust the end time,-
to: triggertime (the triggertime from Flow2)
.. with 5 minutes..
I know it is a strange question, but in one of my other flows I use for tracking my time at work, I use the location of my work as a trigger for the end-flow. (When I leave work,- the flow triggers.)
The thing is that I use about 5 minutes from logging out of my work computer, before I have changed and leave work,- triggering the end-flow.. So to compute the correct time I actually work, I will have to subtract 5 minutes from the triggertime of the end-flow.
Could I use something like:
triggertime-5 ??
Or is there another sollution ?
Thanks in advance.
Br
Geir.
Re: "Create calendar event" start-end time question
Posted: 16 Jun 2017 18:49
by Bingwu
Hello Br Geir!
You can count on time!
The time in Automagic (triggertime, getDate() ...) is given in milliseconds since January 1, 1970. (June 16, 2017, 5:50:50.082 pm = 1497628250082 milliseconds)
If you want to subtract 5 minutes from the triggertime, you subtract 300000 from the triggertime (5 minutes x 60 seconds/minute x 1000 milliseconds/seconds = 300000).
For example: in an Action -> Script: realendtime = triggertime - 300000
That's all!
I wish you success!
Peter
Re: "Create calendar event" start-end time question
Posted: 17 Jun 2017 07:24
by geirj
Thanks once again. Worked great !
