openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

[REST API] Inconsistent response of REST-Api for items with mapped values #4978

Closed adb76 closed 7 years ago

adb76 commented 7 years ago

I'm currently using openHAB 2 build #692 with the following items / map Definition (as also described here: https://community.openhab.org/t/mapping-of-item-values-not-correctly-shown-in-habpanel/19518)

Contact Wohnzimmer_Fenster1_OpenClosed  "Wohnzimmerfenster 1 [MAP(de.map):%s]" (Wohnzimmer, Wohnung_Fenster) { channel="max:shuttercontact:NEQ0897054:LEQ0791036:contact_state" }

Contact Wohnzimmer_Fenster2_OpenClosed  "Wohnzimmerfenster 2 [MAP(de.map):%s]" (Wohnzimmer, Wohnung_Fenster) { channel="max:shuttercontact:NEQ0897054:LEQ0790888:contact_state" }

de.map:

CLOSED=zu
OPEN=offen

When I make a REST-Api call http://homenuc:8080/rest/items/Wohnzimmer_Fenster1_OpenClosed/state

it returns always CLOSED respectively OPEN

When you call the item with http://homenuc:8080/rest/items/Wohnzimmer_Fenster1_OpenClosed

returns the mapped value "zu" and "offen" beside the key "state":

{
  "link": "http://homenuc:8080/rest/items/Wohnzimmer_Fenster1_OpenClosed",
  "state": "zu",
  "stateDescription": {
    "pattern": "",
    "readOnly": false,
    "options": []
  },
  "type": "Contact",
  "name": "Wohnzimmer_Fenster1_OpenClosed",
  "label": "Wohnzimmerfenster 1",
  "tags": [],
  "groupNames": [
    "Wohnzimmer",
    "Wohnung_Fenster"
  ]
}

The same also when calling it via a "sitemaps" call like:

http://homenuc:8080/rest/sitemaps/zuHause?jsoncallback=callback

"widgets": [
                      {
                        "widgetId": "Wohnzimmer_0",
                        "type": "Text",
                        "label": "Wohnzimmerfenster 1 [zu]",
                        "icon": "contact",
                        "mappings": [],
                        "item": {
                          "link": "http://homenuc:8080/rest/items/Wohnzimmer_Fenster1_OpenClosed",
                          "state": "zu",
                          "stateDescription": {
                            "pattern": "",
                            "readOnly": false,
                            "options": []
                          },
                          "type": "Contact",
                          "name": "Wohnzimmer_Fenster1_OpenClosed",
                          "label": "Wohnzimmerfenster 1",
                          "tags": [],
                          "groupNames": [
                            "Wohnzimmer",
                            "Wohnung_Fenster"
                          ]
                        },
                        "widgets": []

On the "Event channel" it is also always "unmapped". This leads for example in HABpanel to the problem that the values are "jumping" between their mapped and unmapped representation dependent of the way the last call was made.

I would have had expected, that the values are always send in der mapped representations via the REST Api.

Kind regards,

André

9037568 commented 7 years ago

I don't believe there's any code here for REST. This probably belongs in ESH.

adb76 commented 7 years ago

Ok - sorry for opening the issues at the wrong place. So should we close it here and reopen it directly at ESH?

Regards.

9037568 commented 7 years ago

I would recommend searching first to see if it's already been raised. But, yes, I think closing this and raising it elsewhere is the right way to go.

I frequently guess wrong when choosing which repository a bug needs to go to, so caveat emptor.

adb76 commented 7 years ago

Closed and reopened at Eclipse Smarthome: https://github.com/eclipse/smarthome/issues/2788