INTENT: Is it possible to change more than the "enabled" state for alarms or does ALARM_STATE_CHANGE have more extras?

361 views
Skip to first unread message

Eldorel

unread,
Sep 10, 2014, 10:46:23 PM9/10/14
to sleep-as...@googlegroups.com
Summary: I'm trying to figure out how to change either the time or the smart period setting on an alarm to account for a very erratic sleep schedule, or a way to remove alarms that are no longer needed.

I'm hoping that the Dev's have added more extras to com.urbandroid.sleep.alarmclock.ALARM_STATE_CHANGE that just havn't been added to the developer-api page...

Alternately, I'm open for suggestions on ways to mitigate the issue without ending up with 200 separate alarms that I have to delete by hand.

----
This is the end result I'm working the bugs out of.

I've been working on setting up an automated alarm system with Sleep as Android and tasker, and I've got most of it figured out thanks to the developer-api page. 

I have my phone programmed to setup an alarm to wake me up after 8 hours when I put it next to the bed, since I don't have a static schedule.
I am also able to automatically set a power nap up to trigger in 30 minutes by scanning an NFC tag next to my bed or at the office.

Additionally, I have a 5 minute power nap that is created whenever my office send me a service alert in the middle of the night.
    (I'm on-call most of the time, the idea is for the power nap to wake me on the next light sleep phase when there's a major problem at the office).

Unfortunately,  people have a habit of waking me up from naps and the on-call power nap alarms regularly cause me to skip my normal wake up alarm.
This results in my having a ton of alarms that are disabled before they get the chance to trigger and delete themselves, and they start to interfere with each other after a while.

So far, I've tried the following:

1) Setting up a Nap alarm and just enabling it with "com.urbandroid.sleep.alarmclock.ALARM_STATE_CHANGE"
        Result: the scheduled time doesn't change to reflect the current time.
        If I create a 30 minute nap at noon monday, and then reenable it at 2pm tuesday, the alarm is scheduled for 12:30 pm wednesday.
            (ideally the app should remember that "this was a 30 minute nap", and adjust the time when it is reenabled.)

2) Setting application defaults to match one alarm type, and then creating a new alarm via "android.intent.action.SET_ALARM"
        Result: Partially works, until I wake up before the alarm triggers and it gets disabled without getting to delete itself.
                This leaves an orphaned alarm which interferes with the next nap and having the defaults set makes it impossible to automatically create other types of alarm.

3) Using Joaomcg's autoalarm to identify orphaned alarms and use tasker to disable them, then just change the alarm label to include the date.
        Result: mostly corrects the issues with alarms interfering or remaining enabled, but it still conflicts with automatically creating other alarm types.

None of these options allow for me to automatically generate different types of alarm with different settings.


Possible solutions:
1) If I could adjust the times on existing alarms, I would be able to create one alarm for a full nights sleep and another for a nap, configure them completely, and just reuse them indefinitely.
2) If I could change the Smart period, I would be able to generate either type of alarm.


Other than that, I'm stumped.

Does anyone have any ideas?

Petr Nalevka

unread,
Sep 13, 2014, 10:34:52 AM9/13/14
to Andres Del Rio' Via Sleep As Android

Petr replied

Sep 13 16:34
Hello,

could you please provide more details on your use case. If you create alarms using some automation app they get a disposable flag so they are automatically delete after triggering - so no need to delete them later on. We currently don't have a feature which would allow to directly delete an alarm through automation.

Although you can use our exported content provider to delete alarms. Let me know if you like to get more feedback on this..

Thank you very much.

Best regards,

Petr Nalevka
Urbandroid Team

Conversation started by Andres Del Rio' Via Sleep As Android

Cc: sleep-as...@googlegroups.com

Sep 11 4:46
--
You received this message because you are subscribed to the Google Groups "Sleep as Android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sleep-as-an-dr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

{#HS:45288481-2085#}
Powered by Help Scout

Eldorel

unread,
Sep 15, 2014, 6:05:20 AM9/15/14
to sleep-as...@googlegroups.com
"Quick" summary.

I use tasker to automatically trigger sleep mode with several events. This task does the following steps.
        a) Set silent mode
        b) Set the %personalstate variable  to "sleeping" (for other tasks to trigger from)
        c) Trigger a vibration to my pebble smartwatch
        d) Start sleep tracking with "com.urbandroid.sleep.alarmclock.START_SLEEP_WEARABLE_TRACK" intent.
Currently, I am setting the alarms manually.

While the "%personalstate" variable is set to "sleeping", 2 phone calls from my office or a specially formatted email (or SMS) will trigger an alarm to wake me up.

When I wake up and get out of bed (or off of the couch at my office) a second profile automatically recognizes this. That task:
        a) Set the ringer and notification volume to normal
        b) Set the %personalstate variable  to "awake"
        c) triggers my "morning status update" tasks.
        d) Stop sleep tracking with "com.urbandroid.sleep.alarmclock.STOP_SLEEP_TRACK"

All of this works perfectly, but I can't effectively control the alarms automatically.

I'm trying to set different alarm settings for powernaps at work and sleeping at home, as well as use the powernap feature to try and wake up gently when the office needs me awake. (by creating a power nap while sleep tracking is already active with a 1 minute duration)

My goal is for tasker to automatically add (or enable) an alarm with the alarm time and settings based on when "Sleeping" mode is triggered and where I currently am, and have that alarm disabled if I get up before it triggers.

Planned Alarm settings:
        Home: Ideal sleep duration, loud (increasing) ringtone, 1 hour smart period.
        Work: 30 minute sleep duration, silent ringtone, power nap smart period.
        On-call: 45 minute duration, VERY LOUD (increasing) ringtone, power nap smart period.
        Emergency: 1 minute duration, VERY LOUD (increasing) ringtone, disabled smart period.

I can currently re-enable an existing alarm, but I can't change the time on it.
OR
I can create a new alarm, but it always uses the application default settings.

This means that I can either have the correct settings or the correct time, but not both.

The second problem is that alarms don't get to trigger when I am woken up early, and thus do not get the chance to automatically delete.
I would like to add a "remove alarm" loop to the wake tasks, so that the old alarms do not build up.

Note: I have figured out a way to do much of this using sqlite3 shell commands to modify the databases/alarms.db, but I know from experience that this is a BAD idea.

Petr Nalevka

unread,
Sep 30, 2014, 10:54:08 AM9/30/14
to Sleep as Android Googlegroup

Petr replied

Sep 30 16:53
Hello, sorry for the late response. There is a ContentProvider for alarms which allows to query, delete and update alarms. I don't know what is the state of COntentProviders automation, but it should work pretty well. If you think this is a viable option I can provide some documentation on how to use the provider - basically on the data model of the alarm DB...

Authority of the provider is com.urbandroid.sleep.alarmclock and path is "alarm"...


Thank you very much.

Best regards,

Petr Nalevka
Urbandroid Team

Sleep as Android Googlegroup replied

Cc: sleep-as...@googlegroups.com

Sep 15 12:05

Petr replied

Sep 13 16:34
Hello,

could you please provide more details on your use case. If you create alarms using some automation app they get a disposable flag so they are automatically delete after triggering - so no need to delete them later on. We currently don't have a feature which would allow to directly delete an alarm through automation.

Although you can use our exported content provider to delete alarms. Let me know if you like to get more feedback on this..

Thank you very much.

Best regards,

Petr Nalevka
Urbandroid Team

Conversation started by Sleep as Android Googlegroup

Cc: sleep-as...@googlegroups.com

Sep 11 4:46
Reply all
Reply to author
Forward
0 new messages