Custom Component: IoTaWatt Energy Monitor integration

@djuniah What changes do you need to make?

Sorry, i edited my post because I had made a mistake. Things seem to be working now after manually adding all of my outputs to the config.yaml file like they mention on this page: IoTaWatt - Home Assistant

I didnā€™t realize that it needed to be done for each and every output (which in hindsight makes sense). Also, it seems like any custom outputs arenā€™t included in the list from the integrations menu. Theyā€™re just sensors not tied to anything specific. For example, in iotawatt, I created an output called ā€œUnknown Loadā€ which is the mains minus all of the circuits that Iā€™m monitoring (i donā€™t monitor all of them) and i had to search outside of the integrations list as it didnā€™t show up in there.

@djuniah There is a difference between the Inputs and Outputs currently. The underlying issue that there is only a Unique ID for the Inputs. Since only entities in Home Assistant with Unique IDs can be renamed and assigned, the Outputs are not grouped with the Inputs in the Entities page. There is an Issue #55489, which the result is a firmware update will send an ID so the Outputs have a Unique ID in Home Assistant.

Another change between the custom_integration and the official one is the removal of appending iotawatt_{I/O Type}_ to the sensor name. For example if you had sensor.iotawatt_input_spa it would be changed sensor.spa. Was this the reason you had to change the names in your config?

What is mentioned in the https://www.home-assistant.io/integrations/iotawatt/ page is for Solar systems where IoTaWatt is monitoring a single circuit that is both importing and exporting. The creation of two sensors is to split the positive and negative into two sensors so that you can use the sensors in the Energy Dashboard.

Any other issues you may have had?

Iā€™m getting an error (or at least a warning) when adding my sensors as described above - the error/warning states -

Unexpected state class
The following entities do not have the expected state class ā€˜total_increasingā€™

  • sensor.iotawatt_output_mainsconsumption_wh (measurement)
  • sensor.iotawatt_output_mainsexport_wh (measurement)

I had to add entries for each CT clamp and output into my config file before they would show up as being eligible for entry in the energy dashboard. It doesnā€™t seem like itā€™s just a solar thing. This is the section I was referring to ā€œAdd the following to your configuration.yaml file to convert the Watt measurements into kWh:ā€ Without doing that, none of my inputs/outputs were available to be selected on the energy dashboard. The sensor name change wasnā€™t related to what i had to do that. I assume thereā€™s no way to migrate and keep the old data due to them having unique IDs right?

This was a last-minute change made to the 2021.9.0 release. PR 55510

As @djuniah has mentioned above a configuration entry has to be added for each Watt sensor that you want Home Assistant to monitor in the Energy Dashboard. Reading the PR the reasoning to remove the state class is:

Remove the total_increasing state class from the Wh entities. These entities represent net usage. So if you have solar they would actually go down too. Itā€™s currently not possible to figure out which one is which, so dropping state class.

Iā€™ve been talking with the developer of IoTaWatt, and trying to figure a way (maybe in firmware or a change to the integration) where the sensor is always increasing so that the sensor can be added to the Energy Dashboard.

With that, it really comes down to either continue to use the custom_component with <= 2021.8.x or update to 2021.9.0 use the official one and (for now) add sensors to your configuration file as noted below in the example:

sensor iotawatt:
  - platform: integration
    source: sensor.mainsexport
    name: Total Grid Export
    unit_prefix: k
  - platform: integration
    source: sensor.mainsconsumption
    name: Total Grid Consumption
    unit_prefix: k
...

Note that going through the integration path has downsides.

the iotawatt integration in HACS wonā€™t have those ; Iā€™m hoping to get those merged in HA proper Add iotawatt high-accuracy energy readout sensors by jyavenard Ā· Pull Request #55512 Ā· home-assistant/core Ā· Gi

Yeah it didnā€™t take long to set up, I had just assumed that it would be the same thing I had been using, just integrated into HA instead of through HACS. Either way though, iā€™m all set up and running now (albeit with my last months worth of history erased) and wanted to say thanks again for all of the work being put in to this integration!

1 Like

Thank you @djuniah!

Iā€™ll see about getting the custom_component updated to work with HA 2021.9.0 in the meantime.

Iā€™ve just setup the Integration (was not using the custom component before) and for some reason itā€™s pulling in the ā€˜Inputsā€™ not the ā€˜Outputsā€™. Any suggestions?

It is pulling the outputs, just that Paulus from HA didnā€™t want to give them a unique_id and not make them configurable. So they are classified as a generic sensor rather than be a iotawatt entity.

Itā€™s a very unfortunate choice; and as a last minute change we can no longer use the energy sensor directly in the Energy screen.

2021.9 was pulled today ; if you are still running 2021.8 HACS, @gregtd has merged all my changes and the iotawatt integration is now version 0.1.1 : it adds high resolution energy sensor you can directly use your import/export rule directly in the energy screen.

1 Like

Iā€™m having one of those days, I noticed that comment above in the thread but my brain didnt kick in and work out I was seeing the same thing! On checking all the Outputs are there. Thx :slight_smile:

1 Like

I know there has been a bit of churn regarding the sensor names over the past few releases. Which then creates more overhead. And the historical data is lost.

Now with the 0.1.1 release the custom component version and the official Home Assistant integration should have the same sensor names. Which should be an easier transition in the future.

I updated to 2021.9 and switched to using the non-hacs iotawatt, however, none of the readings are accurate at all aside from the total_grid_consumption. Since setting that up this morning it shows 17kWh consumption, which seems accurate based on what I was getting before upgrading. However, everything else is all jacked up, for example, the ac_wh is showing 486,094 Wh. Just my office is showing 75,146 Wh. In Iotawatt when I look at the graph+ stats, it says my AC is 27.9 kWh, and office is 5.57 kWh. Not sure what is going on, wish I had looked at this thread before upgrading to .9, since the iotawatt hacs was working great. Anyone else whoā€™s upgrading seeing these crazy large numbers on the sensors? Am I missing something?

@Na3blis Where are you seeing the values? In the Energy Dashboard?

Did you create integration sensors in your configuration.yaml for each of your input and output sensors? What does the confit look like?

I did not, I had 17 sensors automatically created, the only one I manually created was the mainsexport (which I donā€™t actually need) and mainsconsumption. So the sensor.ac_wh I assumed is created like it was in the hacs version. I have:

sensor iotawatt:
  - platform: integration
    source: sensor.mainsexport
    name: Total Grid Export
    unit_prefix: k
  - platform: integration
    source: sensor.mainsconsumption
    name: Total Grid Consumption
    unit_prefix: k

And then in my template.yaml I have several sensors like this:

- sensor:
    - name: "AC kWh"
      unit_of_measurement: "kWh"
      state:  "{{ (states('sensor.ac_wh')| float / 1000) | round(2) }}"

The energy dashboard did not allow me to import any of the sensors that iotawatt generated. But Iā€™m seeing these when I click on the entity, then click the icon in the top right that displays the value and the chart. hereā€™s a screenshot

Reading through the entries Iā€™m uncertain if I should transition from custom component to the integration or not.

Are the instructions on the integration page still current? Do I still need to configure iotawatt?

This is what I currently have in sensor.yaml using the custom component. Is there anything I need to change?

- platform: integration
  source: sensor.iotawatt_input_mainspower
  name: energy_used
  unit_prefix: k
  round: 2
  method: left

Do I just install the new integration and delete the one from HACS? There seems to quite a few changes, so I am a bit uncertain about changing over.

There seems to be some confusion with the documentation that is on the HA website IoTaWatt intergration.

The sensors mainsexport and mainsconsumption are just examples. These examples are based on the other example that is shown on the website that creates two Outputs in the IoTaWatt web interface.

I didnā€™t author the website, but am trying to put something together this weekend.

This gist is if you are running HA 2021.9.0 (or 2021.9.1 as of today) and using the official integration (not the HACS integration) and if you have one IoTaWatt input monitoring a circuit that is for your solar panels, this circuit is doing both importing and exporting energy. This means positive and negative values could be sent from IoTaWatt to Home Assistant. To mitigate this issue the user first needs to configure two Outputs in the IoTaWatt web interface, as is shown in the graphic in the link I referenced above. Then from in Home Assistant you need to create two sensors, this is where mainsexport and mainsconsumption comes to light. If you followed the example and named the Outputs in IoTaWatt as per the example they need to match in the configuration in Home Assistant. If you named the Outputs differently then well use your names.

Now the above is if you have solar. If you donā€™t have solar, not monitoring solar, or monitoring solar but donā€™t have both import and export energy through a single CT clamp (Input) attached to an IoTaWatt then you can ignore the above. But there is more!

Now for any sensors (Input or Output) from the IoTaWatt with a unit type of Watts that you want Home Assistant to use in the Energy Dashboard you have to create an entry in your configuration for each sensor. If you have a total of 30 sensors you need to create 30 entries.

In your case from your template file I assume you have a sensor named sensor.ac. This should be the sensor from the IoTaWatt but with a type of Watts You would need to add this entry (you can change the Name to whatever you want I just gave it Main AC) in your configuration file to have the Energy Dashboard accept it.

sensor iotawatt:
  - platform: integration
    source: sensor.ac
    name: Main AC
    unit_prefix: k

If you actually donā€™t have sensors with the name of sensor.mainsexport or sensor.mainsconsumption you can remove those from your config.

I know this is very long! And Iā€™m sorry but some things are out of my control. Anyway I have released a beta release of the HACS custom_component for IoTaWatt that supports HA 2021.9. Still be tested but it only needs a sensors added to the configuration if you have solar and need to split the import and export into seperate sensors.

3 Likes

@currest2620 I think you read my very long post! But I wanted to follow up anyway. If you are running HA 2021.9 and want to move from HACS custom_component to the official release, you would have to have an entry in the config file for each sensor you want to appear in the Energy Dashboard. As well I think some are looking for the entities in the Entities when itā€™s filter by the IoTaWatt integration. After moving to the official version the Entities page may appear to not have your sensors, but if you clear the filter the sensors will be seen just they appear as with the integration name of Sensor. The beta version will also have this too as I wanted to be a bit consistent with HA until the Unique ID issue is resolved.

Thanks for that. I think I get it. My setup is as simple as it gets. I just have volts and power for one zone / whole house. Should be pretty straight forward I think.

1 Like