Auto sleep/lock/awake based on shake

Post your questions and help other users.

Moderator: Martin

Post Reply
DavidJeep
Posts: 5
Joined: 11 Dec 2014 15:43

Auto sleep/lock/awake based on shake

Post by DavidJeep » 11 Dec 2014 15:50

I am trying to create a flow to stay awake as long as the tablet has been moved in the last minute. But if a minute passes by and no shake is detected, then to sleep or lock the tablet, and then to awake again on shake.

As I build this flow, I can get everything, but not how to determine if it has not shook in the last minute to initiate the sleep/lock.

Any one willing to help?

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Auto sleep/lock/awake based on shake

Post by Martin » 11 Dec 2014 17:54

Hi,

You could use trigger Shake (battery hog) and an action Lock device for the one-minute-to-lock feature:
-trigger Shake
-action Sleep: 1m
-action Lock Device

When editing the flow, open menu->Options and switch the flow execution policy to Stop the currently executing instance and execute afterwards. This will ensure that the lock is not executed when the flow is executing for less than one minute and starts to execute the flow from scratch.

Regards,
Martin

DavidJeep
Posts: 5
Joined: 11 Dec 2014 15:43

Re: Auto sleep/lock/awake based on shake

Post by DavidJeep » 11 Dec 2014 18:15

shake is a battery hog?

What would be the best way to have my tablet on, when it is shook, or there is motion in front of it? but after a couple minutes of no movement of device or in front of device, to go to sleep, or turn screen off?

I do not have a proximity sensor
I also do not have "significant motion detected"

I tried this motion detector which states it works with automagic, but automagic does not recognize it
https://play.google.com/store/apps/deta ... ctor&hl=en

DavidJeep
Posts: 5
Joined: 11 Dec 2014 15:43

Re: Auto sleep/lock/awake based on shake

Post by DavidJeep » 11 Dec 2014 19:26

I asked the developer of the motion detector app, and he emailed me back right away and gave me some basic instructions that I did not know of, so now my tablet will lock and unlock based on motion, and using the steps you stated above, just replacing shake with a notification from his motion detector app.

to receive notification from Motion Detector need to look for Trigger -> General Broadcast
Action: org.motion.detector.ACTION_GLOBAL_BROADCAST

to send activation signal to Motion Detector need to look for Action -> Start Service
Action: org.motion.detector.ACTION_DETECTOR_ON
Package Name: org.motion.detector.Engine
Class: org.motion.detector

to send deactivation signal to Motion Detector need to look for Action -> Start Service
Action: org.motion.detector.ACTION_DETECTOR_OFF
Package Name: org.motion.detector.Engine
Class: org.motion.detector

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Auto sleep/lock/awake based on shake

Post by Martin » 12 Dec 2014 16:55

Great, thanks for the information about Motion Detector. I will add it to the list of examples in trigger General Broadcast and action Start Service.

Trigger Shake keeps the device awake to read and process the sensor values so it consumes quite a bit of battery when used 24*7 which is required when you want to turn the device on using this trigger.
I'm not aware of a better mechanism at the moment. An app like Motion Detector that was specifically written for this purpose might have implemented the detection in a more battery saving way.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Auto sleep/lock/awake based on shake

Post by Martin » 12 Dec 2014 17:04

The values to enable/disable Motion Detector in package and class are interchanged, please try it like this:
Package Name: org.motion.detector
Class: org.motion.detector.Engine

Post Reply