Custom Component: IoTaWatt Energy Monitor integration

Thanks @OzGav appreciate your help. Two sensors that look the same but one appears and one doesn’t.

Here are the entities in Dev tools

And here are the available entities in energy config filtered by “calc”
image

The Export entity is the problematic one and when i view “more info” in dev tools to see the history graph, it shows like everything is normal
image

Not sure why your (Riemann Sum) integration sensor isn’t showing up but you say you are using the HACS version of the IotaWatt. If so then you should have a sensor called sensor.exportabs_wh_accumulated. Trying using that one (and if it works you can remove those Riemann sum integrations)

@OzGav I cheated and grabbed the export value from the fronius integration which seems to work. I might come back to the IoTaWatt integration once it matures a little more. Thanks again for taking the time to help!

you don’t need to use integration with the HACS iotawatt version.

If export doesn’t work with the energy screen it’s most likely because the sign of the value is incorrect.
The HA Energy needs positive numbers for everything ; and the iotawatt gives signed value ; so typically solar and export would show up as negative.

So you need to invert the sign in the iotawatt settings.

You need to edit your output in the iotawatt and add ABS at the end of your expression for export.

The Energy screens need all value to be positive.

Your fronius will show the production from the solar, it typically has no idea on what your usage is , so it’s not the input you want.

Thanks @jyavenard , The HACS integration accumulated values is what generated the chart in my screenshot of the energy (my original post). I know its meant to just work but when i used the values I must have stuffed something up. The values were showing as wh, not kwh. Even discounting the unit difference the pattern was displaying the same way as my replica IoTaWatt chart was.

On the other comment, the solar is already positive and for export I created and used a positive version of export called exportabs ( (Mains min 0) abs). The export abs entity is what i had been using for my Riemann Sum which is why I was so confused it wasn’t working. Here are the export and solar values in IoTaWatt showing as positive. I am currently only using Fronius for export only so i think im okay. Solar and Import are captured from IoTaWatt.

sorry but I’m not sure I fully follow what you mean here.
Are you using the HA integration or the HACS’s iotawatt accumulated value?

What thing to keep in mind, the Energy screen uses the history of the sensors. You can’t change the units half-way.

So if you had first used a sensor that was using kWh and then changed to one using Wh but used the same name; it will add the Wh value to kWh and now everything appears like you have massive kWh usage.

You can’t change units half-way.
The Energy screen will deal with Wh just fine and present the data in kWh. You don’t need to adjust the unit.

If you change the input settings in the Energy screen, it will take up to two hours for the new value (and correct units) to appear there.

The value you see in the sensorname_wh_accumulated should be the same as what you get in the iotawatt graph if you checked the “Accrue” box.

@jyavenard Thanks again for taking your time to help me. I think you just answered my very confused questions, I didn’t understand the behavior around the change of units and timing. Sounds like my troubleshooting iterations effectively stuffed me up. Do you think I need to truncate/purge the history before i change over to start using the xx_wh_accumulated values or will it just correct itself over time?

it will never correct itself.

If you started with kWh and add Wh you will end up with everything showing as kWh forever and vice versa.

You need to remove the sensor from the energy screen completely. Then add the new one.

You can’t re-use your old entities you need to rename them so that they look like a different one

So to answer your last question, if you use xx_wh_accumulated in place of import_wh_calculated then all will work fine, and content will appear 2h later at the latest.

1 Like

Thanks @jyavenard for being so generous with your time, I changed to accumulated values and waited, all is working perfectly!

1 Like

Hey Guys,

Thanks for all the great work done on this integration.

Just confirming where we are at now - should i

  1. Install from HACS
  2. Go the Integration route.

I have two IOTAWATT - but for the sake of this exercise will initially only be doing one of them.

This unit is located in my main meterboard

I have a 3 phase house, batteries (AC Coupled so seperat to solar) and Solar.

So in total i have 12 clamps

1,2,3 - Clamps go to the grid feed in from the street
4,5,6 - Go to my sub board to give me total house consumption
7,8,9 - Go to my Solar Inverters
10,11,12 - Go to my batteries

I have each of these grouped as outputs

Batteries
Consumption
Grid
Solar

My batteries can either charge or discharge - so those clamps can be + or -
My Solar is always positive i.e. feeding the house
Consumption is always negative for the house loads
Grid can be either + or - depending on how much solar, if the batteres are selling to the grid or buying

Is there a singular source of information as to the best method to follow to get these integrated into the energy dashboard ?

Craig

I don’t believe so.

But the HA energy screen needs three data at a minimum:
1- Grid consumption (how much you are importing from the grid: e.g. what you pay for)
2- Return to grid (how much energy are coming out when your production exceed your usage)
3- Solar production.

All those three values must always be positive, it doesn’t matter if they are in Wh or kWh

If you have a battery two more are needed:
4- What goes into your battery
5- What comes out of your battery.

So you need to determine which outputs you need to define according to the above.

At a guess:
for 1; you would use (1+2+3) max 0
for 2: ((1+2+3) min 0) abs
for 3: (7+8+9)
for 4: (10+11+12) max 0
for 5: ((10+11+12) min 0) abs

(I’m assuming the value of 10+11+12 will be positive when the battery is charging, if it’s not swap the 4 and 5 expression)

As you can see, you don’t need the 4, 5 and 6 clamps. The value of each can be calculated from the others.

In the energy settings; assuming you are using the HACS version (or 2021.10 beta with the official iotawatt component) you will need to use the sensor that have “Accumulated” in the name.
This is essential for the type of calculations you are running, you can’t be using the simple Wh sensor.

Hope that helps.
Jean-Yves

Thanks for this - so i define new outputs on my iotawatt as you have specified and then use those.

I think i will wait for the new 2021.10 non beta and go with that.

rgards

Craig

You can use the HACS version today, it’s the same code without the silky restrictions HA enforces (like inability to rename a sensor)

1 Like

I noticed since a while that the refresh rate of the value of the sensors is significantly lower now? like an update every 30 sec while the native iotawatt interface is 1 sec.

Is there a way to have this integration display updates of the values more frequently?

30s is the default value used by HA.

Seeing the sensors you’re most likely going to use with HA are the energy ones, reading more often would provide no advantage whatsoever.

Consider also the impact on the database. HA stores the past two weeks worth and whenever iotawatt is used, it increases significantly (on mine the size of the DB more than tripled to over 1.5MB)

You can modify how often HA refreshes the sensor by editing the sensor.py file

I am looking at moving from using rest sensors to either this custom Iotawatt integration or the official one. I have setup the official one but doesn’t seem to be bringing through my outputs as configured in the Iotawatt as per the official HA docs.

Has anyone tried this? I can create a new thread but thought I’d quickly ask here first. Failing this I’ll just try this custom integration in place of the rest sensors

Works fine for me Dave, you are not getting any sensors being picked up? I am using the official integration, using the accumulated sensors.

Password protected maybe?

I’m getting all the iotawatt inputs coming through, but none of the calculated outputs

Gotcha, these are my outputs

image