Alarm Clock / Morning Routine - setting time

Hello,

I want to have an alarm clock in Openhab. I use the current stable OH4.

I want to set a time (for instance 06:30), and on every working day I want OH to start the morning routine (slowly dim light, play music on speaker…)
(Note: I do NOT want to sync my android alarms to openhab)

What is the best way to do that?

How can I set a Time via Pages widget? I somehow can only set seconds…

Thanks
Daniel

There’s a bunch of possibilities to achieve that.
the easiest for starters would be:

  1. create a rule (Rules - Basic | openHAB)
  2. chose as a “add trigger” then a “time event” and select 06:30
  3. chose as “add action” and “Item Action” to set your items to your liking

From that work to slowly add more “spice” to it, like creating a “Scene” (Rules - Scenes | openHAB) and starting that, or add a script in your rule (perhaps with Blockly Rules - Blockly | openHAB)…

or even do that and change the “06:30” preset every day to a custom time after working late… :wink:

@binderth’s approach is solid and will work. However I think it’s better to use a DateTime Item instead.

Use a DateTime Item.

Then create “default X widget” metadata using an input widget and set the “type” to “time”.

For example:

value: oh-input-card
config:
  outline: true
  clearButton: true
  inputmode: text
  footer: =items.Default_Bed.displayState
  placeholder: hh:mm:ss
  calendarParams:
    dateFormat:
      hour: numeric
      minute: numeric
    timePicker: true
  title: Default Bed time
  type: time
  sendButton: true

or as a List Item card:

value: oh-input-item
config:
  outline: true
  inputmode: text
  subtitle: =items["Default_Bed"].state
  placeholder: =items[props.item].state
  title: Default Bed Time
  type: time
  sendButton: true

These both will give a nice time picker widget when clicked on.

Note, there was an issue with time for the input widget type in 4.0 so you might need to use the latest 4.1 milestone (or the release which is happening next week I think) for this to work I think.

You can use a Time Event trigger with “at time specified in the state of an item” and toggle “time only” so it ignores the date to trigger the rule. Configure Ephemeris to define the weekends/workdays and use an Ephemeris Schedule condition so the rule only runs on work days.

This approach lets non-admin users change the time of the alarm through MainUI or gives you the option to populate the alarm time from some other source if you want (iCal, Andorid alarm, etc.). Something personal like an alarm time is something that should be exposed to end users, not just admin users.

I don’t think a scene will work well for this. @Daniel_Hermann1 wants to gradually increase the brightness over time and a Scene isn’t going to be able to handle that. But definitely look at Simulate Sunrise for how to do the gradual bring up or down the brightness on a light. It’s a good place to start at least.

1 Like

@rlkoshak

I copied your code, unfortunately I am missing the confirm checkmark.

I can now pick a time in the Input card, however I cannot save/confirm it?

openHAB 4.1.0.M5

Screenshot 2023-12-21 073914

Watch the logs. I believe it commands the Item once a time is selected when there isn’t a check mark icon.

Note that this is all rendered by the browser and each browser looks and works slightly differently. The screen shots above are Brave Browser but they should look similar in most webkit based browsers. Firefox looks and works differently.

That’s the parameter that causes the checkmark icon to appear. The fact that you don’t have the current state of the Item appearing in the footer makes me thing you didn’t copy the whole YAML from above or introduced some syntax error.

Instead of copy and paste, just enter the parameters yourself in the form. The main thing that matters is that “Type” is “time” and “Input Mode” is “text”. Everything else is an optional parameter you can set how ever you want.

All I can do is recommend experimenting and see what happens.