Use Homey to set or delete an alarm on Android and start a flow when the alarm rings

Hi everybody,

Can someone put me in the right direction?

I have a logic variabele with a day ‘monday’ and one with a time ‘12:00’. I want a flow to start when it is currently that time and day.

Another way to achieve what I want is to make a flow to set an alarm in Homey when those logic variables are set or changed.

Soms background information:

I use Tasker with AutoAlarm to check for my next Android native clock alarm, and then sent the time and day of that alarm to Homey via a webhook and put it in a logic variabele.

Thanks in advance.

If you are willing to install HomeyScript you could do something like this:

// for testing purposes
if (args == null || args.length === 0) {
  args = ['thursday,13:00,13:00'];
}

const [day, time, currentTime] = args[0].split(',');
const card = await Homey.flow.getFlowCardCondition({
  uri: 'homey:manager:cron',
  id: 'day_equals',
})

const possibleValues = card.args[0].values;
const dayToCheckAgainstArg = possibleValues.find((value) => {
  return value.title.toLowerCase() === day.toLowerCase();
});

const { result } = await Homey.flow.runFlowCardCondition({
  uri: card.uri,
  id: card.id,
  args: {
    // id is daynumber, weekday or weekend 
    day: dayToCheckAgainstArg.id
  }
});

// is the day correct and are the timestamps equal
const returnValue = result && time === currentTime;
console.log(returnValue);
return returnValue;``

You just have to replace thursday and 22:43 with whatever is in the logic tokens you got from the webhooks. You also have to decide about the precision of the timers since this will only work with times divideable by 5 minutes. This also assumes your Homey is on English btw.

Did not really test this thoroughly but just an idea.

1 Like

It’s been a while since I last messed with Tasker, but isn’t it possible to calculate the seconds/minutes until next alarm and send that data to Homey? With that, you should be able to set a timer with Chronograph or similar app.

I can imagine you could do it all on the Homey with a few flows and using a lot of MathJS expressions. Or use Homeyscript to convert the day/time to ‘in x minutes’ format. It seems like a fun experiment.

1 Like

Thank you very much for your detailed reply! There are only two drawbacks to your proposal for me:

  • The first is that I have no experience with HomeyScript.

  • The second is that it seems very unnecessary to perform a check every 5 minutes. The flow should just start at the time that is already known.

1 Like

I got it done!

  • If an alarm clock is set or adjusted in the standard clock app of an Android device, the time and day are also set in a Logic variable in Homey. Homey then shows me a notification to confirm my new alarm.

  • When the alarm goes off, a flow will automaticly start in Homey.

  • You can use flows to set a new alarm in your standard clock app or delete an existing one based on the time or the name of the alarm clock.

What do you need to get this working?

  • Tasker
  • AutoTools (optional; to calculate the time your alarm will go off minus the given offset in minutes)
  • AutoRemote (for communicating with Homey through webhooks)
  • AutoAlarm (to retrieve your next alarm in your standard clock app)

You can import the Tasker project via the following link:
https://taskernet.com/shares/?user=AS35m8nRu3giFYRoZD%2FtlU%2FAiDGJ4EVpkHarD4YYCfgV6RGlYmqS18YfvC%2BhOmFLQsaG69lY%2BRg%3D&id=Project%3AHomeyAlarm

All the needed flows:

Example flows to test your setup:

Logic Variables to add:

NextAlarmTime - Null
NextAlarmDay - Null
NewAlarmTime - Null
NewAlarmName - Null
DisableAlarmName - Null
DisableAlarmTime - Null
AutoRemotePassword - PASSWORD
AutoRemoteKey - KEY

Feel free to ask questions if you need help getting this working!

4 Likes

That sounds very good!
Tasker is not the most intuitive app, so thank for this how-to.
However, I do not see the forest because of the trees (as we say in Dutch :wink:)…

I only need a way to automatically have a alarm (“wekker”) set in Homey when adding a new alarm or changing an existing one. Preferably only when it is labeled “WakeUp” (or something like that).
What would I need then?
Would I need a way to delete the alarm in Homey too, so there won’t be a whole list of alarma created there?

It is not possible to add new alarms in Homey itself using flows. You can only use the ones you allready configured yourself in the Homey app.

That’s why I use Tasker to detect when an alarm goes off on my phone and then start a flow that way.

I don’t use the build in alarm in Homey because of those limitations.