CalDAV Simple example to turn something ON and OFF?

Hi Martin,
I refer to 1.8.0 caldav binding.
The description is necessary, if you want to use the caldav.command.
In German:
Titel: "does not matter"
Ort: "does not matter"
Beginn: "time when action starts BEGIN-> e.g. activation of switch"
Ende: : "time when action ends END-> e.g. activation of switch"
Notizen: "where you put your commands like BEGIN:Switch:ON
END:Switch:OFF
Cheers
Björn
PS: Important that you chose the right calender in the IOS.

1 Like

Hi there,

Good converstion from you, that’s why I deleted the [solved] word from the title.

There are something in a wiki and I am right with you that it leads maybe to some misunderstoodings. But I cannot say neither how it should be written to get more easier to understood.

But anyway keep going guys!

I give up after having spend about 2 hours getting something to work without success.
Too bad.
Will use iFTTT and myopenhab instead.

[quote=“martin_klimke, post:16, topic:6586, full:true”]
… about 2 hours [/quote]

After that short period of time I’m starting to dig for problems … just kidding :yum:

Hi Martin,
can I help somehow?
Cheers Björn

@Börn,

Yes, if you could answer the questions in my posting above indicated by "->"
regards Martin

Hi Martin,
I’ll try my very best on basis what worked for me (after several hours of trial and error):

If you create an event in the calendar app of your choice synchronized via caldav with openHAB, you can via text lines in the description section “instruct” openHAB to carry out actions → commands. See here for i-phone entry:

The actual command in the calendar is the second part of “BEGIN:Thekenlicht:ON”, thus a command is send via the caldav binding to openHAB to put switch “Thekenlicht” to ON at start time of the calender entry (event). In your case: Put temperature to 22 of Heater_Livingroom.
Anyhow: in your items file of openHAB a corresponding item (in my case a switch “Thekenlicht” see post before) needs to be defined.

Yes. See answer before. The actual calender entry you are doing.

You “only” need to write in the calendar, as long as you have defined the corresponding items in your openHAB items file and configured the cfg file right (see also afore). This writing in the calendar then triggers a change in the openHAB item at the date and start time defined in your calendar entry.

You are right. This was misleading for me at first.

See afore: “BEGIN:Thekenlicht:ON” This line triggers the command of the item “Thekenlicht” to ON to be executed in openHAB.

I tried to give a detailed example in a post before (you do NOT need rules for that!):

In principle you are right. You define two items in your item file. One to visualize the events coming up (like this - however, having nothing to do with carrying out commands via your calendar event):
In items file:

String Event1 “Event1 [%s]” {caldavPersonal=“calendar:openhab type:EVENT eventNr:1 value:NAMEANDTIME”}

In sitemaps file:

Text item=Event1

And another you want to trigger (like this):

Switch Thekenlicht “Thekenlicht” (Licht, Kueche, Raeume) {rwe=“id=8b35bdf1-111f-4fdb-9e7e-159757e2c7f8,param=switch”}

The statement "caldavCommand=“itemName: type:” means only that you can introduce a switch in your openHAB setup which allows you to deactivate the caldav command feature.

Hope I could help a bit.

Cheers
Björn

@Björn,
Great work and big thanks.
Motivated by your great instructions I will give it another try on the weekend.

kind regards Martin

Hi Martin,
let me know if you succeded.
Cheers
Björn

I am trying to google calendar.
But I just do not see any reaction at all.
Also in openhab log file, there is no entry, no log, even when debug is switch on.

It looks as if the caldav.jar files are not loaded at all.

in the addon folder i have copied:
org.openhab.binding.caldav-command-1.8.0.jar
org.openhab.binding.caldav-personal-1.8.0.jar

These are my items:

String OfficeCalName0 “nächster Termin [%s]” { caldavPersonal=“calendar:martin type:ACTIVE eventNr:1 value:NAME” }
DateTime OfficeCalTime0 “Beginn [%1$tT, %1$td.%1$tm.%1$tY]” { caldavPersonal=“calendar:martin type:ACTIVE eventNr:1 value:START” }
String OfficeCalName1 “nächster Termin [%s]” { caldavPersonal=“calendar:martin type:UPCOMING eventNr:1 value:NAME” }
DateTime OfficeCalTime1 “Beginn [%1$tT, %1$td.%1$tm.%1$tY]” { caldavPersonal=“calendar:martin type:UPCOMING eventNr:1 value:START” }
String OfficeCalName2 “übernächster Termin [%s]” { caldavPersonal=“calendar:martin type:UPCOMING eventNr:2 value:NAME” }
DateTime OfficeCalTime2 “Beginn [%1$tT, %1$td.%1$tm.%1$tY]” { caldavPersonal=“calendar:martin type:UPCOMING eventNr:2 value:START” }

this is my configuration
################################### CalDAV IO Binding ###################################

Used to connect to Cal DAV. All parameters are required.

caldavio:martin:url=https://www.google.com/calendar/dav/xxxxx@googlemail.com/events
caldavio:martin:username=xxxxx@googlemail.com
caldavio:martin:password=the related password
caldavio:martin:reloadInterval=10
caldavio:martin:preloadTime=20000
#caldavio:timeZone=Europe/Berlin
#caldavio:martin:historicLoadTime=3000
caldavio:martin:disableCertificateVerification=true
caldavPersonal:usedCalendars=martin

Also setting disableCertificateVerification=false does not change anything.
Any idea?

I have also allowed access to less secure apps as documented in some other threat in this forum.

regards

Martin

Hi Martin,
pls
(1) also install org.openhab.io.caldav-version.jar
(2) comment out via # the “caldavio:martin:disableCertificateVerification=true” line
(3) comment out via # the “caldavio:timeZone=Europe/Berlin” line
(4) insert in cfg: "caldavCommand:readCalendars=martin"
Cheers
Björn
PS: First sentence in the Wiki.

@Björn. Your support is really excellent!!
I will tryout your advise this evening immediately.

@Björn: It is working now. Thanks for your support.

This posting is a life-saver because it presents a simple and concise example which works, and large bits of it ought to be converted into the official documentation of the CalDAV binding which is, honestly, quite awful.

I had a bit of trouble determining the exact URL to the particular calendar, but I found this page which details that for a few servers.

I have not clear how to determine “eventNr” in items.

Moreover, I would like to know if we can use some parameters in rules.
Eg. I can schedule an event to turn on and off the lights of the garden.
I have some rules that change that switch, but I want that in case I turned lights ON using the caldav event, those rules don’t have to run.

An example code can be:
rule1:
when light ON on caldav event set var=1
when light OFF on caldav event set var=0

on other rules:
if var = 1 then exit

Hi Alberto,
To help you I need to better understand what you indent to do:

You have an event definded in your calendar and syncronized to openhab via caldav which turns at a certain time over a certain period your garden light on/off. Correct?

You have also a rule defined which - in case your calendar entry triggers the switch to turn on or off - sets a variable to 1 or 0 respectively. Correct?

Please advise what you what to achieve with this and why do you not set that variable directly via caldav and an event in your openhab calendar as described afore.

Cheers
Björn

You are right. A solution can be trigger a variable via caldav that allow me to know if a particular rule must be skipped when an item is turned on or off using caldav binding. The “problem” is that is not practical.

I explain my case:
I have a relay that turn on garden lights.
I have also few rules that automatically turn the lights on and off: when I open the garage, turn on lights for 120sec, after 20sec that the garage is close, it turn lights off.

Suppose I have friends for dinner: I schedule an event on my calendar to turn on the lights when they arrive and turn them off when they leave.
If someone open the garage, the light will be turned off before they leave. If I can set a variable, I will skip the rule of the garage and have a correct behaviour of the garden lights.

Hi Alberto,
ok understood.
Then create a dummy item in the item.file for the calendar event, e.g.:
Number CalendarSwitch “CalendarSwitch [%.0f]”

Use calendar event to set it to 1 or 0.

Build up a rule in rule.file:

rule "caldavcheck"
when
light changed from ON to OFF
then
if (CalendarSwitch.state == 1) {

}
else if (CalendarSwitch.state == 0) {

}

Does this help?
Cheers
Björn

You are absolutely right!

That can solve the problem. In my opinion, this way to use the calendar is for “geek” audience.
I think that a more easy to use binding should be more easy like:

I add an event in my calendar that contain the word “dinner”, then I should be able to set a rule that will be triggered on begin and another one at the end of the event that contain that word.

In this way, also the non-geek users will be able to use this very interesting feature of openhab. Anyway, I really thanks who developed the binding… I think that all contributors to this project are great and passionate people.

@aniimsaj: Hi Marko,

the radicale server seems to be a very lightweight server, thanks for mentioning it!
Would you mind sharing the server URL format you configured in openhab?
The documentation says: http://localhost:5232/user/calendar.ics/ but that URL is not working for me.
Maybe you could also add the configuration to the CalDAV binding wiki page?