How to multiply 2 data points and graph the product?

#1

Enjoying the Losant platform. I have a dashboard https://app.losant.com/#/dashboards/58a1d23e50530f0001031a34

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!

Thanks!
Winston

#2

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
#3

Thanks for workin thru that one Dylan.