[SOLVED] WIBEEE HACs integration custom sensors at energy panel not working

Hi! First time searching help.

I’m trying to get working my energy panel but i’m stuck at return as my dashboard tells me i’m full solar powered even during night time…

My solar company installed two Wibeee 3 phase meters, one attached to the inbound grid cables and one attached to the solar panels. I get 4 devices and 44 entities from each.

So by what i undesrtand i’m getting separated every phase (3 of them each) and a “general” sensor for each device.

What i’m not getting is HA to calculate as my wibeee webapp does. Wibeee app show the return as negative value, while on the HA i just get wrong information.

For “Grid consumption” i’ve selected GENERAL device, energy sensor ,from Wibeee attached to inbound cables.
For “Solar production” i’ve selected GENERAL device, energy sensor, from Wibeee attached to Solar cables
And last, for “Return to grid” i’ve selected again the GENERAL device, energy sensor, for the Wibeee attached to inbound grid cables…

So, why is my homeassistant counting everything as solar production and not interpreting like…

Example:
for consumtion +2kWh, consumption = 2kWh
for solar +5,5kWh, consumption = -3,5kWh
for return to grid = +3,5kWh

Hope i’ll explain my self… otherwise i’ll try to upload screenshots or something that helps to get the point. Thanks for any help!

So after some work around and having figured it out that i started a discussion without even configured everything from the begging… i’m stuck at this state with “integration” (riemann sum…) :
image

And both sensors showing:


However, template sensors working:
image

Seeing lots of topics and discussion, but there are like “new” and “old” ways to write and i’m getting quite lost at this point.

I think you need to use “unit_of_measurement: kWh”, not kW

Maybe you have to add “unit_time: h” if the unit_… is still kW.

sensor:
  - platform: integration
    source: sensor.current_power
    name: energy_spent
    unit_prefix: k
    unit_time: h
    round: 2

Thanks mate, and Sorry, i was doing so much trial and error that i uploaded a wrong picture… they are now, and were when the problem started, at “kWh”.

By the way, code used:

Template:

- sensor:
    - unique_id: grid_import_export_power
      device_class: power
      unit_of_measurement: "W"
      state_class: measurement
      state: >-
        {% if states('sensor.wibeee_power_factor_l4') | float < 0 %}
          {{ states('sensor.wibeee_active_power_l4') | float * -1 | round(0) }}
        {% else %}
          {{ states('sensor.wibeee_active_power_l4') | float | round(0) }}
        {% endif %}
      availability: "{{ not states('sensor.wibeee_active_power_l4') in ('unavailable', 'unknown') and not states('sensor.wibeee_power_factor_l4') in ('unavailable', 'unknown') }}"
      attributes:
        friendly_name: "Grid import(+) or export(-) power"
    - unique_id: grid_import_power
      device_class: power
      unit_of_measurement: "W"
      state_class: measurement
      state: "{{ [states('sensor.template_grid_import_export_power') | float, 0] | max | round(0) }}"
      availability: "{{ not states('sensor.template_grid_import_export_power') in ('unavailable', 'unknown') }}"
      attributes:
        friendly_name: "Grid import power"
    - unique_id: grid_export_power
      device_class: power
      unit_of_measurement: "W"
      state_class: measurement
      state: "{{ [states('sensor.template_grid_import_export_power') | float, 0] | min | abs | round(0) }}"
      availability: "{{ not states('sensor.template_grid_import_export_power') in ('unavailable', 'unknown') }}"
      attributes:
        friendly_name: "Grid export power"

Sensors:

- platform: integration
  source: sensor.grid_import_power
  name: consumo_energy
  unit_prefix: k
  round: 2
- platform: integration
  source: sensor.grid_export_power
  name: volcado_energy
  unit_prefix: k
  round: 2

Customize:

sensor.consumo_energy:
  state_class: total_increasing
  unit_of_measurement: "kWh"
  device_class: energy
sensor.volcado_energy:
  state_class: total_increasing
  unit_of_measurement: "kWh"
  device_class: energy

Solution found.

If creating TEMPLATE sensor without “name” field, the sensor will be generated as “sensor.template…”.

So i was calling wrong sensor as i was expecting “sensor.grid…” and i was creating “sensor.template_grid…”

So, just added “name” field to each sensor:

Code (remember to match your sensor names*):

- sensor:
    - name: grid_import_export_power
      unique_id: grid_import_export_power
      device_class: power
      unit_of_measurement: "W"
      state_class: measurement
      state: >-
        {% if states('sensor.wibeee_power_factor_l4') | float < 0 %}
          {{ states('sensor.wibeee_active_power_l4') | float * -1 | round(0) }}
        {% else %}
          {{ states('sensor.wibeee_active_power_l4') | float | round(0) }}
        {% endif %}
      availability: "{{ not states('sensor.wibeee_active_power_l4') in ('unavailable', 'unknown') and not states('sensor.wibeee_power_factor_l4') in ('unavailable', 'unknown') }}"
      attributes:
        friendly_name: "Grid import(+) or export(-) power"
    - name: grid_import_power
      unique_id: grid_import_power
      device_class: power
      unit_of_measurement: "W"
      state_class: measurement
      state: "{{ [states('sensor.template_grid_import_export_power') | float, 0] | max | round(0) }}"
      availability: "{{ not states('sensor.template_grid_import_export_power') in ('unavailable', 'unknown') }}"
      attributes:
        friendly_name: "Grid import power"
    - name: grid_export_power
      unique_id: grid_export_power
      device_class: power
      unit_of_measurement: "W"
      state_class: measurement
      state: "{{ [states('sensor.template_grid_import_export_power') | float, 0] | min | abs | round(0) }}"
      availability: "{{ not states('sensor.template_grid_import_export_power') in ('unavailable', 'unknown') }}"
      attributes:
        friendly_name: "Grid export power"

Thanks!