Phone Accelerometer to trigger piston


#1

I would like to add a condition to several of my pistons. After searching, I found no results for my query. I’m wondering if it is possible to use the accelerometer in a phone as a condition. By way of example: switch “A” comes on everyday at 6:00 AM. I would like to add the condition of movement of a phone or phones to the mix so switch “A” will turn on “IF” it is 6:00 AM everyday “and” movement is detected on person “1” phone. I’ve not been able to find this last variable as a condition.

Thoughts?


#2

You might be able to achieve this with Tasker as the source of acceleration data, IF you’re an Android user.


#3

In Tasker, the trigger is found in Event > Sensor > Shake…
(It detects Left-Right… Up-Down… and Backwards-Forwards)

You can tell Tasker, after a certain time, if the device is shaken in the “correct” direction, then a HTTP Get can point directly to the External URL of a piston. WebCoRE can keep track in a variable, and use that as a condition at 6AM to determine if the switch should come on or not.

(Again, all this is assuming you have an Android device)


The User Guide for “shaking” can be found here.


#4

Thanks for the response… I use Android, but 2 others use iPhones. I was hoping to find it in WC itself. I do use Tasker for other things but have not yet figured out how to combine it with webcor.


#5

You can program anything on Tasker’s “Profile” tab… and when it is true, the “Task” can execute a piston by sending a HTTP Get to the External URL. (this link gives many examples)


Another approach to this (not using your phone), is you can let a motion sensor (during specific hours) set a global variable @activeMorning = true. Then, in your original piston, you can check the status of that global variable before turning on the switch.


#6

I’m really trying to tie this to one person. For example, if person 2 triggers the motion sensor and the time is after 6:00 AM, it will incorrectly fire. That’s why I was hoping to use a specific phone to be part of the condition.

… It’s after 6:00 AM, and phone Accelerometer triggers, …Stuff happens.

I guess I could buy Tasker for the Android, but I’m stuck on the iPhones.


#7

I tried a test piston with the Tasker app on my android.It was to simply send me a text message with “TEST”. I used the Tasker event of 5 steps taken to trigger the task. I got the following error in the piston log.

Logs

12/2/2019, 9:04:33 PM +572ms
+126ms ║Error executing external web request: javax.net.ssl.SSLException: java.security.ProviderException: java.security.InvalidKeyException: EC parameters error


#8

I have read this five times, and still do not understand…


If Tasker is sending a command to webCoRE, it is simply a Task that sends a HTTP Get to the piston’s External URL.


If you are going the other way, (webCoRE sending a command to Tasker), then just send a PUSH notification, and tell Tasker to use that as a trigger.

pic

Make sure it is a unique notification, that is not used for anything else.


#9

Sorry for the confusion. What I was saying is that I was using the Tasker trigger under sensors of “taking five steps”. So if the person picks up the phone and takes five steps the task of sending the HTTP get is accomplished. I have figured that part out. Now I’m hung up on how do I get it to only happen one time per day? I need to limit it to the first time that trigger happens otherwise it is going to send that command every time it happens which is not what is desired. For example if the phone travels five steps and it is after 6:00a.m., stuff happens.


#10

You can limit the trigger in webCoRE, but I would prefer limiting it in Tasker.

The following “Task” will only send the command once per calendar day:


Breakdown:

(1) Stores Day Of Week into a local variable called %day
(2) IF %day does not match %dayprev
(3) Then send HTTP Get. (Flash is my placeholder)
(4) END IF
(5) Stores current %day into a local variable called %dayprev
(6) Good coding practice in Tasker

Note:

  • The two local variables should be in all lowercase.
  • The system variable (%DAYW) must be in all caps.

Pro Tip:

I have not used the “Every 5 steps” trigger yet, but your current trigger will likely not stop the Task from running throughout the day… (however it does limit the IF block to only once per day)

I would also consider adding more logic to the “Profile” tab to limit within a certain time range.
(to keep battery usage to a minimum)

IE:

  • Go to the “Profile” tab
  • Expand your trigger (don’t open it)
  • Long press on the left side of your trigger
  • Add +
  • Time
  • Adjust both Time dials
  • Back up multiple times to the desktop

#11

Thank you @WCmore . That is good stuff!