I don't think there's a snippet to do it, you may call the same REST API which calls Composer when you edit units... ( but I think that on this case, it's modifying the entire entity ).
For this reason, I've implemented my own Units system, which it's more flexible, but It would be good if they allow easily to modify units ( but should be on a Thing Basis, not ThingTemplate/ThingShape ).
Our Units system it's rather complicated.. something like:
- We usually don't define "Raw" units for Properties ( Units Value ) , we define Units Class, for instance ( Temperature, Currency, Thermal Energy, Electrical Energy,... ). This is the type of units we usually define on a property ( ThingTemplate /ThingShape )
- Then Based on the Things Hierarchy ( a network ) the Thing inherit the Units Value ( Celsius/Fahrenheit, €/$/..., kWh,... ) from a Units Setters Thing.
- Optionally we can have a service which returns the Unit Type or Unit Value for a property, or for a given property we can have also Units Value
- Optionally we can set the Units on the Thing Instance using our custom Aspects solution
- TW Units field on our solution looks like this custom notation:
- (service_name) --> service_name will be called in order to recover units_name
- [literal_name] --> Raw units ( Units Value ), sample: [€]
- units_name --> Units Type ( Units Class ), sample: currency --> Will inherit Raw units from Hierarchy Units Setter.
- Aspect --> We have a custom aspect feature on our solution, which allows as on a Thing instance set custom property aspects ( which are implemented on Dynamic Properties created on the Thing instance ) , where we can set Custom Units on a Thing Instance.
- We have data tables defining Units Value and Units Class ( for Localization purposes, and for easy input ), units value it's not like €, it's more like currencyEUR