OH3 MAP transformation is behaving different for different Items

I have fixed se.map as above and entered on the item

Could you show the code view for that metadata?

What’s different between the Garage door Items that do not seem to work and the door Item that do appear to work? Perhaps there is a typo? Your screen shot shows it working for some of your Items so the solution is in figuring out what is different.

The two that are not working are zwave items vs verisure. Are the z-wave node channels returning Open or OPEN, Closed or CLOSED

Both verisure and zwave is OPEN CLOSED when i look in Mariadb.

Verisure without MAP

Contact    Kitchen_Door_State         "Altandörr Kök"       <door>          (geKitchen_Door, gcDoors, gpCR)       ["OpenState"]    {channel="verisure:doorWindowSensor:liegatan:2JJSTVU8:state"}

Verisure with MAP

Contact    Kitchen_Door_State         "Altandörr Kök [MAP(se.map):%s]"       <door>          (geKitchen_Door, gcDoors, gpCR)       ["OpenState"]    {channel="verisure:doorWindowSensor:liegatan:2JJSTVU8:state"}

Zwave without MAP

Contact    Garage_Gate_Contact        "Garageport"          <garagedoor>    (geGarage_Gate, gcDoors, gpCR)        ["OpenState"]    {channel="zwave:device:e8581bab06:node20:sensor_door"}

Zwave with MAP

Contact    Garage_Gate_Contact        "Garageport [MAP(se.map):%s]"          <garagedoor>    (geGarage_Gate, gcDoors, gpCR)        ["OpenState"]    {channel="zwave:device:e8581bab06:node20:sensor_door"}

Zwave channels provide/suggest default state description, unlike many other bindings.
Is that over writing your manual change to the Item?

Comparing Item JSON with a working Item may help understanding.

How do we then translate zwave items?

No idea. It all works in sitemap based UIs. I might be very wrong about root cause. What do your working and non-working Items JSON look like?

What Items JSON to you mean.

Wait, if you are defining the Items in .items files then you need to define the State Description Item metadata in the .items files too. As has always been the case, when your .items file gets unloaded, the Item gets deleted including the Item metadata I think. So you’ve lost that State Description metadata.

You can confirm this by looking at the State Description metadata in the UI again to see if it’s gone. If it’s not gone then something else is going on.

Oh yes, of course, it’s no good editing Item properties in the UI if you have defined them from file.
Does MainUI need an enhancement to stop that?

I think you can view an Item’s internal JSON by looking at it in MainUI and clicking “code”? Get a view like you can in REST API. What is going in the state presentation section is the interest.

Well, my understanding of the behavior is from 2.5. I don’t know if that changed in 3.0 which is why I asked for the confirmation. It may be the case that the metadata sticks around even after the Item is deleted and then gets reassociated with the Item when it’s recreated during the .items file load.

Items are sadly the only place in MainUI that doesn’t have a code. And even if it did, it wouldn’t help with the metadata because the metadata is stored separately. To make it even worse, there is no way to query for all of the metadata on a given Item. You have to know the namespace for the metadata first. So even if there were a code view, it wouldn’t show the Links (which are also stored separately) nor the metadata and it’s the metadata that we are really interested in here.

The REST API could be used as you can pass in the namespace as part of the query for an Item, and it will return that one namespace’s metadata. But we can also just look in the State Description section of the Item’s page in MainUI which will be easier.

Why is it then working for some bindings with this items files but not for zwave?

I have the same problem with Items (defined in the UI) where the binding provides state options and I have a MAP-transformation with different values. When querying the Item through the API explorer I get this:

{
  "link": "https://openhab.alfredsson.info/rest/items/SMHI_Hour0_Wsymb",
  "state": "3",
  "transformedState": "Växlande molnighet",
  "stateDescription": {
    "pattern": "MAP(smhi_wsymb2.map):%s",
    "readOnly": true,
    "options": [
      {
        "value": "1",
        "label": "Clear sky"
      },
      {
        "value": "2",
        "label": "Nearly clear sky"
      },
      {
        "value": "3",
        "label": "Variable cloudiness"
      },
      {
        "value": "4",
        "label": "Halfclear sky"
      },
      {
        "value": "5",
        "label": "Cloudy sky"
      },
      {
        "value": "6",
        "label": "Overcast"
      },
      {
        "value": "7",
        "label": "Fog"
      },
      {
        "value": "8",
        "label": "Light rain showers"
      },
      {
        "value": "9",
        "label": "Moderate rain showers"
      },
      {
        "value": "10",
        "label": "Heavy rain showers"
      },
      {
        "value": "11",
        "label": "Thunderstorm"
      },
      {
        "value": "12",
        "label": "Light sleet showers"
      },
      {
        "value": "13",
        "label": "Moderate sleet showers"
      },
      {
        "value": "14",
        "label": "Heavy sleet showers"
      },
      {
        "value": "15",
        "label": "Light snow showers"
      },
      {
        "value": "16",
        "label": "Moderate snow showers"
      },
      {
        "value": "17",
        "label": "Heavy snow showers"
      },
      {
        "value": "18",
        "label": "Light rain"
      },
      {
        "value": "19",
        "label": "Moderate rain"
      },
      {
        "value": "20",
        "label": "Heavy rain"
      },
      {
        "value": "21",
        "label": "Thunder"
      },
      {
        "value": "22",
        "label": "Light sleet"
      },
      {
        "value": "23",
        "label": "Moderate sleet"
      },
      {
        "value": "24",
        "label": "Heavy sleet"
      },
      {
        "value": "25",
        "label": "Light snowfall"
      },
      {
        "value": "26",
        "label": "Moderate snowfall"
      },
      {
        "value": "27",
        "label": "Heavy snowfall"
      }
    ]
  },
  "commandDescription": {
    "commandOptions": [
      {
        "command": "1",
        "label": "Clear sky"
      },
      {
        "command": "2",
        "label": "Nearly clear sky"
      },
      {
        "command": "3",
        "label": "Variable cloudiness"
      },
      {
        "command": "4",
        "label": "Halfclear sky"
      },
      {
        "command": "5",
        "label": "Cloudy sky"
      },
      {
        "command": "6",
        "label": "Overcast"
      },
      {
        "command": "7",
        "label": "Fog"
      },
      {
        "command": "8",
        "label": "Light rain showers"
      },
      {
        "command": "9",
        "label": "Moderate rain showers"
      },
      {
        "command": "10",
        "label": "Heavy rain showers"
      },
      {
        "command": "11",
        "label": "Thunderstorm"
      },
      {
        "command": "12",
        "label": "Light sleet showers"
      },
      {
        "command": "13",
        "label": "Moderate sleet showers"
      },
      {
        "command": "14",
        "label": "Heavy sleet showers"
      },
      {
        "command": "15",
        "label": "Light snow showers"
      },
      {
        "command": "16",
        "label": "Moderate snow showers"
      },
      {
        "command": "17",
        "label": "Heavy snow showers"
      },
      {
        "command": "18",
        "label": "Light rain"
      },
      {
        "command": "19",
        "label": "Moderate rain"
      },
      {
        "command": "20",
        "label": "Heavy rain"
      },
      {
        "command": "21",
        "label": "Thunder"
      },
      {
        "command": "22",
        "label": "Light sleet"
      },
      {
        "command": "23",
        "label": "Moderate sleet"
      },
      {
        "command": "24",
        "label": "Heavy sleet"
      },
      {
        "command": "25",
        "label": "Light snowfall"
      },
      {
        "command": "26",
        "label": "Moderate snowfall"
      },
      {
        "command": "27",
        "label": "Heavy snowfall"
      }
    ]
  },
  "editable": true,
  "type": "Number",
  "name": "SMHI_Hour0_Wsymb",
  "label": "Väder",
  "category": "weather_day",
  "tags": [],
  "groupNames": [
    "Smhi"
  ]
}

But main UI doesn’t seem to use the transformedState value, it uses the options instead (which come from the binding). When you edit the stateDescription metadata in the UI there is an Options field where you can input key-value pairs like in the .map-files, and this seems to override the binding provided values, but this needs to be set on each item individually which isn’t scalable if you have many Items that use the same transformation.

1 Like

I have the same problem with Verisure Items,it shows the Option Value in UI not transformed State.

{
	"link": "http://openhab:8080/rest/items/Verisure_AlarmStatus",
	"state": "DISARMED",
	"transformedState": "Olarmat",
	"stateDescription": {
		"pattern": "MAP(se.map):%s",
		"readOnly": false,
		"options": [
			{
				"value": "DISARMED",
				"label": "DISARMED"
			},
			{
				"value": "ARMED_HOME",
				"label": "ARMED HOME"
			},
			{
				"value": "ARMED_AWAY",
				"label": "ARMED AWAY"
			}
		]
	},
	"commandDescription": {
		"commandOptions": [
			{
				"command": "DISARMED",
				"label": "DISARMED"
			},
			{
				"command": "ARMED_HOME",
				"label": "ARMED HOME"
			},
			{
				"command": "ARMED_AWAY",
				"label": "ARMED AWAY"
			}
		]
	},

This is also the actual problem with zwave item.

{
	"link": "http://openhab:8080/rest/items/Garage_Gate_Contact",
	"state": "CLOSED",
	"transformedState": "Stängd",
	"stateDescription": {
		"pattern": "MAP(se.map):%s",
		"readOnly": true,
		"options": [
			{
				"value": "OPEN",
				"label": "Open"
			},
			{
				"value": "CLOSED",
				"label": "Closed"
			}
		]
	},
	"commandDescription": {
		"commandOptions": [
			{
				"command": "OPEN",
				"label": "Open"
			},
			{
				"command": "CLOSED",
				"label": "Closed"
			}
		]
	},
	"editable": false,
	"type": "Contact",
	"name": "Garage_Gate_Contact",
	"label": "Garageport",
	"category": "garagedoor",
	"tags": [
		"OpenState"
	],
	"groupNames": [
		"geGarage_Gate",
		"gcDoors",
		"gpCR"
	]
}
1 Like

So we could sum up by saying that BasicUI etc.use the stateDescription/pattern (if given) to override any stateDescription/options provided.
While MainUI does the reverse, gives priority to options.

Have you reloaded those .items files?

We have found the issue look above.

@rossko57 and @pacive how do we file this as an issue.