Auto Update

General discussions about Automagic and automation in general

Moderator: Martin

Post Reply
User avatar
regissg
Posts: 22
Joined: 23 Apr 2018 13:13

Auto Update

Post by regissg » 07 Jun 2018 09:45

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?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Auto Update

Post by Desmanto » 07 Jun 2018 13:58

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
regissg
Posts: 22
Joined: 23 Apr 2018 13:13

Re: Auto Update

Post by regissg » 03 Sep 2018 17:27

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)?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Auto Update

Post by Desmanto » 03 Sep 2018 18:23

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).
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

User avatar
regissg
Posts: 22
Joined: 23 Apr 2018 13:13

Re: Auto Update

Post by regissg » 03 Sep 2018 21:43

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?

User avatar
regissg
Posts: 22
Joined: 23 Apr 2018 13:13

Re: Auto Update

Post by regissg » 04 Sep 2018 08:56

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),"]]","");

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Auto Update

Post by Desmanto » 04 Sep 2018 17:25

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

Code: Select all

filetime = files[3];
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/", "");
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

NicholasIndoril
Posts: 5
Joined: 31 Oct 2016 19:28
Location: Sparta

Re: Auto Update

Post by NicholasIndoril » 06 Sep 2018 14:27

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

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Auto Update

Post by Desmanto » 07 Sep 2018 18:11

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.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply