Custom Component: IoTaWatt Energy Monitor integration

That seems weird, either way I got the HACS version installed and working. Much better. Just something about having the entities tied to the device in the UI makes it easier to find stuff :slight_smile:

Couple things.

It would be nice if the device name was picked up from iotawatt. It would also be nice if the device name was in the entity name. So sensor.iotawatt_heatpump instead of just sensory.heatpump.

Also what is the difference between the _wh counter and the _wh_Accumuleted counter? These look to be both accumulative from what I can tell.

Is there a good way to convert the counters to kWh vs Wh?

Awesome addition! Thanks,

It used to be like that. The HA dev team didnā€™t approve it and we had to remove it.

Create a template sensor and divide by 1000

That is weird, and since I have iotawatt already setup I canā€™t easily rename the existing items.

Thanks got a template sensor setup. :slight_smile:

The _Wh sensors are reading the energy value starting from the 1st January of the year.
They arenā€™t suitable for calculating export/import value

The _accumulated ones are the energy value read since the iotawatt sensors were first setup.
They never reset

1 Like

Does anyone know if there is a way to reduce the polling interval for one or more IotaWatt measurements (IotaWatt inputs or outputs)? I would like to setup an HA automation that is triggered by a certain power level on an IotaWatt sensor, but for this use case (in my shed, turn on the power to the dust extractor when the saw starts) to be effective, HA would need to see the power change in less than a few seconds rather than wait 30 seconds or more.

Using Core IotaWata integration :slight_smile:

Donā€™t think it is possible at the moment Refresh Rate Ā· Issue #3 Ā· gtdiehl/iotawatt_ha Ā· GitHub

Since iotawatt publishes to mqtt, you could use NodeRed to monitor the same MQTT and trigger your automation within NodeRed.

NEVERMIND - Ignore above not sure why i was thinking iotawatt published to MQTT. Have not had my coffee yet.

1 Like

Youā€™ll have to modify the iotawatt integration ; and change that line:

You will get quite a bit of warnings when running as the _accumulated sensors store data in block of 30s and it will complain that itā€™s been queried too often ; but all the other sensors will be updated as expected.

1 Like

Iā€™ve created a pull request Add config option to iotawatt for scan_interval by amosyuen Ā· Pull Request #64755 Ā· home-assistant/core Ā· GitHub to add an option to customize the update interval.

1 Like

You will need to change the interval set for the update interval when querying the interval too:

from there:

set timespan=number_seconds

Abandoned the PR as per comment from frenck. We should be using a periodic automation that calls homeassistant.update_entity on one of the entities and disable polling on the integration. Iā€™ve verified that this works.

1 Like

I have tried this, with update_entity called every 5 seconds, but the logs show the automation only being triggered approximately every 30 seconds or so anyway. Is there a trick to getting it to actually run more frequently?

Hi - been getting this logged error for some time now and it does not appear to be a common problem.

Any clues would be appreciated. Connectivity errors maybe?

2022-01-30 14:21:48 ERROR (MainThread) [homeassistant.components.iotawatt.coordinator] Unexpected error fetching 192.168.2.162 data: 'NoneType' object has no attribute 'text'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/iotawatt/coordinator.py", line 65, in _async_update_data
    await self.api.update(lastUpdate=self._last_run)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 76, in update
    await self._refreshSensors(timespan, lastUpdate)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 161, in _refreshSensors
    query = query.text
AttributeError: 'NoneType' object has no attribute 'text'

There has been an open issue on GitHub about this for some timeā€¦ā€¦ AttributeError: 'NoneType' object has no attribute 'text' Ā· Issue #6 Ā· gtdiehl/iotawattpy Ā· GitHub

1 Like

thatā€™s just a waning log.
The _accumulated sensor measures the data by a block of 30s at a minimum, so itā€™s easier to query the new data accumulated from the last read.

Thereā€™s a warning if you call the update too often as there would be nothing to read.

For now edit iotawatt.py in your python folder and remove those lines:

Or maybe better, drop the log level to not include warning but info only

I still get that error all the time. It doesnā€™t seem to have an impact that I know of, but it is mildly annoying to see all the time. :slight_smile:

Thanks, I will look to see if can make that edit, though not sure I can when using HASSIO?

You may be able to change the log level in the configuration.yaml
I think that will be enough

So whatā€™s the procedure to recover when the iotawatt readings go negative? I had the iotawatt set up, and the energy dashboard accumulating data, and it was great. But we just finished a 47h power outage thanks to an ice storm, and when HA came back up it was reporting that Iā€™d used -880 kWh today.

I tried deleting all grid and individual devices from the energy dashboard and adding them back in, hoping it would reset the ā€œnowā€ valueā€¦ but no, they come back in with the massive negative values.

Am I going to need to delete the integration (default HA, nothing shows up in HACS) and add it back in to recover?