这是indexloc提供的服务,不要输入任何密码
Skip to content

Allow setting the unit of an UOM item #3247

@spacemanspiff2007

Description

@spacemanspiff2007

According to the docs the system locale will define the default unit of an UOM item.
There are many use cases where a user does not want the conversion to the default unit but rather wants the item state to represent a different unit.

So it's important the the user can explicitly set the desired unit for each item.
Explicit setting of the unit is optional and only required when the system default is not correct.
NumberItems should carry the unit as an additional field on the item

Changes to *.items files

Current syntax

Number:Temperature    TestTemp     "Temperature [%.1f °C]"   

Since all the units are unambiguous I propose the following syntax for items files:

Number:°F    TestTemp     "Temperature [%.1f °C]"
Number:m/s   TestSpeed    "Speed [%.1f mph]"

Changes to the RestAPI

NumberItems should show the current unit

Current response:

  {
    "link": "http://localhost:8080/rest/items/TestTemp",
    "state": "20 °C",
    "stateDescription": {
      "pattern": "%.1f °C",
      "readOnly": false,
      "options": []
    },
    "editable": false,
    "type": "Number:Temperature",
    "name": "TestTemp",
    "label": "Temperature",
    "tags": [],
    "groupNames": []
  }

New response

  • state doesn't carry the unit any more
  • new fields unit and dimension (I'm unsure about dimension since it's not required)
  {
    "link": "http://localhost:8080/rest/items/TestTemp",
    "state": "20",
    "unit": "°F",
    "dimension": "Temperature",
    "stateDescription": {
      "pattern": "%.1f °C",
      "readOnly": false,
      "options": []
    },
    "editable": false,
    "type": "Number",
    "name": "TestTemp",
    "label": "Temperature",
    "tags": [],
    "groupNames": []
  }

Metadata

Metadata

Assignees

Labels

enhancementAn enhancement or new feature of the Core

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions