I started a rule in RM to watch my Aeotec Home Energy Monitor. The first part of the rule took the value of 'Power' from the monitor (which is updated every 30 secs) rounded it and copied it to a Hub Variable. It also took the 'Energy' value (updated every minute), rounded it and did some math to get the cost. It's a messy rule as each calculation is an additional operation. I wanted to try setting it up in node red instead but I'm struggling.
For the first part I'm just trying to round the value and write it back to a Hub Variable. The Hubitat device node is set as shown and the output is as below:
Any pointers as to what node goes between the Device and Command nodes (function I guess?) and how to set it up? Apologies I'm brand new to node red so I'm struggling with the basics.
This is above my head, but I have had an Aeotec HEM updating every 5 seconds for the last couple months, lol.
I have no idea if this will help, or if you've already done this, but I had to change a bit of the driver code to get the values from string to number. Then, I at least, could do more stuff with readings.
This is on the Aeotec Home Energy Monitor 2 phase (Gen 5) driver.
@velvetfoot - Mine already seems to output number rather than string. I used a driver that someone from Aeotec modified so not sure if we're using the same one.
I've managed to progress one small step. I found the node-red-contrib-calc and inserted that after my device node and set it as follows:
That rounds the value as I wanted but I can't get that rounded value to update the variable. I could do all of this in Rule Machine but I think it would be better to hand it off to node red if I can fathom out how.
Stuck with how to setVariable to the output of the previous node. Without an argument set I'm just getting the following in logs for the variable I'm trying to set:
Solved - I found the answer in another thread linked below. I needed a change node in order for the Hubitat Command node to know what to do with the value. So thanks to @JasonJoel
@FriedCheese2006 - I was...I wanted to see whether I could set up either RM or Node Red to give me what I wanted (cost calculation including the standing charge) and the other displayed items from one source. On my dashboard I want:
power. I can't take it directly from the Aeotec HEM as I need to round it, so need to run that through RM or node red
energy for the day
cost for the day (inc standing charge)
accumulated weekly, monthly cost and energy
I think the table in your app shows everything, but there are only variables created for some items. I don't want the table myself - just the values from it.
Several versions ago I updated your app and something broke. After the update it hung when I ran it so I had no choice but to delete it as it dragged the hub down. Also using RM or Node Red, I reset the energy use at midnight which messes things up for your app.
I think I probably will have to use a combination of your app and Node Red/RM to get what I want. It's probably easiest for me to take the cost calls from variables in your app, add the standing charges as applicable and output them to my own hub variable to display.
I'm probably not going to do anything for this since it's the power value. What is your use-case that you need the power value rounded?
I presume you're just looking for this in a variable to use elsewhere. Creating the ability to map any value in the table to a variable is in the works. I wanted to create the hub variable using the app, but the decision was made to remove that capability through the hub variable API. Presumably because you could easily overwhelm a hub with a little bit of bad code this way.
I started working on this yesterday.
I grab everything at a few seconds after midnight...so if you did this at midnight and 30 seconds instead, or not at all, it'd be fine.
Did a reboot not resolve? Do you recall if there was an actual error or was it just hanging? I know there have been reported performance issues with the last few Hub firmware updates. I ran into it last night. Went to update an app through HPM. It got a about halfway through installing the updates (multiple modules) and just hung. The whole admin UI wouldn't do anything....couldn't get to the logs, navigate to other pages, etc.. I ended up having to use the diagnostic tool to reboot. Once it came back online, I went into HPM and updated the same app without issue.
I'll give that another try. My rules reset energy at 00h:04m. Maybe I'm mistaken and it's because while I was setting up my rule I reset the energy during the day.
I didn't reboot. When I say it hung - I updated your app through HPM and when I tried to open your app to look at the changes it wouldn't open. Immediately after I deleted your app, CPU started to rise and rise until I had to shutdown at about 90%. I've not a clue what went wrong, that was on 3.4.132, I updated to .134 last night as I was still seeing occasional large spikes in cpu.
I think there's something else afoot with the performance issues.
I have two hubs. One of which has an instance of my app that has been there since the beginning. I installed it from HPM. Every time I make a code change, I update the app for that hub via HPM and make sure it doesn't break my existing install. I also create a new instance and go through basic initial setup. Through all this, I keep an eye on the app stats to make sure nothing unusual creeps up (although this is jaded since small spikes wouldn't be obvious in the apps stats).
I think the Aeotec HEM sends it out with three decimal places as it does for energy. For watts I only want a whole number as it's irrelevant other than using as a quick and dirty 'what am I using this instant'. For KW/h I was using the raw figure for calculations, then rounding it down to 2 decimal places for display purposes.
Exactly. I've no issue manually creating all of the variables so that would be good and would make my Node Red flow redundant (though it has been useful for me to learn a little more)
Standing charge would be great . Or even just somewhere to add a positive offset so that your daily costs are always "calculated cost plus x"