iCalendar for presence simulation

I want to implement a presence simulation function with OpenHAB. Therefore I created a Google Calendar with events to turn certain lights on specific dates and times on and off. This works in general fine with the binding iCalendar: It reads the Google Calendar and light is turned on and off as configured.
But now I only want to activate this, when I am on holidays and nobody is at home. So I am searching for a Switch to turn ICalendar off, if I want to. How can I do that?

Sidenote: With OpenHab 2 I successfully used gcal. There I could use: Switch PresenceSimulation. Unfortunately this binding isn’t compatible with OH 3/4…

Note that there is a rule template on the marketplace that does this using persistence. It plays back the states of the Items you choose based on what state they were in x number if days ago. What’s better than minicing the lights based on actual recorded behavior? 7 days works well since changes based on the weekend get mimiced too.

You can add a rule condition to only run when your presence Item or what ever switch you want is OFF.

If you are using a rule for this you can use a rule condition (UI rules), an if statement, or a separate set of rules that enable/disabled the simulation rule based on the state of the Switch Item.

You’re not going to find an easy way to disable the iCal Thing yourself but it’s not impossible. That too will need a rule and as long as you are not using Rules DSL (which I’m pretty sure doesn’t have access to the ThingRegistry) to enable/disable the Thing through the API. In JS Scripting it’s a one liner:

things.getThing("thing:UID").set enabled(false);
1 Like

That’s even easier, assuming you are using the presence state as trigger for your rule:

Add a switch item named like “on_vacation” through the UI or a things file and do not link it with a thing/channel. Now you can use it as a virtual switch and add its state as condition to your rule. Just ensure the switch is getting persisted somehow (default mapdb is fine), so the vacation mode doesn’t get lost when restarting your OH instance.