Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Virtual" sensor for PV power/energy #195

Open
ScherzerThomas opened this issue Sep 9, 2023 · 0 comments
Open

"Virtual" sensor for PV power/energy #195

ScherzerThomas opened this issue Sep 9, 2023 · 0 comments

Comments

@ScherzerThomas
Copy link

Hello,
currently, there's no simple way (without headaches) to get the plain PV power/energy values (without battery) when you have a battery installed.
This is because the modbus only reports the values of the "inverter" and "battery cable" but not the values of the "pv cable".

Following entities are currently available (and are correct):

  • ac_power
  • meterX_ac_power (Grid meter)
  • batteryX_power
  • ac_energy
  • meterX_exported/meterX_imported (Grid meter)
  • batteryX_charged/batteryX_discharged

image
image
image

For using the native energy dashboard or doing energy optimizations, the PV-energy/PV-power values (without battery included) are required.

Currently, i ended in calculating these 'virtual' values myself using a sensor template to calculate the PV-power value.

template:
  - sensor:
    - name: pv_power
      unique_id: pv_power
      unit_of_measurement: 'W'
      state: '{{([0, states("sensor.solaredge_ac_power") |float(0) + states("sensor.solaredge_battery1_power") |float(0)]|max) if (states("sun.sun") in "above_horizon") else float(0) }}'
      device_class: power

  - sensor:
    - name: export_power
      unique_id: export_power
      unit_of_measurement: 'W'
      state: '{{ [0, (states("sensor.solaredge_m1_ac_power")|float(0))]|max }}'
      device_class: power

  - sensor:
    - name: load_power
      unique_id: load_power
      unit_of_measurement: 'W'
      state: '{{ [0, states("sensor.solaredge_ac_power") |float(0) - states("sensor.solaredge_m1_ac_power") |float(0)]|max }}'
      device_class: power

The sun state in the condition (and setting pv power to 0) is used to avoid short 'spikes' at night, when you have abrupt load changes.
The same is for the load_power (which can't be negative if you have no generators installed except the pv)

The export_power/load_power are for doing energy optimizations (switch on devices if enough energy is available).

To get the pv_energy, i used a riemann integration helper and a utility meter.
image
The utility meter is necessary to syncronize/set the inital value of the pv_energy.
The pv_energy should then run more or less sync with the ac_energy value over a whole day, because the battery enables you a 'shift in time'. (assuming the soc hasn't changed and when neglecting discharging losses)

Problematic at this solution is that i currently 'lose' pv_energy when home-assistent doesn't run. For such cases, it would be necessary to 'resync' the value to the 'ac_energy' value (but this only works simple when the soc hasn't changed meanwhile).
The same problems arise for the initial value as mentioned before.

A further problem is that the pv_energy/pv_power logically have no historic values until they have been created (but the solaredge values may already exist for a longer time) - so dropping the old data is necessary.

I know - it would be better if solaredge simply would add this 2 modbus registers before doing this junk - but this will not happen soon.
Maybe they don't want because then it would be easy to integrate, but this is one of the most important values (compared to shit like 'solaredge_m1_import_varh_q2_c' - does anybody know what this is in reality?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant