Timestamp minus 2 minutes to trigger an action (Automower, garage door)

Hello experts! I´m struggeling with a rule and handling DateTime items!

My automower is providing an Item PlannerNextStart. At the moment the items state is “2024-03-27T08:00:00.000+0100”.

I want to write a rule that opens my automowers garage door 2 minutes before the mower starts to mow. How to calculate this minus 2 minutes? I really can´t make any progress as this is my first attempt to calculate with DateTime items!

Thank you!

Br,
Mario

Is PlannerNextStart a DateTime item?

Which rule language are you using?

General tip (there are many ways of doing this… but I’m giving you the simpler method I think)

  • Create a virtual DateTime item called OpenMowerDoorTime, with timestamp-offset profile.

Example with .items file:

DateTime OpenMowerDoorTime { channel="same:channel:as:PlannerNextStart" [ profile="timestamp-offset", offset=-180 ] }
  • Create a DateTime trigger based on OpenMowerDoorTime item and in the rule action, do what you need to open the door.

Can the automower be started from openHAB, or does it have to be scheduled in the proprietary app?

If you can start it from openHAB, then you can have all of the logic in one place (rather than split between two different systems. Your rule would be triggered at the times you define, open the garage door, and then start the automower.

The main benefit of this is that OH can make sure the door is open before starting the automower. Otherwise, you could have a scenario where your OH server is offline and doesn’t open the door. Your automower isn’t going to know that, though I assume it’s smart enough to not run into the door.

Exactly. I´m using RuleDSL.

Thanks for that hint! I will give it a try.

Yes I can start is from OH directly as well. That´s coming up next.
Thanks for your input! Much appreciated.

So I adopted my items and rules - tomorrow I will see if it works!

Items:


DateTime PlannerNextStart "Next auto start" {channel="automower:automower:f8642d1ea1:planner-next-start"}
DateTime OpenMowerDoorTime { channel="automower:automower:f8642d1ea1:planner-next-start" [ profile="timestamp-offset", offset=-120 ] }

My Rule:

rule "Open Garage door for mower"

when Time is OpenMowerDoorTime timeOnly

then 

Shelly_MowerGarageDoor.sendCommand(0)

end

Never used trigger “Time is” to trigger a rule! Hope it works.

Can you put when and Time in one line like that? I thought you’d need to put when on its own line

with my automower, I only get the variables after polling the api. You want it to push that message, is that changed or different for your API?

edit: I see there’s a websocket event option, cool! learned already something today :wink:

1 Like

I guess you are right. In Visual Studio Code the color for “timeOnly” was the same like for the item.
I moved it into the next row and now its colored white.

when Time is Automower_OpenMowerDoorTime 
timeOnly

Ok the offset calculation is working fine. But I realized that the timezone is obviously wrong? Next start says 10:32, Garage Door Item says 10:30 - but it´s +1h ahead! It should be 09:30 instead.

The timezon is setup correctly in the regional settings for openhab. Any idea how to fix this? I tried offset 3720 (so 1 hour + 2 minutes) which didn´t work at all.

I found this topic here: How to correctly format datetimeoffset in item? - #6 by rossko57

Guess I´m not the only one having this problem…

Short update: The offset is working correctly now - it says: 2024-03-29T06:58:00.000+0100

Next start in the Automower App says 29th of March, 07:00 AM. I will update this one here if the trigger is working as expected - I hope it does!

Thanks for your support!

What’s its time zone though? If it’s also +1h ahead, then I think it should be fine. Your rule will still trigger at the correct instant (I think)

Short update: The trigger is working but it get´s executed every day. My mower is not mowing every day but every second! So I guess this is because of the “timeOnly”.
I will remove it and try again.

@JimT The trigger wasn´t working without calculating the offset manually. Anyhow I´m close to finish my rule. Thank you