Code Monkey home page Code Monkey logo

iotawatt_ha's People

Contributors

agners avatar cgarwood avatar gtdiehl avatar jyavenard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

iotawatt_ha's Issues

Error starting integration since HA 2023.5 upgrade

After upgrading to Homassistant 2023.5, this integration no longer works.

The HA log file shows following error:

Logger: homeassistant.config_entries
Source: custom_components/iotawatt/init.py:16
Integration: IoTaWatt
First occurred: 09:05:55 (1 occurrences)
Last logged: 09:05:55
Error setting up entry iotawatt for iotawatt

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/iotawatt/init.py", line 16, in async_setup_entry
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'

Entering wrong credentials does not stop setup

During setup of the IoTaWatt if the user enters the wrong credentials the setup continues and the log is flooded with these exceptions:

2021-08-27 21:09:37 ERROR (MainThread) [homeassistant.components.iotawatt] Unexpected error fetching IoTaWatt data: Expecting value: line 1 column 1 (char 0)
Traceback (most recent call last):
  File "/workspaces/core/homeassistant/helpers/update_coordinator.py", line 187, in _async_refresh
    self.data = await self._async_update_data()
  File "/workspaces/core/homeassistant/components/iotawatt/__init__.py", line 106, in _async_update_data
    await self.api.update()
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 66, in update
    await self._refreshSensors(timespan)
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 101, in _refreshSensors
    results = json.loads(results)
  File "/usr/local/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

In the Configuration >> Integrations page the tile will be red indicating a problem. User can delete and re-add using the correct credentials.
Screen Shot 2021-08-27 at 2 16 29 PM

Remove last_reset attribute

Starting in Home Assistant Core 2021.11 the last_attribute will be deprecated. Need to remove this attribute to avoid users seeing the below message for each entity that is using the attribute.

2021-08-27 21:57:49 WARNING (MainThread) [homeassistant.components.sensor] Entity sensor.iotawatt_output_subpaneltotal_wh (<class 'homeassistant.components.iotawatt.sensor.IotaWattSensor'>) with state_class measurement has set last_reset. Setting last_reset is deprecated and will be unsupported from Home Assistant Core 2021.11. Please update your configuration if state_class is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+iotawatt%22

All outputs are missing in 0.1.1

After upgrading to 0.1.1 new sensors were created. As per warning notice iotawatt_something prefix was removed. However, only input sensors are present. I wonder how it is expected to work if I name output sensor the same as input?
Regardless, it is simply broken.
I tried this 2021.9 embedded one with exactly the same result.

Can't find integration in HACS

I just recently installed an IoTaWatt and started using Home Assistant and stumbled across this integration while trying to resolve issues with the currently built-in integration. I installed HACS, but this integration is not showing up when I search in HACS under integrations. Has this integration been removed by HACS, or is there something else I need to do to add this integration through HACS?

Unexpected state class

Trying to use the builtin integration in homeassistant and am getting the following for any of the inputs I choose:

Unexpected state class
The following entities do not have the expected state class 'total_increasing'
sensor.mains_1_wh
sensor.mains_1_wh_2
sensor.mains_2_wh
sensor.mains_2_wh_2

Home Assistant 2021.9.7 (Version | core-2021.9.7)

Removing sensor from IoTaWatt device causes errors

When removing a sensor from the IoTaWatt webpage, Home Assistant tries to update the state of the removed sensor and results in the errors in the log to appear for every poll

Traceback (most recent call last):
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/update_coordinator.py", line 119, in _handle_refresh_interval
    await self.async_refresh()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/update_coordinator.py", line 193, in async_refresh
    update_callback()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/update_coordinator.py", line 245, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 296, in async_write_ha_state
    self._async_write_ha_state()
  File "/Users/greg/Documents/GitHub/core/homeassistant/helpers/entity.py", line 320, in _async_write_ha_state
    sstate = self.state
  File "/Users/greg/Documents/GitHub/core/homeassistant/components/iotawatt/sensor.py", line 89, in state
    return self.coordinator.data["sensors"][self._ent].getValue()
KeyError: 'output_mhghjk'

Energy use - wh vs wh_accumulated?

Does anyone know what the difference is between the wh and wh_accumulated sensors? I'm thinking wh_accumulated might be a bug?

In looking at the change over the past 24 hours…I know from the power company’s meter I seem to average around 60-80kWH in a day in “mild” weather.

According to the IoTaWatt device directly “energy” output:total_power (L1+L2) sensor graph directly: 24894−24840 = 54 (this seems a tad low for my daily kWH usage, but its been mild/cloudy and today was my first day “back at the office” vs work from home so maybe correct without HVAC, lights, or cooking at home)

According to sensor.iw_total_power_wh graph: 10288519−10234315 = 54204 (this seems to match the IoTaWatt kWH usage graph for 24 hours)

According to sensor.iw_total_power_wh_accumulated graph: 5101237−4832827 = 268410 (this seems impossibly high for watts used today - even on the coldest single-digit-temperature sub-freezing days running tons of electric backup-heat, spaceheaters, and hot water we only use maybe 250kWH in a 24 hour period)

SO…I have zero clue where this comes from or what it represents. Anyone have a guess?

Issues with wh for a particular "solar surplus" output

Pardon the double-post. I'm honestly not sure if this is an issue with the API or the integration. Want to make sure it gets visibility from the HA integrators:

I'm having a terrible time getting a "Solar Surplus" output showing up in HA.

HA seems to want a "return to grid" sensor rather than just looking at negative grid_total values (which would make more sense to me, but whatever). So i created an output called "Solar_Surplus" that looks like this:

Watts = 0 max (-1 x (Main_1 + Main_2))

(alternately, also tried this:)

Watts = 0 max (0 - main_1 - main_2)

The wattage sensor works just fine, but I get 0 kwh for the _kw version. It also appears to never refresh until an HA restart.

FYI, my Grid_Consumed output works just fine, with

Watts = 0 max (Main_1 + Main_2)

Any suggestions? On the Iotawatt itself using the Graph+ UI, i can see these guys no problem in WH over a year, month etc. Tried recreating, adding additional outputs with different names and the same query, and none of them work.

Unable to prepare setup for platform iotawatt.sensor: Platform not found (cannot import name 'VOLT' from 'homeassistant.const'

Logger: homeassistant.setup
Source: setup.py:311
First occurred: August 3, 2021, 10:43:34 AM (2 occurrences)
Last logged: 12:19:05 PM

Unable to prepare setup for platform iotawatt.sensor: Platform not found (cannot import name 'VOLT' from 'homeassistant.const' (/usr/src/homeassistant/homeassistant/const.py)).

I'm getting the following error when loading the iotawatt integration. This has started occurring since the core-2021.8 update.

Sensor state isn't updated unless the value change.

The consequence of this problem was discussed in :
https://community.home-assistant.io/t/custom-component-iotawatt-energy-monitor-integration/254110
in which I noticed an issue when calculating the integration of a power sensor in order to get the energy accumulated since the last read.
I also opened that bug: home-assistant/core#55130

What we see is that when integrating the power sensor some datas were ignored, causing the integration to return invalid result.

However, after writing a little automation writing to a file whenever a sensor was updated:

- alias: Log iota sensors
  trigger:
    - platform: state
      entity_id:
        - sensor.iotawatt_output_export
        - sensor.iotawatt_output_import
        - sensor.power_grid_export
        - sensor.power_grid_import
        - sensor.energy_grid_export
        - sensor.energy_grid_import
        - sensor.daily_exported_energy
        - sensor.daily_purchased_energy_peak
        - sensor.daily_purchased_energy_offpeak
  condition: []
  action:
    - service: notify.sensor_update
      data:
        message: "{{ now() }} {{ trigger.to_state.entity_id }} : {{ states(trigger.to_state.entity_id) }}"
  mode: queued
  max: 10

it quickly became evident on what was happening:

in there I see every 30s:

2021-08-24T13:00:58.948066+00:00 2021-08-24 23:00:58.931224+10:00 sensor.iotawatt_output_import : 956.7
2021-08-24T13:00:58.990680+00:00 2021-08-24 23:00:58.980965+10:00 sensor.power_grid_import : 956.7
2021-08-24T13:00:59.042709+00:00 2021-08-24 23:00:59.016679+10:00 sensor.energy_grid_import : 27.988
2021-08-24T13:00:59.090497+00:00 2021-08-24 23:00:59.083603+10:00 sensor.daily_purchased_energy_offpeak : 16370.645
2021-08-24T13:01:29.427267+00:00 2021-08-24 23:01:29.409896+10:00 sensor.iotawatt_output_import : 920.4
2021-08-24T13:01:29.454557+00:00 2021-08-24 23:01:29.446324+10:00 sensor.power_grid_import : 920.4
2021-08-24T13:01:29.516071+00:00 2021-08-24 23:01:29.485562+10:00 sensor.energy_grid_import : 27.996
2021-08-24T13:01:29.617179+00:00 2021-08-24 23:01:29.576890+10:00 sensor.daily_purchased_energy_offpeak : 16370.653
2021-08-24T13:01:58.775600+00:00 2021-08-24 23:01:58.767084+10:00 sensor.iotawatt_output_import : 991.8
2021-08-24T13:01:58.814723+00:00 2021-08-24 23:01:58.800374+10:00 sensor.power_grid_import : 991.8
2021-08-24T13:01:58.844214+00:00 2021-08-24 23:01:58.834699+10:00 sensor.energy_grid_import : 28.003
2021-08-24T13:01:58.874055+00:00 2021-08-24 23:01:58.864241+10:00 sensor.daily_purchased_energy_offpeak : 16370.660
2021-08-24T13:02:29.437440+00:00 2021-08-24 23:02:29.413309+10:00 sensor.iotawatt_output_import : 929.6
2021-08-24T13:02:29.518908+00:00 2021-08-24 23:02:29.472959+10:00 sensor.power_grid_import : 929.6
2021-08-24T13:02:29.584119+00:00 2021-08-24 23:02:29.577050+10:00 sensor.energy_grid_import : 28.012
2021-08-24T13:02:29.632731+00:00 2021-08-24 23:02:29.621587+10:00 sensor.daily_purchased_energy_offpeak : 16370.669
2021-08-24T13:02:58.854691+00:00 2021-08-24 23:02:58.834879+10:00 sensor.iotawatt_output_import : 957.5
2021-08-24T13:02:58.889165+00:00 2021-08-24 23:02:58.881409+10:00 sensor.power_grid_import : 957.5
2021-08-24T13:02:58.930739+00:00 2021-08-24 23:02:58.913406+10:00 sensor.energy_grid_import : 28.019
2021-08-24T13:02:58.959762+00:00 2021-08-24 23:02:58.949684+10:00 sensor.daily_purchased_energy_offpeak : 16370.676

the iota output sensor for the export output (which would be 0 at this time of night) aren't updated.
As such when dealing with data points that should be:
(00:00:00, 0)
(00:00:30, 0)
(00:01:00, 0)
(00:01:30, 0)
... repeat
(08:59:30, 0)
(09:00:00, 188.1)
(09:00:30, 205)

what the integration gets to be provided is in fact:
(00:00:00, 0)
(09:00:00, 188.1)
(09:00:30, 205)

And so the first data entered at 9AM will be 188.1W9h = 1.692kWh
instead of 188.1W
30s = 188.1W*30/3600h = 0.0015675kWh

The sensors must be updated even if the value isn't changing as it otherwise can't be used with the HA integration and provide an accurate result.

Submit to Home Assistant Core

Home Assistant will have a new added focus on energy management in the next release. We're trying to get as many energy related integrations part of core.

Your integration is great. Would you want to submit it to core?

Edit: to avoid unnecessary noise, please don't comment with "+1" or similar. Just use the thumbs up reaction on the first post.

Refresh Rate

Is there a way to increase the refresh rate, say 10 or 15 seconds?

Confused with current versioning, and HACS vs HA built-in.

I appear to be running iota watt_ha 0.0.8 in HA 2021.9.1 and I have manually created 'integration' sensors, and things appear to be working as they should.

I assume that the HA in built version was supposed to automatically create these 'integration' sensors, as the 'wh' sensors from the iota watt itself dont appear to be of much use (due to an API limit/bug?).

I really don't want to much around too much with my Energy Dashboard in HA as it seems to be working, but I am not sure if I should update my HACS install, or use the HA built in version?

Can someone please give me some advice?

Multi-IoTaWatt setup issue with identical inputs

Hi,

first of all thanks for your work, I am new to HA and I am currently testing your integration. I have 3 IoTaWatt units in use (one for each phase). With that setup I have notices an issue with your integration:

If I have two inputs with the same name in multiple IoTaWatt units, the entities cannot be created properly. For me this is the case for the voltage, which is named the same in each and every unit. Maybe it would be a good idea to add a prefix to every entitiy name tha represents the IoTaWatt unit to which it belongs.

Sensor isn't updated until a new different value is read

This is an issue I discussed in https://community.home-assistant.io/t/custom-component-iotawatt-energy-monitor-integration/254110/107?u=jyavenard

iota_integration

What we can see when dragging the mouse over that graph, we can see that there were no updates to the sensor until 9:00:39 where it reads -188.1W

As I use the Riemann Sum integration with the right method, it considers that -188.1W is the average wattage since the last read.
so 0.1881kWh * 9h = 1.06kWh will be what the first value stored will be for the Export Energy for the day; skewing the result of the entire day.

I had opened that bug: home-assistant/core#55130

After writing a little automation writing to a file whenever a sensor was updated:

- alias: Log iota sensors
  trigger:
    - platform: state
      entity_id:
        - sensor.iotawatt_output_export
        - sensor.iotawatt_output_import
        - sensor.power_grid_export
        - sensor.power_grid_import
        - sensor.energy_grid_export
        - sensor.energy_grid_import
        - sensor.daily_exported_energy
        - sensor.daily_purchased_energy_peak
        - sensor.daily_purchased_energy_offpeak
  condition: []
  action:
    - service: notify.sensor_update
      data:
        message: "{{ now() }} {{ trigger.to_state.entity_id }} : {{ states(trigger.to_state.entity_id) }}"
  mode: queued
  max: 10

it quickly became evident on what was happening:

in there I see every 30s:

2021-08-24T13:00:58.948066+00:00 2021-08-24 23:00:58.931224+10:00 sensor.iotawatt_output_import : 956.7
2021-08-24T13:00:58.990680+00:00 2021-08-24 23:00:58.980965+10:00 sensor.power_grid_import : 956.7
2021-08-24T13:00:59.042709+00:00 2021-08-24 23:00:59.016679+10:00 sensor.energy_grid_import : 27.988
2021-08-24T13:00:59.090497+00:00 2021-08-24 23:00:59.083603+10:00 sensor.daily_purchased_energy_offpeak : 16370.645
2021-08-24T13:01:29.427267+00:00 2021-08-24 23:01:29.409896+10:00 sensor.iotawatt_output_import : 920.4
2021-08-24T13:01:29.454557+00:00 2021-08-24 23:01:29.446324+10:00 sensor.power_grid_import : 920.4
2021-08-24T13:01:29.516071+00:00 2021-08-24 23:01:29.485562+10:00 sensor.energy_grid_import : 27.996
2021-08-24T13:01:29.617179+00:00 2021-08-24 23:01:29.576890+10:00 sensor.daily_purchased_energy_offpeak : 16370.653
2021-08-24T13:01:58.775600+00:00 2021-08-24 23:01:58.767084+10:00 sensor.iotawatt_output_import : 991.8
2021-08-24T13:01:58.814723+00:00 2021-08-24 23:01:58.800374+10:00 sensor.power_grid_import : 991.8
2021-08-24T13:01:58.844214+00:00 2021-08-24 23:01:58.834699+10:00 sensor.energy_grid_import : 28.003
2021-08-24T13:01:58.874055+00:00 2021-08-24 23:01:58.864241+10:00 sensor.daily_purchased_energy_offpeak : 16370.660
2021-08-24T13:02:29.437440+00:00 2021-08-24 23:02:29.413309+10:00 sensor.iotawatt_output_import : 929.6
2021-08-24T13:02:29.518908+00:00 2021-08-24 23:02:29.472959+10:00 sensor.power_grid_import : 929.6
2021-08-24T13:02:29.584119+00:00 2021-08-24 23:02:29.577050+10:00 sensor.energy_grid_import : 28.012
2021-08-24T13:02:29.632731+00:00 2021-08-24 23:02:29.621587+10:00 sensor.daily_purchased_energy_offpeak : 16370.669
2021-08-24T13:02:58.854691+00:00 2021-08-24 23:02:58.834879+10:00 sensor.iotawatt_output_import : 957.5
2021-08-24T13:02:58.889165+00:00 2021-08-24 23:02:58.881409+10:00 sensor.power_grid_import : 957.5
2021-08-24T13:02:58.930739+00:00 2021-08-24 23:02:58.913406+10:00 sensor.energy_grid_import : 28.019
2021-08-24T13:02:58.959762+00:00 2021-08-24 23:02:58.949684+10:00 sensor.daily_purchased_energy_offpeak : 16370.676

the iota output sensor for the export output (which would be 0 at this time of night) aren't updated.
As such when dealing with data points that should be:
(00:00:00, 0)
(00:00:30, 0)
(00:01:00, 0)
(00:01:30, 0)
... repeat
(08:59:30, 0)
(09:00:00, 188.1)
(09:00:30, 205)

what the integration gets to be provided is in fact:
(00:00:00, 0)
(09:00:00, 188.1)
(09:00:30, 205)

And so the first data entered at 9AM will be 188.1W9h = 1.692kWh
instead of 188.1W
30s = 188.1W*30/3600h = 0.0015675kWh

The sensors must be updated even if the value isn't changing as it otherwise can't be used with the HA integration and provide an accurate result.

Unremovable Duplicated Output Entities

Hello, thanks for this integration, it makes getting the live values into Home Assistant a lot easier.

We have an issue with the 'outputs' coming through, the integration seems to create multiple entities for each output and it seems they never go away and can't be deleted even when the integration is removed.

DuplicateSample

image

Can someone please look into why this would be happening ?

Need graphic/logo for IoTaWatt

When submitting the IoTaWatt sensor integration to the official Home Assistant repo, we will need to have graphics/logos from IoTaWatt.

IoTaWatt's website is mainly text with mostly photos of the device and components. I've tried to reach out to overeasy on the IoTaWatt forum but haven't had any luck.

These are the only graphics/logos I could find, these might work just have to look at the size requirement and ratio when submitting them to Home Assistant

image

Screen Shot 2021-08-04 at 10 34 05 AM

iotawatt.py", line 81, in _createSensors AttributeError: 'NoneType' object has no attribute 'text'

Logger: custom_components.iotawatt
Source: custom_components/iotawatt/init.py:106
Integration: iotawatt
First occurred: August 2, 2021, 10:48:17 PM (2400 occurrences)
Last logged: 6:52:41 PM
Unexpected error fetching IoTaWatt 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 "/config/custom_components/iotawatt/__init__.py", line 106, in _async_update_data
    await self.api.update()
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 67, in update
    await self._createSensors()
  File "/usr/local/lib/python3.9/site-packages/iotawattpy/iotawatt.py", line 81, in _createSensors
    results = response.text
AttributeError: 'NoneType' object has no attribute 'text'

Energy sensors created from an IotaWatt output can yield an incorrect result

The integration queries the energy value (in Wh) for all sensors using GET request like so:

http://IP_ADDRESS/query?select=[time.iso,Phase1.wh,Phase2.wh,Phase3.wh,Tesla1.wh,Tesla2.wh,Tesla3.wh,Pool.wh,Solar1.wh,Solar2.wh,AC1.wh,AC2.wh,AC3.wh,HotWater.wh,AC.wh,Export.wh,Import.wh,Main.wh,Tesla.wh,Total.wh,Total_Phase1.wh,Total_Phase2.wh,Total_Phase3.wh,Total_Solar.wh]&begin=y&end=s&group=all

This will ask the iotawatt for the energy used by such output since the beginning of the current year.

The following thread explains on why it will not return the expected result under some circumstances:
https://community.iotawatt.com/t/wrong-values-returned-by-rest-api-explained/3239/14
and:
https://community.iotawatt.com/t/solar-import-export/3175

To get around this, with the inclusion of the fix for #15 and the integration Riemann sum integration, we can calculate the energy used for a given sensor.
This however is a rather non-user friendly way of going at it.

What would be nice would be for this iotawatt integration to perform such operation, generate the energy sensor and whenever a power value is read, to update the energy sensor.

Using a configuration, we could define something like:

iotawatt:
  energy_sensors:
    source: Export
    name: energy_output
    unit_prefix: k
    round: 3

similar to https://www.home-assistant.io/integrations/integration/

An issue here is that if you have multiple iotawatt devices, you can only define it for one. But that's another issue.

The sensors created that way should be directly usable by the Home Assistant energy tool.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.