Just picked up your reply to my post. Hope you got it sorted but this is what I did. I created five integration sensors as below and then used them in the energy integration. You unfortunately have to accept that the input form your generator is “Grid” as that is not currently configurable. The energy distribution screen grab is from a not very sunny day in December!
- platform: integration
source: sensor.solar_to_batteries
name: Energy To Batteries
unit_prefix: k
unit_time: h
round: 1
- platform: integration
source: sensor.solar_from_batteries
name: Energy From Batteries
unit_prefix: k
unit_time: h
round: 1
- platform: integration
source: sensor.solar_direct_use
name: Energy Direct Use
unit_prefix: k
unit_time: h
round: 1
- platform: integration
source: sensor.solar_generator
name: Energy From Generator
unit_prefix: k
unit_time: h
round: 1
- platform: integration
source: sensor.solar_panels
name: Energy From Panels
unit_prefix: k
unit_time: h
round: 1
I’ve added a custom integration template to use one of the newly created sensors, but I can’t see this in the energy dashboard configuration (for adding solar production).
You don’t need the integration integration. According to your unit of measurements, they already have the correct units. Also, you should use the new template format instead of the legacy format. Then you won’t have to use customize.yaml. Lastly, you’re using templates that are prone to startup errors.
Keep in mind, this configuration does NOT go in the sensor section. It goes in configuration.yaml.
template:
- sensors:
- unique_id: pv_temperature
name: PV Temperature
state: "{{ state_attr('inverter_goodwe', 'tempperature') }}"
unit_of_measurement: ºC
- unique_id: pv_eday
name: PV energy day
state: "{{ state_attr('inverter_goodwe', 'eday') }}"
unit_of_measurement: kWh
device_class: energy
state_class: total_increasing
- unique_id: pv_etotal
state: "{{ state_attr('inverter_goodwe', 'etotal') }}"
name: PV energy total
unit_of_measurement: kWh
device_class: energy
- unique_id: pv_iday
name: PV income day
state: "{{ state_attr('inverter_goodwe', 'iday') }}"
unit_of_measurement: €
- unique_id: pv_itotal
name: PV income total
state: "{{ state_attr('inverter_goodwe', 'itotal') }}"
unit_of_measurement: €
- unique_id: pv_excess
name: PV spare
state: "{{ state_attr('inverter_goodwe', 'pmeter') }}"
unit_of_measurement: W
- unique_id: pv_soc
name: Battery power
state: "{{ state_attr('inverter_goodwe', 'soc') }}"
unit_of_measurement: %
As I’m not allowed to more than 1 embedded item per post, here are the entities that I can see it in the energy dashboard configuration when I try to add the entity sensor.pv_eday as solar production:
The energy produced sensors, are coming from the slimmelezer integration
Yes, see my last response. You didn’t add the necessary items. Look at my post again and ensure you include state_class and device_class for each power entitythat you want to show up in the energy panel.
2022-02-03 12:16:56 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('TypeError: 'int' object is not iterable') while processing template 'Template("{{ states.sensor.shelly_em_c45bbe77e8ff_meter_power_0.state | float(0) | min(0) | multiply(-1) }}")' for attribute '_attr_native_value' in entity 'sensor.power_export'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 407, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1814, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "<template>", line 1, in top-level template code
File "/usr/local/lib/python3.9/site-packages/jinja2/filters.py", line 525, in do_max
return _min_or_max(environment, value, max, case_sensitive, attribute)
File "/usr/local/lib/python3.9/site-packages/jinja2/filters.py", line 475, in _min_or_max
it = iter(value)
TypeError: 'int' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 523, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 409, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: 'int' object is not iterable
Yeah I can reproduce this. Something has changed with the min function and it is no longer happy that it has a list to iterate over. I am not sure that I have a solution immediately to hand. Someone who is better at templating than I might have a solution but I will keep googling for a result…