mapero / node-red-contrib-smartplug

MIT License
3 stars 4 forks source link

Request: Add option for cost to the output node #3

Closed TotallyInformation closed 8 years ago

TotallyInformation commented 8 years ago

The iOS app allows setting of $ per kWh.

It would be great to have this option in the output when the energy readings are included. Though for those of us not in the USA, it would be nice to have it simply as "Cost per kWh" so that we can assume our own local units.

mapero commented 8 years ago

I would prefer a solution independent of the node itself. Why not just create a function on the output and post-process the values. Its more flexible. Including this into the node is not planned yet.

mapero commented 8 years ago

Add a function behind the node containing this:

var factor = 0.20

if (msg.payload.status) {
    msg.payload.status.cost = {};
    msg.payload.status.cost.day = msg.payload.status.day * factor;
    msg.payload.status.cost.week = msg.payload.status.week * factor;
    msg.payload.status.cost.month = msg.payload.status.month * factor;
}
return msg;

would this be sufficient?

TotallyInformation commented 8 years ago

Hi @mapero, thanks for your responses.

I can of course add the required data in a separate function node. However, Node-Red is meant to be about allowing non-programmers to create tools and services, especially for IoT. In addition, many flows are already long and complex, adding more nodes to get such simple data into place adds even more complexity.

Since the cost is already a feature of the official Smartplug apps, it seemed sensible to build it into this as well.

Not to worry if you don't want to add it, just thought it might be useful to others, not just myself.

mapero commented 8 years ago

Okay. I'll try to include it in the next update as optional selectable information into the status.