I installed InfluxDB (not the 2.x) and Grafana. From the Huawei Solar Modbus Integration i have 2 entities (updated every 30 seconds): sensor.inverter_pv_1_current sensor.inverter_pv_1_voltage
which provides me the instantaneous value. this i can also read in InfluxDB as well as Grafana.
I would like to calculated the instantenous power VxI and then calculate the Energy kWh for the day.
I thought of creating the sensors in the influxDB and then use it in the Grafana. But I have no clue where to start. All i read in the internet is about the 2.x version which is not available in my basic version.
If someone has already the knows it, could you please share a quick snippet and guide me how can i accomplish it please ?
If you do this in home assistant it will be easier and you will be able to use the power and energy values for automations if needed, you can of course send these new sensors to InfluxDB and plot them in Grafana.
#configuration.yaml
template:
- sensor:
- name: Solar Power
unique_id: solar_power_sensor
device_class: power
state_class: measurement
unit_of_measurement: W
state: "{{ states('sensor.inverter_pv_1_current')|float * states('sensor.inverter_pv_1_voltage')|float }}"
availability: "{{ has_value('sensor.inverter_pv_1_current') and has_value('sensor.inverter_pv_1_voltage') }}"
Then you can feed this power sensor to the Riemann Sum helper to accumulate energy, you can do this part from the UI if you wish (you will have to restart HA after creating the template sensor first though):
#configuration.yaml
sensor:
- platform: integration
name: Solar Energy
unique_id: solar_energy_sensor
source: sensor.solar_power
unit_prefix: k
Another restart and you should now have the following two sensors:
sensor.solar_power and sensor.solar_energy
The energy sensor will always increase. If you want a daily sensor you can feed the energy sensor to the Utility Meter helper.
thanks for the quick and simple solution , This works like a charm for me.
Thanks also for the bonus Utility_meter, this is also exactly what i’m looking for the daily consumption in HA Dashboard.