SmartThings Community

SmartThings Event-Specific Text To Speech (TTS) for your Android Phone With Tasker

Hi everyone,

The following is a way to have Tasker make TTS announcements for specific SmartThings (ST) notifications you might have, on your Android phone. For example you can have it say “Movement in back yard” when ST sends your phone a notification of that.

It looks for specific text in the notification, in which case it plays whatever TTS you tell it to in Tasker. So it can key in on completely specific ST notifications (however you have defined them to be output from ST).

If any newbies are reading this that don’t know how to send custom phone notifications out of ST, see the end of this post.

Also, this is not the “official” Text To Speech capability of SmartThings. Sadly, this only seems to be for dedicated (and expensive!) speakers bought solely for the purpose of ST TTS. (And no, you can’t directly use Alexa. But you can indirectly use it - thanks @MEarly!)

I sure wish ST just let its phone app talk!!

Anyway,

For anyone that doesn’t know, Tasker is a way to automate all kinds of things on Androids (not just ST). Many people have used it for a lot of creative ST things, such as @joshua_lyon’s SharpTools.

So this is one very specific little instance of something that can be done. I am writing it up because it was very important to me, but I flailed around for months to figure it out, although it’s super simple in hindsight.

Without further ado,

I assume you know the basics of how to get around the Android ST app, and also that you have installed Tasker (from Google Play Store).

In Tasker main window, first make the Profile (the trigger):

  1. Hit the big + in bottom center to start a new Profile,
  2. Suggest giving it a specific name, like “Movement in back”.
  3. Tap Event / UI / Notification
  4. Put into the Text field, the specific notification text output from ST that you want it to watch for, like “Movement on porch”. When Tasker sees that particular text in a notification, it will trigger the action (below).

A few notes:

  1. The Tasker Profile Text must EXACTLY match what’s in the ST notification or it won’t work
  2. You don’t need to tell it that the owner application is SmartThings (you can, but don’t have to). Not unless other apps send notifications with exactly the same notification text. No, this field is more suited when you want Tasker to perform an action for any/every notification from some app. But that’s not what we’re trying to do here.
  3. I’m not sure any other fields matter here; I haven’t bothered with anything else. Maybe Priority can matter. But it seems to work fine at Normal, shrug.

Now, a word on Tasker: It uses Profiles (trigger conditions) and Tasks (actions to do). Strictly speaking, these are separate and you can mix and match Profiles and Tasks all you want (once you have a lot). We just made the all-important Profile. Next comes the Task for it, which will also be easy.

Tasker is kind of odd in that there is no “Ok” or “Save” button for when you are done with a screen. Just hit the omnipresent Android Back key (little triangle in lower left) when done. When you exit, it will ask you to pair with an Action:

  1. Hit New Task
  2. I recommend giving the Task (it’s separate from the Profile) the same name as the TTS (the text the Task will say). Otherwise it can be confusing down the road if you have a lot of TTS Task Actions but their Name doesn’t always match their TTS.
  3. Click the big + at bottom of screen to add a new Action
  4. Select Alert / Say
  5. Put your text to speech (TTS) in the Text field. It does not have to match the ST notification text; it can be anything you want.
  6. The Stream field here might be important. Notice that these selections match the types of phone volumes available in Android Sound Volume settings. To cut to the chase, typically you would have your Stream set to Notification so it matches the general volume level of your SmartThings notification sound. Use Alarm if you want it to sound even when Do Not Disturb is on (but your usual ST chime won’t sound! for typical DND settings).
  7. Engine:Voice is a way to change the TTS accent to an Aussie woman if you want, laugh. Not sure what else good it’s for.
  8. Playing with pitch and speed can make for a sense of urgency or hilarity.

I’ve heard someone say Network matters, but I’m not sure how. I don’t think anything else here really matters, although you can play with the other fields and variables all you want.

When you are finished making the Task and Back out, you will be left at a little screen with what looks like a Play arrow in lower left. Hit this to play your Task and hear/test your TTS already (without needing to trigger Profile). Good for testing.

In summary,

All you did was make:

  1. A Profile that looks for specific text in the body of a notification, and link it to
  2. A Task that says particular TTS.

That’s it.

A few important notes:

  • You must always hit the checkmark in the upper right of Tasker to “save” changes and have them become operational. Otherwise you are working on a draft that will NOT cause anything to happen. Remember this when Tasker ignores everything you do. :slight_smile:

  • You may not want your phone saying things like “movement in back yard”. It can be weird in a meeting or at a party, laugh. So I have more cryptic things like “Back” or “F” or “dor” that really only mean anything to me. If people casually hear something very short, they are not even sure what it was. But you will know.

  • You have to give Tasker permission to see notifications. I can’t remember exactly when or where; maybe it will ask first time you try.

  • Tasker is odd for letting you change names of Profiles and Tasks. Hold your finger on the Profile or Task and it will turn blue. Now you will see along the top of the screen an A to change name, and other options like deleting it.

  • Tasker has a few general settings (“Preferences”).

  • Under Monitor / General / Run In Foreground is not ordinarily needed. It will also make an annoying permanent Notification.

  • Android Settings / Battery / (More) / Battery Optimization / change “Not Optimized” to “All apps” - You should not have Tasker OR SmartThings OR other apps like LiftMaster or whatever that you want reporting near real time, to necessarily be battery optimized. Sometimes “optimized” equals “completely turned off”. I have not completely figured it out, and you might drain your battery doing this, but anyway, be aware of this if you see seriously laggy reporting sometimes. I have seen instances where I saw nothing a few hours, then a rush of a lot of delayed reporting! And other weirdness.

  • If your device is inconvenient to trigger, you can test for text in anything else that generates a notification, while testing. Like sending yourself an email (from an anonymous Chrome window if necessary).

New 1/31/17, Insert a Wait: You may find that your ST notification sound and your TTS arrive at the same time, which can make it hard to understand the TTS. If you space them out, you also get a little mental primer that your TTS is coming.

To insert a Wait command into your Task,

  1. View the Task with your TTS action
  2. Hit the big +
  3. Select Task / Wait. Tip: If you can’t remember which category an action is hiding under (like me), use the Filter at the bottom of the category chooser to search for, e.g., Wait.
  4. Select a time and Back out.
  5. If you made this action after you made your TTS action, your new Wait will now be the second action. The Tasker interface doesn’t tell you how to re-arrange them. To move it first, hold your finger on its zap symbol (to the right) and slide it up.

I have a very short ST notification sound (one xylophone tap) and only have a 400 ms wait. YMMV. The TTS actually starts slightly later than the ST sound already, which makes sense.

New 11/29/17, How to handle Do Not Disturb (DND) with Android Tasker

If you don’t want every single notification going off in the middle of the night (or any time you’ve turned on DND), here’s how to handle it:

  • Use the conditional IF found in every Tasker Action.
  • For DND, see Global Built-In Variable %INTERRUPT whose values can be none, priority, all or alarms
  • For testing its value, use Alert / Popup and text like “INTERRUPT = %INTERRUPT”
  • This shows it works backward from what I would’ve thought; instead of DND = “none” when DND is Off, %Interrupt actually equals “all” most of the time (i.e., allow all) and what I would normally have thought of as DND is “priority” (i.e., only allow Priority messages). It is case sensitive - it can’t be All or ALL. Look at the examples provided in the Help.
  • Summary: To have an Action not be performed if there is any form of DND whatsoever, then your IF line should read:

If %INTERRUPT EQ all

where the EQ condition operator means “Equals”.
.

Okay, that’s all for the Tasker app. Only newbies need read past here -

If anyone doesn’t know how to get SmartThings to send you a specific text notfication for an event, here’s how to do it. There may be other ways, but this is what I do:

  1. Go to home screen (Dashboard) of Android ST app
  2. Hit settings gear in upper right
  3. Select Custom monitor. (This is what works for me.)
  4. Select New Monitoring Rule (at the bottom if you have a lot already)
  5. Select Kind Of Device. If you are unsure the capabilities of your devices, go to the web API at graph.api.smartthings.com (make account if you don’t have one - there’s tons here), go to My Devices, and click on device in question. You will see the Current State of each capability it has.
  6. Next, select which one(s) of those types of devices. IF YOU SELECT MORE THAN ONE HERE, you cannot make device-specifiic notifications. Sadly YOU HAVE TO MAKE A SEPARATE NOTICE FOR EVERY SINGLE device, to get a device-specific text. Hopefully one of these years they’ll let you drop in variables for device and sensor names so you can change the rules for all 20 motion detectors at once. sigh. okay end of rant. :slight_smile:
  7. Change if you want only once per day, number of minutes, etc. on this screen. Hit Next.
  8. Here’s the crux of the matter. Under “Text & Push Notifications”,
  9. Click “Send push notifications” and
  10. Tap to set a Custom Message. This is the message notification text ST is sending your phone, which must exactly match the text that Tasker is looking for in the Profile to trigger the TTS Task action (above).
  11. Hit Done then Next. Change name if you want (doesn’t matter for Tasker). Hit Done.
  12. When you see the green popup that you successfully added the rule, you’re done. Go test it to make sure it works correctly as a notification, before making your Tasker Profile for it.

Hope this helps. Questions or discussion welcome.

Edit 1/28/17: Added “Insert A Wait” info
Edit 1/31/17: Added Stream Volume info
Edit 2/19/17: Added Use Alarm sound to cut through DND
Edit 11/29/17: Added notes on how to work with Do Not Disturb at a more general level

3 Likes

Nice detailed post. Good job.

I just want to throw in there you can use TTS in ST without expensive official integrated speakers. You can use android, landroid, and other options.

I personally think the best is with using EchoSistant.

2 Likes

Use sharptools attribute values inplace of specific notification messages. Your profile would be “sharptools attribute change” and task would be “say” - %st_thing_name %st_attr_value.

3 Likes

This article has some more details on how to do this. David summarized it well though: you can subscribe to events in SharpTools and then react to those in Tasker. This means you don’t have to have notifications come from SmartThings (which can be a challenge in multi user households) and you can directly access variables to be used in your ‘Speak’ profile.

1 Like

Thanks Jason. Can this be specifically used for tailored notification announcements like I described - “Movement in back yard” based on a particular sensor event?

I don’t see such a thing on the pages for EchoSistant but there’s so much there I could be missing it.

If it’s true, can you point to the part that talks about how that would work. Thanks!

.
P.S. It would be nice if your first landing page said EchoSistant is for Echo/Alexa.

It is, right? I mean, it seems to be, based on the name. And that seems to be all it’s talking about. Then eventually I dug down to the wiki, which finally seems to actually say, Yes, we are only talking about Echo.

But look at the landing page itself. Does it say “For Echo/Alexa (only)” right up top? Anywhere at all, really?

No. Leaving newcomers wondering all the way through. Looking for hints or clues as to whether it’s only Echo, or also other things, or what.

It would be nice to take one little line to just say that right up top front. Sometimes we get so close we forget others can be new. I do it all the time. Thanks for considering this.

Yes, The system is set up for custom notifications and alerts based on a number of inputs. You choose the device and what kind of output you want.

You kind of lost me here… cause doesn’t it say it… right here… at the very top of the landing page?

Thanks muchly for the reply David and especially Joshua, I was hoping you would chime in.

I like the idea of not having to use the ST notifications per se, they can be clunky. You have to flip through so many screens every single time you want to play with one little parameter to see how it works! I count 7 taps/Nexts/Dones just for a tweak of the notification message. Or if I want them all to have a 10 minute reporting period. Then there’s the issue of applying one setting or message to them all (like my 9 motion sensors).

Just to be clear - it is possible for SharpTools to have an individual sensor give an individual TTS message, right? I have nine motion sensors but really only care about three of them for verbal alerts. So they need to be handled individually.

I never though about the concept of multiple users because so far I am the only user. But of course it’s possible to have more than one. I never even thought about tailored messages for different users. If ST doesn’t do it but SharpTools can, that’s very important.

Hi Jason, for the landing page, please reread what I wrote. Thanks!

Also, when I look at this page, I don’t see anything that sounds like getting Alexa to make a specific TTS based on a particular sensor event. As I asked, please tell me where it talks about it. Doesn’t look like it can to me, but I’m completely new to it. Thanks.

Yes, you can subscribe to as many attributes and Things as you want in SharpTools and then set the filters in the 'Thing State’s event plugin to only trigger for Things and Attributes that match your criteria.

And in cases where the filters might still be too broad for your needs (for example, the devices have very different names), you can use conditional logic in the Tasker task to determine if the event should be triggered. Since you have things like the device name, attribute name, and attribute value as parameters, it makes it easy to setup conditional logic in Tasker to only trigger as you desire.

I’m mobile at the moment, so this post is a bit brief, but let me know if you need more details.

1 Like

ahhh, ok… I see what you’re thinking… Echo’s, Dot’s, Taps… you can NOT push a message to those devices. You can use those devices with this app to push messages to remote speakers, not other Alexa enabled devices.

for what you are wanting, the app can push messages based on the motion input… but only to remote speakers.

That’s why the page doesn’t say that you can do that… because you can’t.

Okay, thanks for the clarification, man. EchoSistant looks really cool for what it can do. But like many say, Echo is actually extremely selective on what it can and can’t do. Some have called it a glorified remote. Anyway, thanks very much for speaking up so things are clear. It’s all part of a process of the community learning what can and can’t be done.

If I’m not belaboring the point, if you go back and look at what I said about the landing page, I was not talking about the wiki landing page, I was talking about your landing page - the one that the link you provided brings one to, first.

Please reread what I wrote carefully.

Ultimately I am making a very small point which will only need a very small fix, but then all will be clear to neophytes. So please consider it.

As I learned in grad school, anybody that is giving constructive advice is improving your product for free and showing you other viewpoints. If one person speaks up, probably another hundred wanted that, too.

Anyway. Thanks for your nice app! :blush:

I gotcha… When you said landing page, the wiki page comes to mind first… not the thread link.

I’m assuming you read the entire first post in that thread link. It directs you to the wiki for full information about the app.

I’m not trying to bee obtuse, and I fully appreciate constructive criticism, so I’m trying to make sure we are on the same page.

In one of your posts above you link to the wiki, but not the beginning of the wiki, so that could be confusing yes.

In the first post if my release thread is the link to the beginning of the wiki.

Just an fyi, that wiki is not completed. It seems it never is. But what is there is the result of about 20 plus hours of work… So I tend to not repeat things in the release threads.

And with version four having been in work since the day of the last release (mind you there are two of us working this project) there are multiple hundreds of hours in he app and I get to overhaul the wiki.

But, your point is clear… I will definitely ensure that anyone reading it is well informed that a message can not be pushed to an Alexa device.

Thanks

@Joshua_Lyon, is it possible to have SharpTools originate notifications which put a timestamp into the text of the message? Like “AMS4 - Motion in back yard at 3:01 am” or whatever.

ST notifications used to have timestamps in their text IIRC, then quit last summer or so. I really miss it because sometimes my notifications are greatly delayed. That’s a whole nother ball of wax I am looking into, but the fact remains, it would be great if ST notifications had timestamps in them. Then you could see at a glance if some important event really did just happen (run see who’s in the lawn!) or it’s from 3 hours ago. Now, if I want to know, I have to root around for 30-60 seconds to bring up the device and see its Recent history. Every time it happens, sigh.

.

P.S. Is there a main SharpTools thread somewhere where I might have asked this? I see a lot of forum messages on SharpTools, but don’t readily see one that looks like a main/general thread for general questions.

For those looking for other ways to play TTS notifications through external speakers - you can use the tasker AutoVoice plugin (https://joaoapps.com/autocast/) to cast notifications through Chromecast audio, or any other chromecast enabled device.

SharpTools doesn’t currently expose the timestamp of the event origination. If you turn on debug notifications, you can see the full payload the SharpTools receives from the push events:

SharpTools currently exposes all of these except for the location ID… and in SharpTools 3.0 BETA I’ve added the Location ID and Location Name as variables as well (%st_location_id and %st_location_name).

Unfortunately, it sounds like the timestamp of when the message is received by your device won’t work for you… I’ll take a look at adding the event origination timestamp, but I believe it will require modifying the SmartApp itself which would require approval by SmartThings. I would note that the initial submission of the SharpTools SmartApp took SmartThings 12 months to fully approve, so I try to avoid modifying the SmartApp wherever possible!

As crazy as it may seem, I’ve never created a thread for SharpTools. :stuck_out_tongue: You took the right approach though - tag me and I’d be happy to respond!

Hi @joshua_lyon I’m using sharptools with tasker and secure settings to turn my tablets screen off when my goodnight routine runs and it works great.
I’ve also set it up to wake my screen in the morning when my routine “Morning routine” runs but it never turns the screen on when it runs.
But the thing is if I create a new routine called “test” and use the same settings it will turn the screen on when I run the routine.
I’ve tried unsubscribing to the routines and subscribing again but still the same.
You any ideas.
Cheers

What’s the difference between the profile for the Morning Routine and the Test routine? Is it literally the same Tasker profile with just the routine name changed?

Can you share an export of your relevant Tasker profiles?

Thanks for the reply.
Yeah all I’m doing is literally changing the name of the routine in task edit.
The morning routine just turns 3 lamps on and the test routine is blank.
Here’s the export

Profile: Morning Routine (9)
Event: Routine Executed [ Configuration:Active for ALL Routine Executions
]
Enter: Turn Screen On (8)
A1: Secure Settings [ Configuration:Screen & Keyboard Lights On
3 Seconds Timeout (Seconds):0 ] If [ %st_routine ~ morning routine ]

Hiya
It’s just started working lol
I was just testing it again after doing the export and it just started working this time :joy:
Tried that loads yesterday but wouldn’t have it.
Sorry about that

Thanks for the update. Glad it’s working for you!

If you have trouble in the future, you can enable the Push Event Debug Notifications and you’ll be able to see the value SharpTools is receiving from Smart things. It’s often helpful to find discrepancies with names, etc.

1 Like