What tasks do you automate with Tasker?

I don’t mind sharing here in case someone else is interested. It’s nothing too fancy.

Going to sleep

  • I say, “Hey Google, good night” to my bedside Google Mini
  • IFTTT triggers my “Good night routine”, which sends a notification to the IFTTT app on my phone
  • Tasker sees the notification, deletes it, turns on sleep tracking via the Sleep As Android plugin, and enables my “Weekday Wake-up” Tasker profile.

If Tasker could detect state changes via the openHAB app/plugin, then I could remove IFTTT from this workflow.

Waking up

  • Sleep as Android alarm goes off, triggering the “Sleep Alarm started” intent in my “Weekday Wake-up” profile. It also checks that it’s a weekday and my phone is connected to my home wifi (translation: I’m not away and I probably have to go to work).
  • The “Weekday Wake-up” profile is disabled (to prevent it from triggering again after I snooze the alarm).
  • Tasker plays a wave file I recorded on my phone, which announces “Hey Google, good morning”. That triggers Google Assistant to start casting a TuneIn radio station to my Chromecasts and turn on the bedside light.

The last bit seemed like the easiest way to get Tasker to send a command to Google Home, though it remains a bit weird waking up to my own voice. There are AutoApps to do it, but this method is simple and reliable.

I would love if Sleep as Android could trigger openHAB, and openHAB could start casting TuneIn to my Chromecast group. But from everything I’ve read, we’re not there yet.

I did this in a pretty “quick and dirty” way. I have a variable named %RLK_TOD (I put RLK in front of all my variables to make them easier to find in the list). I have a separate Profile for each time of day. So for example Morning State is from 6:01 am - 11:00 am. I only have an entrance Task for the profile and all it does is set %RLK_TOD to MORNING.

Repeat for the other times of day you care about.

(Yep, working from home today :smiley: )

If Tasker would let you have a Profile without a task I wouldn’t even need the variable and could just check to see if the Morning State Profile is active.

Not really but I’ll be happy to answer any questions you have or provide any details explaining how I did anything. I think most of my tasks are shareable too. I’ve only account name and passwords in a couple of places and variables don’t get shared when using the built in sharing function. If you think it’s too off topic for here I’ll happily reply via PM.

I use AutoLocation which works a little better than the Tasker built in geofencing, though to be honest it has been years since I’ve tried the built in stuff. When I last used any geofencing or location based attempts at presence detection (OwnTracks, Tasker, IFTTT) they were all too slow to do arrival detection. And I had to make the geofence larger than I would like to use for actual presence detection (if I’m two or three houses down, should OH really think I’m home?). So I don’t use them and instead rely on WiFi. But with Tasker, you can detect if a SSID is nearby (or AP MAC address if you want that added bit of specificity) and get a much faster and much tighter detection which is fast enough to be used for arrival detection.

Once you’ve detected arrival you’ve basically solved presence so I don’t see the use of GPS based presence. Maybe the GPS apps are better now.

That is my intention too.
I am currently turning on the radio with the “smart mode intent” which gets executed a while before the alarm goes off.
With this trigger i am turning on the radio and increase the volume in smooth steps every 5 minutes.

At least this is the plan, but it doesn’t seem to work stable sometimes.
I am still investigating whats wrong.
(The problem is that i am sleeping most of the time i could debug that in a live environment.:smiley: )

I would love to get the smart alarm event into openHAB and do radio/wakeUpLights all within rules afterwards.
That would be really neat.

I don’t know about you, but there are a few times when I’ve woken up confused because the wake-up routine hasn’t triggered for some reason. I know something’s not right, but I’m too dopey to go beyond that thought.

I live in a condo building, so before I set up OH I tried using Tasker to detect my GPS location when I turned off my car, which would then turn on my house lights in the evening. It was too slow, so I switched to using SSID detection in Tasker and that was marginally better (but still unreliable). Now that I have OH, I’m just triggering the lights when I unlock my door.

So, if you don’t want to wait for the updates to the app, you can do this using OH’s REST API from tasker. That is how I control my garage door opener. Here is an experimental task I shared awhile back showing how to do this.

https://taskernet.com/shares/?user=AS35m8kUuK3OLwOeerzwoTliAX%2B%2FTPWRXm474S3LSRumiYN32eEodwHjMBursvN2IFK1&id=Task%3ASend+Command+to+openHAB

The description tells you what variables you need to set up to use it.

NOTE: The URL will only work if opened from an Android device. If you want it to work when your phone is not on your LAN, use myopenhab.org for the URL.

There is more discussion and ideas in

It will be a lot better to have real integration but we don’t have to wait. Just note that there can be a noticeable delay, particularly when going through myopenhab.org.

1 Like

That’s nothing the openHAB app and a server side rule could do now :slight_smile: Android App | openHAB

rule "Alarm Trigger"
when
    Time cron "*/10 * * * * ?" // Every 10 seconds
then
    if (AlarmClock.state as Number == 0) {
        // Alarm is turned off
        return;
    }
    val diff = AlarmClock.state as Number - now().millis
    if (diff <= 300000) {
        // Turn on stuff 5 min before alarm goes off
        Radio.sendCommand(ON)
    }
    if (diff <= 15000) {
        // Turn on stuff, e.g. radio or light
        logInfo('AlarmLogger', 'Turn on light')
        Light.sendCommand(ON)
    }

end

The alarm time is sent when the alarm changes. So you could set up the alarm and turn off the phone. openHAB still wakes you up the next morning.

1 Like

I don’t think (but I’m not certain) that Sleep As Android alarm times are synchronized with the Android alarm clock, in which case the OH app wouldn’t be able to pass them to the server.

Also, I’m guessing that by “smart mode intent”, @Confectrician meant Sleep as Android’s “Smart Period”. It’s a 45-minute period before your alarm during which the app will attempt to detect the best time to wake you. If you’re sound asleep, it won’t wake you until the alarm time. Otherwise, it’ll go off sometime in that 45 minutes when Sleep As Android thinks you’re almost awake. An OH plugin for Tasker would be perfect for this scenario.

1 Like

I also use sleep as android, and had it integrated with tasker, and had it send the alarm time to domoticz (before I switched to OpenHab) every night.
And then I had lights come up in that 30min period before the alarm, which helps me a lot with waking up. It was important to me to skip this waking up routine when the alarm is off.

Then if I have the alarm set at 8:00 with 30min “smart period”, lights would come on gradually at 7:30, increase every few minutes and then Sleep as Android would wake me in the perfect minute when I am most awake.
And it was so precise I was almost intimidated by it, as I would be half dreaming about waking up, and in that very second the app would wake me up. I cannot recommend the app enough to friends and family (you need to sleep with your phone for it to work, but its fine with me).

Also would like a way to send some commands to the app from the tasker, either a plugin or some other “simple” way, maybe better documented intents or whatever.

I use MQTT Client plugin for tasker to send mqtt message to OpenHAB. I was a total mqtt noob when I set this up, never did mqtt in OpenHAB before, stumbled thru the set up, got it working and then set tasker up to send mqtt messages.

I’m pretty sure you can send message in both directions

hey, i am a beginner here and was looking for the same. thanks all for your responses. it was helpful for me.
best regards!

The openHAB app makes use of AlarmManager: https://developer.android.com/reference/android/app/AlarmManager.html

This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future.

AlarmManager is the way to set up alarms, so I guess Sleep as Android uses this API. Smart Period is something non-standard, so I guess this won’t work.

You are fully right, i have tested it.

That should be no problem in my usecase.
I needed a time before the alarm goes off and this was the solution so far.
When openHAB knows about the time the alarm will go off, i can build my own smart period. :slight_smile:

So can start doing some wake up stuff in openHAB now.

Anyways:
Tasker can fetch somemore stuff from sleep as android, so i am sure that i will find additional usecases for a sleep as android to openHAB bridge with a OH Tasker plugin. :slight_smile:

Correct me if I’m wrong, but this pretty much assumes only one user can have an alarm that OH will react to. For example, if you have a couple who work different shifts they might have vastly different alarm times and might also have different routines. But if I set up this AlarmClock Item there will be no way to distinguish between the two. Only the latest one to have been changed will end up in AlarmClock.

If I’m correct, Tasker integration could be a way to manage this use case.

You can configure the item name that is used within the app, so you could easily add an item per person you want to watch the alarm clock.

Of course you would have to implement a logic, that decides which alarm clock should be used for a possible wake up logic.

I could not find a setting for that anywhere. Is this a feature not yet released outside of beta? I’m currently running 2.6.9 which is the latest version I see in the play store.

Being able to configure the Item name indeed would allow for the handling of different users.

Maybe I need to get on the beta channel for the Android app.

1 Like

Correct. It’s a Feature of the beta app.

2 Likes

It’s not available in the stable version yet. You can add an item name prefix, e.g. “Rich” => “RichAlarmClock”. If we add other things to upload, e.g. battery state, you don’t need to change the item name itself.

3 Likes

Cool, I’ll have to give this some thought. Thanks for investigating it while I was asleep, folks!

I would be interested in the day of week logic. I am digging into it currently.