OH4 M4: Problem with Profile JS-Transformation of Datetime-Type

My heating binding is offering a thing channel [string] for determining the heating periode (Start, Stop days) in the format YYYY-MM-DD/YYYY-DD-MM.

I want to connect this string to 2 datetime items with a 2-way profile JS transformation (ECMA Script Ed 11). One of these items is shown here.

From Thing to Item the transformation is working well:

(function(data) {
  console.info( "Buderus Heating Break:" + data );
  return (String(data.slice(0, 10)) + 'T00:00');

But the other way, from item to thing, the transformation is not working, I think even not executed (as nothing is logged):

(function(data) {
  var tmp = String(data).slice(0,10) + "/" +  String(items.getItem("i_StopHeatingBreak").state).slice(0,10);
  console.info( "Buderus Heating Break Update: " + tmp );
  return ( tmp );

Any hint what I’m doing wrong?

Thx in advance. O

Make the first line of the transform function be the log statement.
If there is something wrong with the creation of tmp you’d not get the following log statement. Though I would expect to see an error in openhab.log if that happened.

Which OH version are you running? There are lots of changes in OH 4 so the differences between M3 and M4 could be huge.

Are you sending a command to the Item? Updates do not propagate to the Thing so if you are merely updating the Item the transform wouldn’t be invoked because the update doesn’t go that far. It just changes the Item’s state.

added a log in the 1st line:

(function(data) {
  console.info( "Buderus Heating Break In Update: " + data );
  var tmp = String(data).slice(0,10) + "/" +  String(items.getItem("i_StopHeatingBreak").state).slice(0,10);
  console.info( "Buderus Heating Break Out Update: " + tmp );
  return ( tmp );

and send a command to the item:

2023-07-06 20:29:47.871 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘i_StartHeatingBreak’ received command 2023-03-11T00:00:00.000+0100

But even after 3 minutes nothing happened.

I played a little bit around. I think there is an issue with datetime inputs.
If I use strings instead of datetime the transformation is triggered.

As written: I use oh4 milestone 4 (on a raspi 2 b).


After sending the command do you see anything else on that Item? A changed event perhaps? That shouldn’t matter but I’m trying to gather additional information to get a fuller picture.

Just to be clear, you are looking in openhab.log for the logs from your transform, right? They do not appear in events.log.

Since it seems to work with a String, is there a reason you can’t just use a String Item for this?

I observed via openhab-cli showlogs all logs.

2023-07-06 20:29:47.871 [INFO ] [openhab.event.ItemCommandEvent ] - Item ‘i_StartHeatingBreak’ received command 2023-03-11T00:00:00.000+0100
2023-07-06 20:29:47.898 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item ‘i_StartHeatingBreak’ predicted to become 2023-03-11T00:00:00.000+0100
2023-07-06 20:29:47.902 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item ‘i_StartHeatingBreak’ changed from 2023-04-11T00:00:00.000+0200 to 2023-03-

I want to use a datetime item as I want to use a datepicker widget

There’s nothing about the Date Picker widget that requires the Item be a DateTime Item. It should work just fine with a String Item.

You are right - a datepicker is basically working with string items - but with some restrictions. So I decided to stay for the time being with your proposed workaround.

Nevertheless I think that it is worth to document that datetime with with js-transformation is not yet properly working in order to avoid that other people waste so much time on this issue as well.


I think that’s a symptom of a wider problem though, not an absolute problem. You should file an issue. It’s something that needs to be fixed, not documented.