Code Monkey home page Code Monkey logo

Comments (4)

gtdiehl avatar gtdiehl commented on September 3, 2024

In the post that is linked it mentions this query does not work
http://iotawatt/query?select=[net.wh,grid_consumption.wh,grid_return.wh]&begin=d&end=s&group=all

Unfortunately changing the parameter of group to auto or some other value the IoTaWatt backend returns an array with multiple elements. Each element for the time period of the grouping from the beginning of the year. Currently, the API is written to expect an array with a single element.

This can not be resolved without a large code change. Would take some time to resolve this one.

from iotawatt_ha.

jyavenard avatar jyavenard commented on September 3, 2024

Querying a Wh Iotawatt output will not work for HA and the energy component.
I posted a way to work around that here:
https://community.home-assistant.io/t/custom-component-iotawatt-energy-monitor-integration/254110/91?u=jyavenard

The explanation on why you can't query Wh that needs to be calculated by summing the calculations is in the thread above.

from iotawatt_ha.

gtdiehl avatar gtdiehl commented on September 3, 2024

@jyavenard Would the only code change (probably on the IoTawatt Home Assistant integration code side) that would need to be made is to change the negative values to positive and use the Riemann sum?

from iotawatt_ha.

jyavenard avatar jyavenard commented on September 3, 2024

@jyavenard Would the only code change (probably on the IoTawatt Home Assistant integration code side) that would need to be made is to change the negative values to positive and use the Riemann sum?

Everything else can be done in HA yes.

So if you simply want to integrate the result you would add the following integration sensor:

- platform: integration
  source: sensor.iotawatt_output_export
  name: energy_grid_export_wh
  method: right

It is better to calculate the absolute value after the integration, but care should be taken to include the attributes required by the energy screen.

If you want to calculate the absolute value before the integration you need something like:

- platform: template
  sensors:
    power_grid_export:
      friendly_name: "Grid Power Export"
      unit_of_measurement: W
      device_class: power
      value_template: "{{ states('sensor.iotawatt_output_export')|float|abs }}"
      attribute_templates:
        last_updated: "{{ now() }}"

You then use the sensor.power_grid_export with the integration.

The attribute_templates is important, because HA by default doesn't call the entity's watchers if the value hasn't changed, and the integration needs to know of all values, not just when it changes.
Adding a last_updated attribute gets around the problem.

I automated the process above and automatically create the integration sensor with this commit:
jyavenard@fca1f93

I believe it makes for more user friendly approach.

What I don't like with the pure integration approach is that if you lose connectivity with the iotawatt (which somehow happens rather regularly at my place), then no energy is recorded during that time.

from iotawatt_ha.

Related Issues (20)

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.