5 Replies Latest reply on Jul 7, 2016 3:32 AM by qngo RSS
    fmanniti Creator

    Mashup. Set Properties to all things

    All the mashups I've done so far were about one thing so if I wanted to set a property's value I used

    Add dynamic template -->Set Property and then I could set property to each thing.

    My problem, now, is that I want to set a property value to ALL things (i.e. I have a minimum temperature property and I want it to change to all things).

    I don't understand how to do it

      • Re: Mashup. Set Properties to all things
        polinao Collaborator

        One thing to go around the issue would be writing a service that would update/set property to all things. Are they all sharing one template? If so, if the template also shares the property, you may write a service using "set property()" snippet and update all things from within that service. If they are not sharing the template/property, then the service might be a bit more complicate but with a similar logic.

        Once the service code is defined, you'll go the same route with actually using the service from the mashup as in just having one thing to update.

          • Re: Mashup. Set Properties to all things
            fmanniti Creator

            Ok, I'm still learning how to write services.

            All my things are under the same template and they all inherit the same properties from the template.

            I tried "Add my service" and I guess I must set "NOTHING" as output. But I cannot find "set property()" in snippets. I didn't understand if it is written under another name or you meant it's a function I have to make by myself

              • Re: Mashup. Set Properties to all things
                polinao Collaborator

                You may set nothing as the output or some result to test the function before using it in the mashup. Please see below for SetPropertyValue function that is built-in in the Thing entities and "Me" (used fot the Thing Template):

                  • Re: Mashup. Set Properties to all things
                    fmanniti Creator

                    I don't know if I'm writing it wrong or it doesn't work;

                    My properties are called TempMin and TempMax:

                     

                    var props = Resources["InfoTableFunctions"].CreateInfoTable(params);
                    props.AddField({ name: 'TempMin', baseType: 'NUMBER' });
                    props.AddField({ name: 'TempMax', baseType: 'NUMBER' });
                    var params = {
                    values: props /* INFOTABLE */
                    };
                    me.SetPropertyValues(params);
                    
              • Re: Mashup. Set Properties to all things
                qngo Creator

                You can find a solution here UpdatePropertyValues service