Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Support added end of April 2022.

  • This new format is now what should be used for all new templates.

  • The Legacy form_settings format will still work in older templates.

  • Old templates can be updated to the new format by simply editing the template . Note that existing Paired devices will see the new options in Settings - the user will simply need to make a selection in the dropdown and re-save their device settings to take advantage.

...

  • and re-saving with the newly changed form_settings.

    • Existing Paired devices will continue to use existing settings (e.g. it pulls the default units from template).

    • If you define new units in the form_settings, the user simply needs to Refresh their screen to see the new options - there’s no need to re-add device.

    • If form_settings are updated and a user with existing Paired device wants to take advantage without re-adding, they can simply open Settings for device, make selections in the new dropdowns and click Save.

form_settings with Individual channels format:

This is example of Milesight AM107 template which was updated so that now user can not only select Temperature channel units but also now can set Barometric Pressure units.

Code Block
[
  {
    "order": 0,
    "label": null,
    "variables": [
      {
        "order": 0,
        "label": "Temperature Unit",
        "type": "string",
        "min": null,
        "max": null,
        "form": "select",
        "key": "child.3.unit",
        "default_value": "f",
        "required": true,
        "values": [
          { "value": "f", "label": "°F", "short": "°F" },
          { "value": "c", "label": "°C", "short": "°C" }
        ]
      },
      {
        "order": 1,
        "label": "Barometric pressure Unit",
        "type": "string",
        "min": null,
        "max": null,
        "form": "select",
        "key": "child.13.unit",
        "default_value": "hpa",
        "required": true,
        "values": [
          { "value": "pa", "label": "Pascal", "short": "Pa" },
          { "value": "hpa", "label": "Hectopascal", "short": "hPa" }
        ]
      }
    ]
  }
]

The Key should match the Channel as defined in the template.

For example Channel 3 (Temperature) from this template is matched with:

Code Block
"key": "child.3.unit"

The value in values definition should match the Payload from the template’s Units:

For example adding an entry to match “Hectopascals” would use "value": "hpa". The short and label can be used to display nice text to the user.

Code Block
"values": [
          { "value": "hpa", "label": "Hectopascal", "short": "hPa" }

...

Note on priority matching:

Code Block
1. properties.child.X.unit
2. properties.unit (if it is a valid unit for the sensor)
3. the unit marked as "default" for the capability if the sensor has console capability
4. sensor.unit, not sure where it is defined, but might be the standard unit API returns
5. no unit ("null" unit is also not shown)

Clone (using one key for multiple channels)

You can use cloning to show one input field that then gets used to set the units for multiple channels. You can either add a "clone_to_key": ”another_key” or you can use array support as well.

Example: Specifying one input that will also clone to one additional channel’s units

"clone_to_key": "child.502.unit",

Code Block
[
  {
    "order": 0,
    "label": null,
    "variables": [
      {
        "order": 0,
        "label": "TemperaturePrecipitation Unit",
        "type": "string",
        "min": null,
        "max": null,
        "form": "select",
        "key": "selectchild.500.unit",
        "clone_to_key": "child.3502.unit",
        "default_value": "fin",
        "required": true,
        "values": [
          { "value": "in", "label": "Inches", "short": "in" },
          { "value": "fmm", "label": "Millimeters", "short": "°F", "short": "°F" },"mm" }
        ]
      }
    ]
  { "value": "c", "label": "°C", "short": "°C" }
  }
]

Example: Specifying array so that the units will be cloned to multiple channels units

"clone_to_key": ["child.502.unit", "child.999.unit"],

Code Block
[
  {
    "order": 0,
     ]"label": null,
    "variables": [
},       {
        "order": 10,
        "label": "ProbePrecipitation Unit",
        "type": "string",
        "min": null,
        "max": null,
        "form": "select",
        "key": "child.7.unit",
        "default_value": "f",
        "required": true,
        "values": [
 500.unit",
        { "valueclone_to_key": ["fchild.502.unit", "label": "°F", "short": "°F" },
  child.999.unit"],
       { "default_value": "cin",
 "label": "°C", "short": "°C" }
         "required": true,
     ]   "values": [
  }     ]   }
]

where 3 is the channel as indicated by:

Code Block
"key": "child.3.unit"

the priority is:

Code Block
1. properties.child.X.unit
2. properties.unit (if it is a valid unit for the sensor)
3. the unit marked as "default" for the capability if the sensor has console capability
4. sensor.unit, not sure where it is defined, but might be the standard unit API returns
5. no unit ("null" unit is also not shown){ "value": "in", "label": "Inches", "short": "in" },
          { "value": "mm", "label": "Millimeters", "short": "mm" }
        ]
      }
    ]
  }
]