How To Send Sensor Triggers to Android and Have Android React

android
project_alerts

(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #1

[Note: my immediate application for using this concept is with getting external motion sensors to wake an Android’s screen, but I will eventually want to do this with other sensors and different reactions as well]

I have seen this discussed in a lot of threads, and there are different pieces and parts of the concept all over the place. I wanted to see it specifically discussed in one place.

Generally speaking…

  1. Z-Wave/Zigbee connected motion sensor detects motion
  2. SmartThings gets notified
  3. SmartThings sends notification to Android device as usual
  4. Some app on Android device parses SmartThings notifications
  5. App on Android sends command to wake Android device screen or other task on the Android device

Not Using Android Camera
This would waste energy. That’s why I want it to use an external sensor.

Not using yet another ‘cloud’ system beyond the one we’re already using (SmartThings; local processing would be ideal, but I only have a V1 hub). I have heard of people doing something similar with IFTTT and/or other online system, but in light of delays I have experienced with IFTTT and since everything is already going through the SmartThings ‘cloud’, I’d rather keep it limited to that, and not have to add another potential delay to the mix.

The main way I have heard of so far is using Tasker and Secure Settings. However, we need specific steps to get it set up and fully functional.

In my case, I already have both Tasker and Secure Settings and have used them for other things. I just need instructions for how to do this (with those apps or whatever makes it work)…and/or a URL to somebody else’s instructions (I will add links to this OP to give credit if anybody can identify specific instructions already having been posted here somewhere).

Eventually, the system I’m imagining will have at least two modes of operation…

  1. Home
    when we’re home (i.e. SmartThings is in Home Mode), it will act as a trigger for turning the Android’s screen on so that I can see and interact with SmartTiles (or other ‘Dashboard’).
  2. Away
    When we’re gone from the house (i.e. SmartThings is in Away Mode), it will act as a trigger for some kind of camera security app on the Android device.

If YOU have done this (or if you know where it has been detailed with step-by-step instructions), would you please post in here to let others know how to do this?

UPDATE: With the help of @joshua_lyon of Sharp Tools fame, I was able to get this figured out by using a combination of Sharp Tools, Tasker and Secure Settings. If you want more details, either check out post #17 in this present thread, or PM me.

Here it is in a nutshell…

  1. I tell SharpTools app on Android device to ‘subscribe’ to a particular motion sensor in my SmartThings system
    2a. I create a profile in Tasker app on Android device that
    2b. uses the SharpTools plugin to monitor that motion sensor
    2c. uses Secure Settings for the action upon trigger
  2. External Motion Sensor sends trigger to my SmartThings system
  3. Tasker app on Android device (via Sharp Tools plugin) ‘sees’ the motion trigger and passes trigger over to Secure Settings
  4. Tasker app on Android device (via Secure Settings plugin) wakes the screen on the Android device
  5. Done (the screen is on) :slight_smile:


Since I have added a couple apps to the mix to help with turning my Android screens on in a timely fashion, I’m just going to paste this here from another thread…


How do you set up Tasker to wake your tablet when you walk up to it
How do you set up Tasker to wake your tablet when you walk up to it
How do you set up Tasker to wake your tablet when you walk up to it
Home Automation Dashboard (HAD)
Android as a Speech/Alarm Device released! And Updated!
[SOLVED] Erratic Android Presence Reporting (fix=Tasker/SharpTools integration)
How do you set up Tasker to wake your tablet when you walk up to it
[RELEASE: v6.7] ActionTiles (formerly called "SmartTiles V6")
Dashboard Theming (Custom CSS) and Mounting Hardware Ideas
Dashboard Theming (Custom CSS) and Mounting Hardware Ideas
Dashboard Theming (Custom CSS) and Mounting Hardware Ideas
SmartTiles Dashboard v5.7: Release March 2, 2016
#2

I believe people have done this a number of different ways, although it some cases it may depend on the exact phone/tablet being used. Hopefully you’ll get multiple answers here. :smile:

@joshua_lyon may already have instructions somewhere for one…


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #3

Thanks! I sent him a PM.


#4

When you include someone’s @ name in a post, they get tagged automatically and will see the thread. :slight_smile: I’m sure he’ll stop in when he gets a chance.


(Joshua Lyon (SharpTools.io Dashboard)) #5

I can help with the first part of this – getting an Android device to react to events occurring in SmartThings allowing you to trigger a profile in Tasker. I developed an app called SharpTools which is a set of Tasker plugins and widgets for the SmartThings platform.

Using SharpTools, you can subscribe to any number of attributes and then use the ‘Thing State’ event plugin in Tasker to react to those attribute changing (eg. motion sensed, door opened, etc).

I have some instructions (and a video) on how to subscribe to a device attribute and react to changes in Tasker here:

In place of the example task, you would want to create your own Task using Secure Settings to wake the device (turn the screen on).


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #6

Doh! Thanks :slight_smile:

20 20 20


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #7

Awesome! I already have Sharp Tools and the plugins. …just haven’t ever used them much for anything other than a couple light switches on homescreen.

This is great. I will take a look later and get back to you with questions and praise! :slight_smile:


(Bob) #8

If you’re only looking to be alerted, and not waking the phone directly into the ST app, this can be accomplished using the built-in Ambient display feature that’s part of Lollipop and Marshmallow. You can even add it to Kit-Kat if your device is rooted and has X-posed framework, by using the “Enable Ambient Display” module.


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #9

Thanks. I will definitely check this out as well.


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #10

@joshua_lyon

OK, so I finally got around to this…and now I have a question. I could send via your site or something else instead if you want (let me know), but here goes…

I followed the instructions, including the change-up to make it for waking the screen instead of the included example. However, it’s not working.

Two things that may help me on this are…

  1. List of official thing names and attribute names.
    i.e. in your post here, you referred to the sensing of motion as 'motion sensed" whereas in the Sharp Tools app, it is listed as simply ‘motion’, and I have no idea where else to get the actual, official list of them.

  2. Any chance you’d be willing to write out the exact steps you’d use to do this…sort of like the example, but specifically for this use case? I’m pretty sure I have this part right, and there must just be something else going on, but if you were to help me out with that, I would be able to compare with what I’ve done and see if I just missed something or whatever.


(Ernie) #11

I have done something similar to what you are trying to do. One difference is that I used the state of a switch (turned on and off by a motion detector) instead of just the motion detector. If using the motion detector the states you would use are “motion” and “no motion”.
I could not get secure settings to wake my tablet. What worked for me was a pop up alert.


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #12

Wow, the rabbit hole keeps taking turns and the ride is going way too fast lol

Thanks a bunch, @ErnieG !

Though yours may turn out to be the solution for me as well, I will test that after I’m done testing the ST-Motion / Sharp Tools / Tasker / Secure Settings-Wake route (and once I am confident that I have set it up the way Joshua is thinking).


(Joshua Lyon (SharpTools.io Dashboard)) #13

It sounds like you are on the right track!

SharpTools is exposing the native events from SmartThings when you are using the event plugin, so its not hard coded to any particular list.

I’m not sure if SmartThings has all of the events documented, but what I typically do is subscribe to the desired attribute then setup an Event Profile > SharpTools > Thing State…and inside the profile, I create a Task with the action Alert > Notify (or Flash) and put the %st_attr_value variable in. Then I trigger the device (eg. Lock and unlock a door, turn a light on or off, wave my hand in front of a motion sensor) and see exactly what SmartThings reports the value of the attribute to be as it changes.

Please let me know if you need anything else!


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #14

Whoa!!..I have to go through and do that kind of testing with every single thing and every single attribute among all of my smart things? I’m not so sure I even have that much time left on the planet lol

Isn’t there an easier way to get a names and attributes list? :slight_smile:

Sorry if I misunderstood.

Oh, also…I know it’s not your fault if this is indeed the only way…I’m just starting to think of how long and unenjoyable that kind of process could be. Of course, I guess I don’t necessarily have to do the testing on everything, but only on the ones I’m attempting to implement at any given time for a given project, but still…


(Joshua Lyon (SharpTools.io Dashboard)) #15

Capabilities are listed at the link below… If you scroll down, you can see the possible values for various attributes of each capability.

http://docs.smartthings.com/en/latest/capabilities-reference.html


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #16

Thanks. Opening link now…


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #17

Bingo! That’s what I needed.
Now, I’m not exactly sure what went wrong the first time I tried it, because looking at that doc didn’t actually change anything about what thing or attribute name I used this time vs last time, but I’ll just assume that I must have dinked something up when I did it last time.

Just to make sure, this time, I first did an exact walk-thru of your example, and when I saw that it worked, I just went in and modified things to use same general outline to get Secure Settings to wake the screen, and it worked as expected.

So, thanks a lot, man. I am off and running on this particular part of the project. :slight_smile:

To reiterate for anyone else following, I basically set things up exactly like the example named
Event: Thing State
here…

…except for the part about creating an ‘Alert’.
Instead, when it came to that point, I chose to use Secure Settings to create an action that wakes the screen.

If anybody needs help with this specific step, let us know.

Here it is in a nutshell though…

  1. I tell SharpTools app on Android device to ‘subscribe’ to a particular motion sensor in my SmartThings system
    2a. I create a profile in Tasker app on Android device that
    2b. uses the SharpTools plugin to monitor that motion sensor
    2c. uses Secure Settings for the action upon trigger
  2. External Motion Sensor sends trigger to my SmartThings system
  3. Tasker app on Android device (via Sharp Tools plugin) ‘sees’ the motion trigger and passes trigger over to Secure Settings
  4. Tasker app on Android device (via Secure Settings plugin) wakes the screen on the Android device
  5. Done (the screen is on) :slight_smile:

Zigbee thermostat coming?
(Joshua Lyon (SharpTools.io Dashboard)) #18

Thanks for the follow up! I’m glad everything is working as expected and thanks for summarizing the steps for other people who might find this thread!


(ocpd+adhd+alz+md+hfa+fms+lol=me :)) #19

Hey @joshua_lyon,
I want to modify my profile in Tasker to watch for motion on more than one motion sensor.
Is it possible to put more than one ‘thing’ in the Thing: field of the Event?

As of now, I only tested by cloning the original rule and changing the name of the thing, but if I could just put both motion sensors in the same Event, that would help keep down the number of profiles in Tasker.

I also sort of assume this may just be a Tasker question. So, if you could point me in the right direction, I’d appreciate it.

I guess I could just test it and see for myself, but it’s late, and I wanted to just get this out there before sleepy-time. I will try it first thing tomorrow if I don’t see anything in here about it yet. No hurry…I’m just awake and thinking about it…


(Joshua Lyon (SharpTools.io Dashboard)) #20

The Thing State event plugin fields are considered filters for events. So if you leave both fields blank, then the plugin will match all events that are triggered (eg. anytime a subscribed attribute changes).

Using that logic, you could set the attribute field to something like motion and leave the thing field blank which would cause the profile to trigger for any motion sensor attribute that changes. Similarly, the fields also allow partial content matching - so if you put hall in the thing field, the profile would match upstairs hall, hall light, and any other thing with hall in the name.

Note that this is just saying that any thing/attribute that matches the filters will trigger the event. (Eg. this is NOT saying that ALL thing/attributes must match which sounds more like what you are looking for)

For your scenario, you will probably need to take advantage of Tasker variables. Depending on the names of your things and what all you are subscribed to, you may be able to accomplish this with a single profile. And if you can’t, I wouldn’t worry about having multiple profiles – sometimes I create whole projects in Tasker when I know there will be multiple profiles for a single project.

Are you looking to see when both motion sensors are triggered at exactly the same time or are you looking to see if both motion sensors trigger within some period (eg. triggered within X minutes of each other)? If it’s the latter, you could create a global variable for each device (at least one capital letter in the variable name), and when the event is triggered, store the timestamp in each respective variable… then later in the task, you could compare each variable to see if they are within X minutes of each other before triggering your action.