I would like to submit a problem related to “dirty” values when recharging an electric car via a GALI column. This column has no native integration, but exposes API via REST.
via REST I then create a “gali_line_power” sensor which indicates the instantaneous consumption in W during recharging:
rest:
resource: http://x.y.z.k/index.json?btn=X
scan_interval: 60
sensor:
- name: "Gali line power"
value_template: "{{ value_json['pnet']}}"
device_class: power
unit_of_measurement: W
state_class: measurement
Since the column is in the BOX and the internet line sometimes goes down, I created a “gali_line_power_fixed” sensor that mitigates this problem:
- platform: template
sensors:
gali_line_power_fixed:
friendly_name: "gali line power fixed"
unit_of_measurement: 'W'
device_class: power
value_template: "{{ states('sensor.gali_line_power') | default(0) }}"
Now through the integration platform I calculate the energy absorbed during recharging [KWh] and enter it in the energy dashboard
- platform: integration
source: sensor.gali_line_power_fixed
name: Consumo Energetico Gali
unit_prefix: k
round: 2
Now the problems begin:
every time i start a new charge there comes an energy spike which is completely off the charts and you can see it in the screenshot.
In addition to the dashboard where the calculation error is very visible, I also have some sensors that add up the various home and garage lines, also calculating consumption by time slot.
All sensors related to energy consumption go up with that peak as they add up
now my question is: what could be causing this error?
how could I have a debug to rebuild the values?
The read rest value is constant and has no peaks. sometimes it goes to 0 if the internet line is not available, but it happens very rarely.
The reason I have a sensor that mitigates “unavailable” states is that I also have helpers that add up multiple powerlines and if one of them has no value it faults and doesn’t work.
I also had doubts about the format of the template which is currently being deprecated in favor of a newer one.
I noticed that the “fixed” sensor doesn’t have the state_class: measurement.
That can be fixed by using defaults if you want to add up the available sensors, or by using an availability template if you only want the total available when all sensors are present.
Show your template sensor and tell me which option you want.
Edit: oh “UI helpers”. Not a template sensor. Yeah you should replace that. What are the entiy ids you want to add up, and what option do you want (total of available sensors or total only available when all sensors are available)?
I’ll show you how to do it with a template sensor instead of the helper.
Your chart is properly correct.
The consumption is that high in reality, but it is only for a split second.
Laptop charges does it too and it is not in HA I see this it is our 30 laptop charging cabinets that blow the fuse, if all laptops are ready to be charged and the main plug is connected to the grid.
Splitting the laptops up in two halfs makes it impossible to blow the fuse, even though we try to plug the two halfs in at the same time. It really is only a split second.
A large power spike has a small area under the graph as it occupies little time and thus → small energy. This is not what is happening above. The large energy spike is the issue. Using method: left will probably go a long way to fixing this. As the errors in the Riemann Sum approximation of an integral really depends on the method chosen and shape of the power curve.