Rule: Start Action with Alexa Alarm

Hi, I try to crate a rule that switches on the external speaker of my Echo Dot when an alarm, or timer is active.

OpenHab V2.5

example Script what I tried:
explanation of the items
LokaleZeit_DatumUndZeit = Item with aktual Date and Time
ChristophsEchoDot_NChsterTimer = Next alram Date and Time of Echo
A_Tageslicht = Test Actor (light)

rule “AlexaBoxen”
Item LokaleZeit_DatumUndZeit changed to ChristophsEchoDot_NChsterTimer
sendCommand(A_Tageslicht , ON)

Maybe someone has i Idea how to solve that issue.
Thank you.

You cannot do that, a complex evaluation in the ‘when’ clause; only constants.

So presuming that both Items are variable, you could trigger your rule from one of them changing and do a comparison in the ‘then’ section of the rule with if()

Note that will not run at any particular time. Are you trying to do something when some particular time comes around?

You might find this hread helpful

Hi, I have following situation:
An Echo Dot is connected to an external surround system from Yamaha.
When there is no Signal for 20min, the speaker will switch off.
Menes, when an alarm or an time rings I can not here it.

The script should switch on the speaker and change to the Input channel of the echo dot.

Al Items are working but I have now Idea how to create the rule.

I’m using already that Binding and I can see all values in the created thing :slight_smile:

That’s nice. Read that whole thread to see how to set up a rule from Alexa alarm time that sets up a timer to run at the given time.

I had read that, but the rule examples do not fit my situation. Is it not possible to compare two values in an If?


The command is working, when I use for example an switch, the test light switches on.

@ rossko57
Ok, I thought you meant the Link in the treat about the binding, now I had seen that there is in the top also the link to the topic.

Of course. Have you tried?

1 Like

Only with that both Date and Time values, But i can try it for example with two volume level values, there are not many Signals that are not just bool that i have in my OpenHab.

Well, I’m not writing it for you.

First, plan what you want to do.
That seems to be to run a rule every minute, and to see if the “alarm time” is past yet.
I think that is the wrong approach, but it will work.

So, create a rule that runs every minute.
Then find out how to use if() to compare “now” with a DateTime type item.
Remember not to see if it is equal - it never will be in milliseconds.
Test to see if now > alarm

Here’s a useful resource

There is the problem that the “Next Timer” Item gets an value of “-” when the alarm is ringing and there is no other timer.

Okay, what do you need to do about that?

The Idea that I had with that was to switch on the light before the alrm starts but there is still the problem with the comparison. The deactivated line works.

rule “AlexaBoxen”
Item LokaleZeit_DatumUndZeit received update
if((Item ChristophsEchoDot_NChsterTimer) < (now.plusSeconds(90))) sendCommand(A_Tageslicht , ON)
//if(true) sendCommand(A_Tageslicht , ON)

Please use code fences when posting code in this forum.

This is nonsense syntax.

You do not need the keyword Item outside of the ‘when’ trigger section.

ChristophsEchoDot_NChsterTimer is the whole Item object - with properties for label, group memberships, type etc. That cannot be compared with a datetime.
Usually you would be interested in its state property

The next problem you will come up against is that a DateTime type Item is not in the same format as the special variable now
This is explained in the DateTime conversion thread I pointed out.

Ok, Ill give up.
Main Problems:

  • Language barrier, I’m not a English person, so it’s hard to understand all the documentary.
  • I’m an PLC Programmer, in PLC Programming you are working very close with the Hardware, mostly direct with bit manipulation and there i can see all values during debugging in real time. I can see when I’m doing syntax errors. That is here not the case, I’m basically blind.

After nearly one night of reading different stuff I’m now just confused and give up. I understand you that you try to pull me in an specific direction but that does not help me, I have to find an example so that I can use this and edit the code for my use.
That night was just a waste of time.

In PLC Logic that is not an hard task, it’s strange that i should on in these language.

Try this, Christoph…

rule “AlexaBoxen”
    Item LokaleZeit_DatumUndZeit received update
    logInfo("Rules", "LokaleZeit_DatumUndZeit received update: {}", newState)
    if ((ChristophsEchoDot_NChsterTimer.state as DateTimeType).zonedDateTime.isBefore((new DateTimeType).zonedDateTime.plusSeconds(90))) {

Hi, thank you for that Code.
But it’s not working, where can I find the log what logInfo creates?