fsaris / home-assistant-zonneplan-one

Unofficial Zonneplan integration for Home Assistant
https://github.com/fsaris/home-assistant-zonneplan-one
MIT License
105 stars 17 forks source link

Energy production in the Energy dashboard #8

Closed robhuls closed 3 years ago

robhuls commented 3 years ago

Since #7 the energy consumption provided by the P1 sensor can be used in the energy dashboard. However, energy production cannot be selected yet. I think we need the production equivalent of this entry in const.py:

"electricity_total_today": {
    "type": "p1_installation",
    "key": "electricity.measurement_groups.0.total",
    "label": "electricity consumption today",
    "unit": ENERGY_KILO_WATT_HOUR,
    "device_class": DEVICE_CLASS_ENERGY,
    "default_enabled": True,
    "state_class": STATE_CLASS_MEASUREMENT,
},

The instantaneous energy production is retrieved in the integration, but as far as I can see, the total production today is not yet. It is unclear for me how the mapping from the REST interface works.

fsaris commented 3 years ago

It has already the needed attributes see https://github.com/fsaris/home-assistant-zonneplan-one/blob/9d0c2045fa7a8c29aa1b684d27efdf7b426999df/custom_components/zonneplan_one/const.py#L83

You are using version 0.0.4?

For me it shows up in the energy entity selector IMG_20210808_194132

robhuls commented 3 years ago

Electricity consumption has the correct properties and is visible. However, electricity production is not visible (at least, if I understand correctly).

pim-simons commented 3 years ago

I had the same challenge and solved it by using an integration sensor:

  - platform: integration
    source: sensor.zonneplan_p1_electricity_production
    name: electricity_production
    unit: kWh
    unit_prefix: k
    round: 2

This seems to do the trick as you can then select the electricity_production sensor.

fsaris commented 3 years ago

The yield total value holds the production of your solar panels.

_p1_electricity_production is a W value and not a kWh that is why it doesn't show up in the selector.

fsaris commented 3 years ago

The energy dashboard only works with kWh values. And I don't think it's possible to calculate the W values to kWh as the first is a current value and the second a cumulative.

The P1 provides the kWh values in the official protocol but seems like Zonneplan doesn't expose these in there API response. Will reach out to them to see if they are available.

fsaris commented 3 years ago

I had the same challenge and solved it by using an integration sensor:

  - platform: integration
    source: sensor.zonneplan_p1_electricity_production
    name: electricity_production
    unit: kWh
    unit_prefix: k
    round: 2

This seems to do the trick as you can then select the electricity_production sensor.

@pim-simons This is indeed a valid work around. Didn't see at first that you used the integration component to calculate the kWh.

Tnx for this hint. Will add it to the readme so others can also use this until we got the real values from the API

robhuls commented 3 years ago

This works for me too, thanks!