6 Replies Latest reply on Jun 2, 2016 2:44 PM by carlesc RSS
    fserre Explorer

    How to modify property units by script ?

    Thanks to the community I found how to get the units of a property by script.

    But now, I am trying to edit it and I cannot find the good API call to do it.

    Does anybody know if it is possible and how to do it?

      • Re: How to modify property units by script ?
        carlesc Ninja

        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 ).

          • Re: How to modify property units by script ?
            fserre Explorer

            Thanks Carles for your answer. That make sense. May I ask you how do you have implemented your units system?

            I don't know how to add properties on top on properties, the only way I can think is to create a infotable property in the thing which could contains all custom property fields.

              • Re: How to modify property units by script ?
                carlesc Ninja

                Hi Fabien,

                 

                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



                Best Regards,

                Carles