Looking for a way to implement a [Leave Location] trigger

137 views
Skip to first unread message

H.U. Graedener

unread,
Jul 27, 2016, 4:24:33 AM7/27/16
to Automate
Hi, this might be a very basic question, sorry for that but I just started working with Automate a few days ago and am not very proficient in programming.

I would like to make a flow which sets my phone's Ringer Mode to Normal / to vibrate depending on location. So far, I added three different locations in which the ringer is set to vibrate (which is fine and works well). Now, I would like to add a block to disable vibrate and set the ringer back to normal upon leaving these locations.

So far I added a NO statement to the location block, so that the flow would check whether I am at any of these three locations, and if I'm not it would set the ringer back to normal.

However, as I have this flow running every 15 minutes, I can no longer set my ringer to vibrate or OFF at other locations any more, as the flow would detect me not being at one of the 3 locations above and set the ringer back to normal.

Is there a way to detect me leavig a specific location?

Thanks for supporting a newbie.

Florian HubSpace

unread,
Jul 27, 2016, 5:34:06 AM7/27/16
to automa...@googlegroups.com
Hey,

you learn best by browsing the community :D
One of my first flows do this(with a little overhead of dynamic locations, but i think you could understand it anyway)

It is based on http://llamalab.com/automate/doc/block/location_at.html (location at) with proceed "when change".
For each location you need one fiber http://llamalab.com/automate/doc/block/fork.html

I quickly change to improve it to support different actions:

And finaly came to a more modular way: (Advanced users only)
Where you need to create additional subflows to perform any task.
Like my Volume manager to mute your phone at a location:


However, if you realy want to run the flow every 15 minutes and not based on the when change event of the location at block. For whatever reason, you need to save the last state and compare it with the current.
The best way would be an array with a size of 3 and initialized with 0.

location 1: 
if array[0] = 0 and location 1 = in range -> perform enter event and set array[0] = 1
else if array [0] = 1 and location 1 = not in range -> perform leave event and set array[0] = 0

location 2: 
if array[1] = 0 and location 2 = in range -> perform enter event and set array[1] = 1
else if array [1] = 1 and location 2 = not in range -> perform leave event and set array[1] = 0

location 3: 
if array[2] = 0 and location 3 = in range -> perform enter event and set array[2] = 1
else if array [2] = 1 and location 3 = not in range -> perform leave event and set array[2] = 0

Delay 15 minutes and start with location 1

//But be aware, that when you leave and enter an other location within the 15 minutes delay, it will perform a leave and an enter event, but you can't be sure if it first perform the leave or the enter event. So it is buggy and you may need to improve the expressions

H.U. Graedener

unread,
Jul 27, 2016, 6:04:20 AM7/27/16
to Automate
Wow, this is awesome - I glanced into your flows and will try to understand some parts of them. Thanks a lot.

I did not get the meaning of "When change" before and the difference to "Immediately". Thanks for that also. 

Why do you write the locations into the text file? What is the advantage to just checking if at a specific location?

Florian HubSpace

unread,
Jul 27, 2016, 8:14:45 PM7/27/16
to Automate
There is no advantage beside the dynamic aspect instead of hard coding.

My focus is on the community. 
It is much faster and with less blocks to implement this kind of tasks hard-coded. But I can only provide my personal settings, which will differs from yours. 
So you have to find the blocks in my flow and edit all relevant blocks(i.e. all location at blocks, and maybe add additional blocks).
To be able to do this you need a documentation and I have to provide these information in the flow description ... -_-

In my opinion the users shouldn´t be forced to edit the flow. It would be more effective to provice a GUI and implement as much as I can dynamically, to keep the flow as personalized as it could be.
But to store the personal settings you need an external (configuration-)file.
Reply all
Reply to author
Forward
0 new messages