What tasks do you automate with Tasker?

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.

It’s pretty simple as I only need a work day flag so I have a profile using the Day state and selected Mon-Friday. The entry task sets %RLK_WORKDAY and the exit unsets this variable. If you need something more interesting you should be able to create additional profiles for each day type and create a DOW variable that get’s set like the time of day.

I’ve shared the time of day and work day profiles: https://taskernet.com/shares/?user=AS35m8kUuK3OLwOeerzwoTliAX%2B%2FTPWRXm474S3LSRumiYN32eEodwHjMBursvN2IFK1&id=Profile%3AWork+Day+State

1 Like

Yes, i am looking for a bit more logic for my case.
I am wokring on fridays only until noon, so i will have to split the friday.

Week and weekend should be straight forward and i already used the way you described.
Thanks for the reply and for the share anyways. :slight_smile: