CalDav Personal string transformation

I would like to use a JS tranfrmation to manipulate the string values from the CalDav Personal binding. Is this possible? If so what would be the syntax for the string item? I have tried adding :JS(transform.js) to the end of the item binding but this is ignored.

I don’t believe the binding supports transforms in an item’s binding configuration. Try putting it in the item’s label.

Or you could make a dummy String item and set its state to the transformed value of the caldav item’s state using a rule.

putting it directly into the item seems to completely ignore it:

String CalendarAt5 “[JS(transformnull.js):%s]”


JS(transformnull.js):Thorndon Park 5 Hamilton Terrace

I’m guessing, but try putting a name into the label…

String CalendarAt5 “Event [JS(transformnull.js):%s]”

no i have tried that as well - I can go down the rule path but I would have thought I could do it inline

Could you paste in an image of what it looks like? You’ve definitely have something strange going on. Do you have the Javascript transform service installed? I also see smart quotes in your original post. Some browsers will put them in when posting, but make sure you have regular quotes in your file. Also, do you see any errors in the logs?

OK the transform IS working, however the string I am passing in %s has a comma eg:
Thorndon Park 5 Hamilton Terrace, Paradise SA

If I pass something without a comma it is fine

anyone any ideas?

What is in your transformnull.js? There are very likely errors in the logs too.

no errors in the log
I have made the transform simple so I can test - as mentioned works fine for a string without a comma

one line in js:

input = input.substring(0, 4);

Try this return = input.substring(0, 4);. Also, what UI are you viewing it in, and how is the item defined in your sitemap?

no that throws errors invalid return statement - trying return input.substring(0, 4); also ignored
Looking in BasicUI - but all others same of course

String CalendarAt5 “Event [JS(transformnull.js):%s]” { caldavPersonal=“calendar:AJ type:EVENT eventNr:5 value:PLACE” }

Text item=CalendarAt5

I ultimately need it to get into HABPanel so need to do it at the item state level

Stranger still… I setup test items and everything works for me. No error with the transform and text with commas is transformed properly. Which version of OH are you using? I’m on 2.2.0 snapshot #1114.


That implies you haven’t installed the transform.

Using the transform in the label will only change how it gets displayed in your sitemap. If you want to change the Item’s actual state you must go down the Rule path.

You can call your transformation from the Rule using:

val transformed = transform("JS", "transformnull.js", CalendarAt5.state.toString)

I have the transform loaded and it works on the text
“Cub canoeing” which is the calendar title
It doesn’t on the text
“Thorndon Park 5 Hamilton Terrace, Paradise SA 5075, Australia”

That’s when I get
JS(transformnull.js):Thorndon Park 5 Hamilton Terrace, Paradise SA 5075, Australia

If This is only modifying the sitemap display it sounds like it won’t help me so I might go down the rule path as suggested with dummy items


I’m wondering if the commas are throwing the JavaScript off its game. JavaScript is so fast and lose with its typing that it might be automatically converting that String with commas to a list or array of Strings automatically. I’m not great with JavaScript so can’t say for sure.

Yes thats what I think as well but if input is already messed up then I dont see a way of modifying the paramater with escapes

I only using JS as it is something I know a bit would a different transform be better?

And I get the same error with the proxy item :frowning:

Depends on how structured your Strings are and what you want to extract out of them.

For example, you can get everything before the first comma using the Regex transform with


ok thanks I will have a play

Habpanel displays the transformed value:

Again… which version of OH are you running?