How to multiply 2 data points and graph the product?


Enjoying the Losant platform. I have a dashboard

As you might see, I am logging volts, milliamps, and temp. I am graphing temp. I would like to graph temp vs watts. How might I multiply the volts x amps and add to the graph? I can do this swiftly in google spreadsheets, but scratching my head with Losant!



You’ll want to use a workflow to calculate watts and store that value on another attribute on your device. Steps are …

  1. Create a new attribute on your device(s) called “watts”. The attribute type should be “number”.
  2. Create a new workflow in the same application as the devices.
  3. Add a Device Trigger node, which will fire the workflow every time the specified device(s) reports state.
  4. Connect the trigger to a Conditional node and set the condition to be {{ data.watts }} === undefined. (More on why we’re doing this below.)
  5. Connect the positive output of the Conditional node to a Math node. In here, you can pull milliamps and voltage off your payload and do the calculation to convert that to watts. Then, store the result on your payload at data.watts.
  6. Connect the Math node to a Device State node. Use the ID of the device that reported state (available on the payload) and report the wattage that you calculated in the previous step under your new “watts” attribute on the device.

The reason for the conditional node is that, when we report the device state in our final node, this will cause the workflow to trigger again. We are checking to see if watts is not on the payload so we can tell the difference between an actual device state report and our calculated report. Without this check, the workflow will throw an “infinite loop” error.

1 Like

Thanks for workin thru that one Dylan.