Page 1 of 1
Auto Update
Posted: 07 Jun 2018 09:45
by regissg
I am using Automagic on few tablets with the same flows and widgets.
I am trying to see if there is a way to automatically update these flows and widgets when there is a new version of them?
The solution I have considered is to run on periodic basis a flow like that
-action Init Variables File Info: /...MyFlowWidgetGroup.xml, activate the file_last_modified box
-condition Expression: check if file time is higher than current flows/widgets
-->true: -Import Flows/Widgets/...MyFlowWidgetGroup.xml, activate the Replace existing box
To automatically update all my tablets at once I will need to have the file MyFlowWidgetGroup.xml stored on the cloud (for example google drive) but my problem is that I do not see the option for Automagic to access google drive files.
Is that a dead end and if yes is there other solutions to address my Auto Update problem?
Re: Auto Update
Posted: 07 Jun 2018 13:58
by Desmanto
Automagic has the action to access Gdrive. Create a new action and search for Google Drive. You can use "Google Drive Init Variable File List", include file attributes, to check for modified time. If the modified time is different that stored version, then download that, and import it.
Re: Auto Update
Posted: 03 Sep 2018 17:27
by regissg
Hello Desmanto, I am able to get a variable with the file name and the file info (size, time) but I am strugling to extract the specific file modified time.
Should I process the variable string and detect the third comma in the string to extract the proper item or is there a simpler way to do it (like get file_time or extract the 4th item of this variable)?
Re: Auto Update
Posted: 03 Sep 2018 18:23
by Desmanto
I can't test this, I don't use Gdrive. Can you put condition debug dialog after it, and paste here the result of the init files?
We can process the result using regex, parsing the necessary information and act upon them. But I need the example result first.
You can change the filename to something else for privacy, as you are going to post it here. (everyone can see it).
Re: Auto Update
Posted: 03 Sep 2018 21:43
by regissg
Here is the "files" var value i got after the google drive init variable file list action:
[/Automagic/exported_data_20180903_173557.xml, file, 73870, 1535993502625]
I assume that 1535993502625 is the file modified time.
I was wondering if there was an easy way to extract it or if I should do it with regex?
Re: Auto Update
Posted: 04 Sep 2018 08:56
by regissg
After a lot of script test and try I finally was able to extract the file name and the file time with the following script:
list=split(files,", ");
filename=replace(getElement(list,0),"[[/Automagic/","");
filetime=replace(getElement(list,3),"]]","");
Re: Auto Update
Posted: 04 Sep 2018 17:25
by Desmanto
As I predicted, the result will be in a list object. So
files = [/Automagic/exported_data_20180903_173557.xml, file, 73870, 1535993502625]
{files} is a list object with 4 elements (comma is the separator). To access each element, simply point to the index (starting from 0). So
Code: Select all
path = files[0]; // /Automagic/exported_data_20180903_173557.xml
type = files[1]; // file
size = files[2]; // 73870
time = files[3]; // 1535993502625, this is the value you want.
No need regex for the time, since the time is populated in list object, very easy to access. Simply use
For filename, you need to use regex or simply use the same method you use above if you have fixed path, replace the path before the filename
Code: Select all
filename = replace(files[0], "/Automagic/", "");
Re: Auto Update
Posted: 06 Sep 2018 14:27
by NicholasIndoril
Hi I was also using three devices with automagic. I was using a system with gdrive and calendar. since I had google account on all devices when I wanted to update flows on a specific device I was using ui list to specify which device to be updated. So it uploaded the flows.xml file on specific gdrive folder and all devices got the synced calendar event ringing at the right time (set time to now) but when they had a notification popped saying update flows they silenced to avoid ringing on e.x. night hours and checked from the notification event if the update was for the specific device... (had global variables with model code on each device) and then downloaded the flow and updating it.. and deleting calendar event and dismissing notification.. everything silenced..usefull
Re: Auto Update
Posted: 07 Sep 2018 18:11
by Desmanto
I rarely need to sync the flow. If I have to, i simply send it via mixplorer along with other things. But I can actually just set up the HTTP request trigger and sync the flow using it. Will find some time to create the flow.