Map data from a sensor to another value

I have a device that is sending data that is a number representing a state. I’d like this to display as the string representation of the state instead of the number.

The mapping is as follows:
0 = closed
1 = opening
2 = open
3 = closing

If you are not concerned about the history of this string, and only want to display the string value, a key indicator panel can be used.


To keep history, a custom Inline Insight Module can be created. Documentation on Custom Inline Insights can be found here

An example for this scenario could be created in the following way:

This example can be imported using the following JSON:

  {
  "action": "(A == 0 ? \"Closed\" : A == 1 ? \"Opening\" : A == 2 ? \"Open\" : A == 3 ? \"Closing\" : \"Unknown\")",
  "constants": [],
  "description": "Translate number to state",
  "dsl": "mathjs",
  "id": "custom_iimf_vnobklo22ij",
  "inlets": [
    {
      "description": "",
      "name": "Input",
      "primitive": "numeric",
      "tag": "A",
      "translations": null,
      "types": null,
      "units": null
    }
  ],
  "name": "Number To State",
  "outlets": [
    {
      "description": "",
      "name": "State",
      "primitive": "string",
      "types": null,
      "units": null
    }
  ],
  "translations": null,
  "type": "transform"
}
1 Like