Trigger rule via datetime item

Dear all,
i do have a datetime item of my next upcoming amazon echo alarm.
At the time of the alarm i want to trigger a sunrise light routine rule.
However, i dont know how to fire the rule at the value time of the datetime item (2021-10-26T06:15:00.000+0200).

Can someone give me a hint?
Do i need an additional rule for that?

Thank you a lot!

I have a rule (ECMA) that triggers on each change of the next alarm in order to switch on my hotwater.

var logger = Java.type(‘org.slf4j.LoggerFactory’).getLogger(‘org.openhab.rule.’ + ctx.ruleUID);
var ScriptExecution = Java.type(“org.openhab.core.model.script.actions.ScriptExecution”);
var ZonedDateTime = Java.type(“java.time.ZonedDateTime”);
var ZoneId = Java.type(“java.time.ZoneId”);
var Instant=Java.type(“java.time.Instant”);
= (this.OPENHAB_CONF === undefined) ? java.lang.System.getenv(“OPENHAB_CONF”) : this.OPENHAB_CONF;
//var Exec = Java.type(“org.openhab.core.model.script.actions.Exec”);
//var timerAlarm;
this.timerAlarm = (this.timerAlarm === undefined) ? null: this.timerAlarm;
var AlarmTime =items[‘NaechsterAlarm’];
//var WarmWasserSollTemperature = items[‘WarmWasserSollTemperatur’];“AlarmTime: {}”, AlarmTime);
try {
if (AlarmTime == UNDEF) {
if (this.timerAlarm != undefined) {
this.timerAlarm = undefined;
events.postUpdate(‘Naechster_Alarm’,UNDEF);“All alarms are canceled”);
} else {
var epoch = AlarmTime - 600000; // 10 Minuten vorher!!"Scheduling Alarm for: "+ epoch);
var zdt=Instant.ofEpochMilli(epoch).atZone(ZoneId.systemDefault()); ("Converted AlarmTime: " + zdt);
if (timerAlarm !== null) {“Reschedule Alarm”);
} else {“New Alarm”);
this.timerAlarm = ScriptExecution.createTimer(zdt, function(){
if (itemRegistry.getItem(‘ActiveMode’).getState()!=“standby”) {
if (itemRegistry.getItem(‘DhwPumpsCirculation’).getState()==“off”) {
var HTTP=Java.type(“org.openhab.core.model.script.actions.HTTP”);
var client_id = “cca64a97484842923a3d05b52325da8e”;
var installationID=“137038”;
var gatewaySerial=“7571381700298105”;
var token=items[“Viessmann_Token”];
//“token: {}”,token);
var headers = ;
headers[“Authorization”] = “Bearer “+ token;
var url =“”+ installationID +”/gateways/” +gatewaySerial + “/devices/0/features/heating.dhw.oneTimeCharge/commands/activate”;
//“url: {}”, url);
var returnvalue = HTTP.sendHttpPostRequest(url,“application/json”, “{}”,headers,10*1000);“returnvalue: {}”,returnvalue);
} else {“Umwälzpume ist an, also wird Warmwasser schon erzeugt!”);
} else {“Anlage ist im StandBy, Warmwasser wird nicht erzeugt!”);
}“Alarm is expired”);
this.timerAlarm = null;
catch(e) {"Error observed : " + e.getMessage);

Yes you do need a rule for that. Trigger the rule when the DateTime Item changes and schedule a timer to run at the time in the DateTime Item.

If on a recent version (3.2 M3 or later) you can install just such a rule from the Marketplace.

You don’t need to code this yourself.

1 Like