NEW: Home assistant alarm clock UI

I have been wanting for a long time now to have the ability to control all my various alarm clocks from HA, using a nice UI, and to make Alexa turn on the proper alarm every night when I go to bed.

To achieve that I have created a neat Node-Red integration (heavily based on node-red-contrib-ui-time-scheduler):

Which provides a persistent alarm clock schedule with a simple but strong UI using node-red dashboard.

tip

If you want to show the node red dashboard in your supervised instance, use the following addon -

Here is the final result:

Screenshot-20211029165048-320x277

And the function to build the alexa TTS command to add the alarm:

const alarmsObj = msg.data.upcoming || {};
const alarms = Object.keys(alarmsObj).map((alarm) => {
    return {
      name: alarm,
      epoch: alarmsObj[alarm]
    };
});
alarms.sort((a, b) => {
  return a.epoch - b.epoch;
});
const nextAlarm = alarms[0];
if (!nextAlarm) {
    msg.ignoreAlarm = 'true';
    return msg;
}
const timeUntilNextAlarm = nextAlarm.epoch - new Date().getTime();
if (timeUntilNextAlarm >= 24 * 60 * 60 * 1000) {
    msg.ignoreAlarm = 'true';
    return msg;
}
const nextAlarmDate = new Date(nextAlarm.epoch);
let hour = nextAlarmDate.getHours();
let partOfDay = 'AM';
if (hour > 12) {
    partOfDay = 'PM';
    hour = hour - 12;
}
let minutes = nextAlarmDate.getMinutes();
if (minutes < 10) {
    minutes = `0${minutes}`;
}
msg.alarmRequest = `set alarm for ${hour}:${minutes} ${partOfDay}`;
return msg;

Any feedback is welcome :slight_smile:

2 Likes

Hi, this looks like what I have been searching for. Would you mind sharing the code for your flow?
(specifically the Set alarm node!)

image

Sure:

[
  {
    "id": "92dc3bd5b3d938aa",
    "type": "api-call-service",
    "z": "95447d80d70ddec7",
    "name": "Set alarm",
    "server": "5158330a.2c99cc",
    "version": 3,
    "debugenabled": false,
    "service_domain": "media_player",
    "service": "play_media",
    "entityId": "media_player.echo",
    "data": "{\t   \"media_content_id\": msg.alarmRequest,\t   \"media_content_type\": \"custom\"\t}",
    "dataType": "jsonata",
    "mergecontext": "",
    "mustacheAltTags": false,
    "outputProperties": [],
    "queue": "none",
    "x": 960,
    "y": 1320,
    "wires": [
      []
    ]
  }
]
1 Like

Thank you!

1 Like

Hi
Is it possible to get full code
Thanks in advance

1 Like

@ regevbr i try to import the flow but in my manager palette cant find palette ui_alarm_clock to instaled and the flow wont run without it
Any suggestion why not come up in my manager palette
i have node-red-dashboard v 3.6.5