DateTime format with OH3 items not working

Does that have anything to with the state presentation stuff that is giving you the problem?

Just to be clear in the answer to this question, only the CLOSED event goes to the Profile. The Profile creates the timestamp on its own.

But as @rossko57 said, that has nothing to do with the actual problem on this thread. The root cause of the problem is the State Description, not the Profile.

What would be most instructive here is the JSON returned by REST API in response to a ā€œget Itemā€, for each of -
Normal contact Item
Datetime that formats
Datetime that doesnā€™t format

Ok Ross, Iā€™ll try do that, sounds an excellent idea. I havenā€™t used the REST API before but Iā€™ll try figure it.

Super clear summary of the process :ok_hand: I understand it much better now, thank you.

So the Zwave binding injected a default state description for my DateTime Item when I linked to the contact channel and which effectively ignores/overrides the fact that itā€™s NOT a Contact Item in this case and we canā€™t seem to insist/imprint our desired State description onto the DateTime item. Is this correct?

I wonder though how the correctly formatted DateTime ā€˜poppedā€™ into view (and stayed) as soon as I deleted the channel link? Does the State Description somehow ā€˜regain controlā€™ at the last instant? How would it do this if it was never successfully written into/accepted by the DateTime Item?? It must be there all the time but is dynamically overridden whilst the link is in place.

Ross, I have that done. Do ye want those JSON files (from the REST API tool) posted as text document files or a load of code within ā€˜fencesā€™? Actually Iā€™m not sure what fences are on the keyboardā€¦? Sorry if silly Q

Here are these files! Iā€™ve already noticed that there is a readonly setting set to true for the non-working item. I never interacted with this setting anywhere.
ALSO, there was NO METADATA WIDGET involved in these tests, just a State Pattern setting.

JSON files from REST API queries:

JSON Normal Contact Item;

{
  "link": "http://localhost:8080/rest/items/ZWaveNode039AeotecZWA008DoorWindowSensor7_DoorSensor",
  "state": "CLOSED",
  "stateDescription": {
    "readOnly": true,
    "options": [
      {
        "value": "OPEN",
        "label": "Raining"
      },
      {
        "value": "CLOSED",
        "label": "Dry"
      }
    ]
  },
  "commandDescription": {
    "commandOptions": [
      {
        "command": "OPEN",
        "label": "Raining"
      },
      {
        "command": "CLOSED",
        "label": "Dry"
      }
    ]
  },
  "editable": true,
  "type": "Contact",
  "name": "ZWaveNode039AeotecZWA008DoorWindowSensor7_DoorSensor",
  "label": "Rain Sensor",
  "category": "rainsensor",
  "tags": [
    "Point"
  ],
  "groupNames": [
    "ZWaveNode039AeotecZWA008DoorWindowSensor7"
  ]
}

DateTime formats OK - DateTime item linked to FibaroFGS212

{
  "link": "http://localhost:8080/rest/items/Raining_since",
  "state": "2021-12-17T19:13:17.134672+0000",
  "stateDescription": {
    "pattern": "%1$tl:%1$tM %1$tp",
    "readOnly": false,
    "options": []
  },
  "editable": true,
  "type": "DateTime",
  "name": "Raining_since",
  "label": "Dry/Raining since",
  "category": "time",
  "tags": [
    "Point",
    "Timestamp"
  ],
  "groupNames": [
    "ZWaveNode039AeotecZWA008DoorWindowSensor7"
  ]
}

DateTime does NOT format OK - DateTime item linked to Aeotec Contact Sensor

{
  "link": "http://localhost:8080/rest/items/Raining_since",
  "state": "2021-12-17T18:26:44.974284+0000",
  "stateDescription": {
    "pattern": "%1$tl:%1$tM %1$tp",
    "readOnly": true,
    "options": [
      {
        "value": "OPEN",
        "label": "Open"
      },
      {
        "value": "CLOSED",
        "label": "Closed"
      }
    ]
  },
  "commandDescription": {
    "commandOptions": [
      {
        "command": "OPEN",
        "label": "Open"
      },
      {
        "command": "CLOSED",
        "label": "Closed"
      }
    ]
  },
  "editable": true,
  "type": "DateTime",
  "name": "Raining_since",
  "label": "Dry/Raining since",
  "category": "time",
  "tags": [
    "Point",
    "Timestamp"
  ],
  "groupNames": [
    "ZWaveNode039AeotecZWA008DoorWindowSensor7"
  ]
}

Could the readonly status-true that has been mysteriously set be the problem? Could we stop OH, edit the setting in the file and restart OH?

My problem; What actual JSON file has that detail about the readonly-true status?? I have (using Visual Studio Code) opened up and looked in the following:
org.openhab.core.items.Item.json
org.openhab.core.items.Metadata.json
org.openhab.core.thing.link.ItemChannelLink.json
org.openhab.core.thing.Thing.json

I saw listings for both the Raining_since and the Door contact items in most of these files but NO MENTION of a ā€˜readonly-trueā€™ parameter. Where can it be? How did the REST API find this parameter in its request?

No.

The ones that donā€™t work have state description options. None of the supplied options will fit a datetime.

I donā€™t understand your reply, sorry. One channel link did work and one didnā€™t. Also, what do you mean by ā€œnone will fit a DateTimeā€? Sorry I donā€™t know what you mean or are referring toā€¦
Also, do you know where this readonly status info IS stored so??

These are options in the Items state description properties.
Te zwave binding put them there, thinking you have a Contact Item and you would like state OPEN displayed as Open. Might seem silly, makes more sense when it automatically selects language like Offnen instead. You have no choice if you donā€™t like, but you can hand-edit them later.

But the Item is a DateTime, its state is not OPEN and so it matches none of the supplied options.
The options failure I think stops it even getting as far as the ā€˜patternā€™ format.
So you get the default datetime string display because in case of total failure, thatā€™s the backup.

Try deleting (not setting blank) options metadata.

REST response for test DateTime item that works

{
  "link": "http://localhost:8080/rest/items/TimeStampTest",
  "state": "2021-12-17T07:47:05.596157-0500",
  "stateDescription": {
    "pattern": "%1$tm-%1$td %1$tH:%1$tM",
    "readOnly": false,
    "options": []
  },
  "editable": true,
  "type": "DateTime",
  "name": "TimeStampTest",
  "label": "Time Stamp Test",
  "category": "",
  "tags": [],
  "groupNames": []
}

REST response for problematic zwave door contact item without state description set

{
  "link": "http://localhost:8080/rest/items/LastBathDoorOpen",
  "state": "2021-12-17T07:40:49.585991-0500",
  "stateDescription": {
    "readOnly": true,
    "options": [
      {
        "value": "OPEN",
        "label": "Open"
      },
      {
        "value": "CLOSED",
        "label": "Closed"
      }
    ]
  },
  "commandDescription": {
    "commandOptions": [
      {
        "command": "OPEN",
        "label": "Open"
      },
      {
        "command": "CLOSED",
        "label": "Closed"
      }
    ]
  },
  "editable": true,
  "type": "DateTime",
  "name": "LastBathDoorOpen",
  "label": "Last Bath Door Open",
  "category": "",
  "tags": [],
  "groupNames": []
}

REST response for problematic zwave door contact item with state description set

{
  "link": "http://localhost:8080/rest/items/LastBathDoorOpen",
  "state": "2021-12-17T07:40:49.585991-0500",
  "stateDescription": {
    "pattern": "%1$tm-%1$td %1$tH:%1$tM",
    "readOnly": true,
    "options": [
      {
        "value": "OPEN",
        "label": "Open"
      },
      {
        "value": "CLOSED",
        "label": "Closed"
      }
    ]
  },
  "commandDescription": {
    "commandOptions": [
      {
        "command": "OPEN",
        "label": "Open"
      },
      {
        "command": "CLOSED",
        "label": "Closed"
      }
    ]
  },
  "editable": true,
  "type": "DateTime",
  "name": "LastBathDoorOpen",
  "label": "Last Bath Door Open",
  "category": "",
  "tags": [],
  "groupNames": []
}
1 Like

Thanks for that clear explaination. I think you might be right!
Curiosityā€¦ as we see also in Andrewā€™s posting, what does this readonly-try-false setting do? Who does it prevent writing what to where ?

Back to your editing advice:
Which of the json files will I be editing? In fact I canā€™t find any mention of these OPEN/CLOSED label/command options etc in ANY of the JSON files I looked into!
If I (ever) find them, how much ā€˜deletingā€™ of those options do I do?.. all the words AND all the curly brackets but leave the square brackets alone?? Do I shut down OH before? Can I use Visual Studio Code app to do the business or will it have to be via the REST editorā€¦if thatā€™s possible? Iā€™m getting out of my depthā€¦ :dizzy_face:

Read only ; this device is a contact, a sensor, it can inform you if a door is open. You cannot send it an instruction to open the door, it is not an actuator.
The binding sets this because the binding knows what sort of device it is.
It doesnā€™t actually limit what you can do very much - but itā€™s useful for a GUI to know whether to give you a graphical knob to twiddle or not.
All irrelevant here.

None. Do this in the GUI, edit Item metadata.

Rossko got itā€¦
I stumbled across a funny thing last night
I tried it in a widget, but I just clicked the big blue button and created a new widget
The screen shot in Post 11 showed the newly created widget. (Sorry Rich I cut off the yaml but I didnā€™t think it mattered because it was a newly created widget with the same yaml as any other newly created widget)
here is result


notice last line of yaml in code window

content: =items[props.item].displayState || items[props.item].state

then I edited it to this

content: =items[props.item].state

and got

Duhā€¦ still the sameā€¦ so then I edited last line again and made it this

content: =items[props.item].displayState

and got this


actually last night it was a dash like so -
sort of what PaperUI would give when there was no state to show (state was nan)
I think because of

  "stateDescription": {
    "pattern": "%1$tm-%1$td %1$tH:%1$tM",
    "readOnly": true,
    "options": [
      {
        "value": "OPEN",
        "label": "Open"
      },
      {
        "value": "CLOSED",
        "label": "Closed"
      }
    ]
  }

Read only true and options OPEN or openā€¦
soā€¦ off to find if this device in the zwave database per device is how binding decides some device not others

yeah but the read only is in the state description part of the yaml and in the one that works
read only - false

"stateDescription": {
    "pattern": "%1$tm-%1$td %1$tH:%1$tM",
    "readOnly": false,
    "options": []
  },

OK that makes sense.
Do you mean the normal GUI where we design the item metadata details? Those OPEN/CLOSE stuff donā€™t show up anywhere thereā€¦ all I can see is how to ADD metadata partsā€¦ is it to be done in the CODE TAB of the metadata configā€¦gawd Iā€™m getting more n more lostā€¦ :exploding_head: :confounded:

And ā€¦? As you can see from options or not-options being present on similar devices, in the case of zwave devices this is all derived from crowdsourced device entries and the crowd members have different opinions and skillsets, I wouldnā€™t expect brilliant accuracy, if you see an error go fix the zwave device database.

okā€¦ not sure, canā€™t find anything in the database where options are set
here is link to device in database
https://opensmarthouse.org/zwavedatabase/947

I think the fix would be if core (or whatever) checks item type (which is in yaml) and if item type is DateTime instead of whatever (in this case contact) throws away the state description (containing the ā€˜forcedā€™ state description) if a pattern is present

Noā€¦ options - no options being present is from MainUI created item, created from the Thing ā€”> channel ā€”> add item button, picking DateTime type item and clicking ā€˜timestamp on changeā€™ option
this one has options in yaml

Other item is just MainUi created item not tied to any Thing or Channel and just DateTime type and update from little DSL rule