Custom Component: IoTaWatt Energy Monitor integration

Ah yes, thanks for that!

1 Like

Youā€™d have to use another chart such as Lovelace History Graph Card to plot the voltage. Sorry about that. What I meant earlier was to create a custom lovelace view and combine the Energy Dashboard graphs with a Lovelace History Graph card.

Is there a specific reason you want to chart voltage?

No worries, no big deal. I can plot it on another chart card and/or go to iotawatt itself. I became more interested in voltage after a recent incident. The voltage in my set of units started to fluctuate quite a bit. Turns out there was an issue with it going to ground and becoming a significant safety risk. Iā€™ve been more conscious of voltage as a result.

Thanks for responding.

Thanks heaps itā€™s appearing in EmonCMS now. Although in the IoTaWatt EmonCMS config I havenā€™t been able to add any calculated outputs. There is no save button.

The logs are showing the EmonCMS is running and I can see updated data in the EmonCMS server

Ill add it here; but if you are using a calculated output, it seems Iotawatt has an issue. While this is an issue with Iotawatt, having it in there might be useful for someone else:

API query not accruing correctly when using min/max Ā· Issue #303 Ā· boblemaire/IoTaWatt (github.com)

Perhaps try removing the whitespace in the name? ā€œTotal Powerā€ ā†’ ā€œTotal_Powerā€

Perhaps this is what is preventing the SAVE button from appearing? Just a guess.

SOLVED. It was because I needed to use numbers not text for the names.

1 Like

How do you add this repo to HACS?

Itā€™s not showing in the list of available integrations.

TIA

Start by adding the GitHub repo to HACS, using the Custom Repositories option as shown below.

Thanks I had this sorted.

Now, I have my stuff setup so that solar is a negative power input as the iota adds all value to determine max actual power usage.

This appears to mess up the HAā€™s energy screen and it could it all as zero.

But I guess itā€™s something I should deal with the HA folks directly.

Can someone who has the iotawatt feeding the new HA energy panel give some examples of how you created your outputs from iotawatt to satisfy what the HA panel is asking for - particularly the ā€˜grid consumptionā€™ and ā€˜return to gridā€™.

Here is what Iā€™ve tried. I have a solar array feeding my panel so my consumption output is - consumption W=(main1+main2+solar) max 0

I donā€™t know how to handle the ā€˜return to gridā€™ bit.

Thanks in advance.

Return to grid: if main1+main2 < 0 = abs(return to grid)

Export=((main1+main2+solar) min 0) abs

abs because HA wants a positive number

Iā€™m having a weird issue with this HA integration.

Almost everything works okay. But the output counter of HA.

I can query the value in Wh just fine from the iota watt:
http://iotawatt.local/query?select=[time.utc,Export.wh]&begin=2021-08-18&end=2021-08-19&format=csv&group=m

And I will get the values Iā€™m expecting.
But in HA, that value in Wh is always 0.

Just in case it had trouble dealing with negative numbers, I created an output that is the absolute value of it.
And that too always read 0.

None of the others sensors are reading 0.

Any ideas ?
Edit: after retrieving the iotawattpy python bit; I found what URI the integration is querying, and itā€™s the iota watt that is always returning 0; Iā€™ve asked in the iota watt forums to find out whatā€™s going on.

Another option is to get the absolute value using a template in HA.

It would look something like this:

- platform: template
  sensors:
    energy_solar1_wh:
      friendly_name: "Solar1 Energy"
      unit_of_measurement: Wh
      device_class: energy
      value_template: "{{ states('sensor.iotawatt_input_solar1_wh')|float|abs }}"
      attribute_templates:
        last_reset: "{{ state_attr('sensor.iotawatt_input_solar1_wh', 'last_reset') }}"
        state_class: "{{ state_attr('sensor.iotawatt_input_solar1_wh', 'state_class') }}"

that takes the existing sensor.iotawatt_input_solar1_wh and create a energy_solar1_wh sensor that is positive but otherwise have exactly the same properties as the original.

The way I read the energy config settings which are listed as Configure the amount of energy that you consume from the grid and, if you produce energy, give back to the grid.
ā€˜Consume from the gridā€™ does not include solar if (in my case) solar comes into the panel below the mains - just on a circuit in the panel. And ā€˜give back to the gridā€™ as power exported. My equations are -
Grid Consumption = (Main1 + Main2) max 0 ā† values always positive or zero
and Return to the Grid = ((Main1 + Main2) min 0) abs ā† values always positive or zero
So, in effect, itā€™s a net meter - just both values being positive.

BUT - I donā€™t think this is working for me as my numbers in the Energy tab arenā€™t adding up (and they do in the iotawatt app).

Any thoughts?

You may want to read the thread I opened about it there: Wrong values returned by REST API? - #8 by jyavenard - Support - IoTaWatt User Community

the iota watt is just not suitable for calculating import/export.
The way the HA iota watt plugin is querying the iotawatt is asking for the data from the beginning of the year to the last second.
The way the iota watt will calculate those values is taking the sum of the averages and not the average of the sums. It has to as otherwise the processing power required would greatly exceed what its poor processor can do.

So as it is today, if all you have is a HA instance and a iotawatt your energy screen report will be wrong.

Something is a bit fishy with this integration.

Today I noticed that it didnā€™t have any info for the day.
HA was showing that the last time the sensor had been updated was 18 hours ago.
I restarted HA and now itā€™s showing twice the values for each of the iota sensors.

I wonder if thereā€™s a bug with the last reset value ; itā€™s set to be the first day of the current year ; but shouldnā€™t that be the last restart time?

What extra would you need to have it work correctly?

You would need to store the iotawatt values in a database and run the query there; or query through another way.
Getting it all done in a database isnā€™t the most simple things to do.

The way electrical utilities measure import and export, they have two distinct counters and they are updated instantly independently from one another.
The iotawatt samples several times per second.

Iā€™ve been doing this for many years for tracking my solar (you can see my site there Power Tracker - Usage - 19/08/2021)
The way I do it here is that every minutes I calculate the average of the power usage and the Wh produced by the solar inverters (I donā€™t look at the W value, only the energy)
From the power usage, I estimate the Wh value and then simply do a diff with the solar energy. If negative it adds to export, if positive to import.
While this isnā€™t as accurate as what the electrical meter measures as itā€™s rounded to the nearest minute, itā€™s good enough and Iā€™m usually within a 1-2% of what Iā€™m actually billed for.
We could then just increase some counters and present that to HA via a simple web server and have HA query it via the REST integration.

In the mean time, the iotawatt monitor integration is hammering the iotawatt, its CPU must be going like crazy. Would be good to not have it query the iotawatt constantly for which input/output that are set and query them all, all the time.