The configuration is wrong, just read how template sensor sould look like:
sensor:
- platform: template
sensors:
solar_angle:
friendly_name: "Sun angle"
unit_of_measurement: "degrees"
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
sunrise:
value_template: "{{ state_attr('sun.sun', 'next_rising') }}"
So after
sensor:
- platform: template
sensors:
you are adding all template sensor like in example.
As I said I’m using new format for template sensor and in configuration.yaml I added
template: !include template.yaml
to have all this sensors in separate file and in template.yaml I have:
sensor:
- name: "String 1 napięcie"
unique_id: pv_01_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_01_voltage') | float(0) }}"
- name: "String 2 napięcie"
unique_id: pv_02_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_02_voltage') | float(0) }}"
- name: "String 1 natężenie"
unique_id: pv_01_current
unit_of_measurement: 'A'
icon: mdi:current-dc
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_01_current') | float(0) }}"
- name: "String 2 natężenie"
unique_id: pv_02_current
unit_of_measurement: 'A'
icon: mdi:current-dc
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'pv_string_02_current') | float(0) }}"
- name: "Faza 1 V (f)"
unique_id: phase_a_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: >
{% if state_attr('sensor.sun2000_8ktl_m0', 'phase_A_voltage') | float(0) > 180 and state_attr('sensor.sun2000_8ktl_m0', 'phase_A_voltage')|float(0) < 264 %}
{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_A_voltage') }}
{% else %}
{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_A_voltage') }}
{% endif %}
- name: "Faza 2 V (f)"
unique_id: phase_b_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: >
{% if state_attr('sensor.sun2000_8ktl_m0', 'phase_B_voltage') | float(0) > 180 and state_attr('sensor.sun2000_8ktl_m0', 'phase_B_voltage')|float(0) < 264 %}
{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_B_voltage') }}
{% else %}
{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_B_voltage') }}
{% endif %}
- name: "Faza 3 V (f)"
unique_id: phase_c_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: >
{% if state_attr('sensor.sun2000_8ktl_m0', 'phase_C_voltage') | float(0) > 180 and state_attr('sensor.sun2000_8ktl_m0', 'phase_C_voltage')|float(0) < 264 %}
{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_C_voltage') }}
{% else %}
{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_C_voltage') }}
{% endif %}
- name: "Faza 1 V (m)"
unique_id: m_grid_a_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_A_voltage') | float(0) }}"
- name: "Faza 2 V (m)"
unique_id: m_grid_b_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_B_voltage') | float(0) }}"
- name: "Faza 3 V (m)"
unique_id: m_grid_c_voltage
unit_of_measurement: 'V'
icon: mdi:flash-alert-outline
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_C_voltage') | float(0) }}"
- name: "Faza 1 A (f)"
unique_id: phase_a_current
unit_of_measurement: 'A'
icon: mdi:current-ac
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_A_current') | float(0) }}"
- name: "Faza 2 A (f)"
unique_id: phase_b_current
unit_of_measurement: 'A'
icon: mdi:current-ac
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_B_current') | float(0) }}"
- name: "Faza 3 A (f)"
unique_id: phase_c_current
unit_of_measurement: 'A'
icon: mdi:current-ac
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'phase_C_current') | float(0) }}"
- name: "Produkcja DC"
unique_id: pv_input_power
unit_of_measurement: 'W'
icon: mdi:solar-power
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'input_power') | float(0) }}"
- name: "Zużycie prądu"
unique_id: power_meter_active_power
unit_of_measurement: 'W'
icon: mdi:transmission-tower
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'power_meter_active_power') | float(0) }}"
- name: "Zużycie A"
unique_id: active_grid_a_power
unit_of_measurement: 'W'
icon: mdi:transmission-tower
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'active_grid_A_power') | float(0) }}"
- name: "Zużycie B"
unique_id: active_grid_b_power
unit_of_measurement: 'W'
icon: mdi:transmission-tower
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'active_grid_B_power') | float(0) }}"
- name: "Zużycie C"
unique_id: active_grid_c_power
unit_of_measurement: 'W'
icon: mdi:transmission-tower
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'active_grid_C_power') | float(0) }}"
- name: "Prąd oddany do sieci"
unique_id: m_grid_exporterd_energy
unit_of_measurement: 'kWh'
icon: mdi:transmission-tower
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_exported_energy') | float(0) }}"
device_class: energy
state_class: total_increasing
- name: "Prąd pobrany z sieci"
unique_id: m_grid_accumulated_energy
unit_of_measurement: 'kWh'
icon: mdi:transmission-tower
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'grid_accumulated_energy') | float(0) }}"
device_class: energy
state_class: total_increasing
- name: "Temperatura falownika"
unique_id: pv_temperatura
unit_of_measurement: '°C'
state: "{{ state_attr('sensor.sun2000_8ktl_m0', 'internal_temperature') | float(0) }}"
- name: "Efetywność Falownika"
unique_id: pv_efficiency
unit_of_measurement: '%'
state: >
{% if state_attr('sensor.sun2000_8ktl_m0', 'efficiency') | float(0) < 100 %}
{{ state_attr('sensor.sun2000_8ktl_m0', 'efficiency') }}
{% else %}
0
{% endif %}
- name: "Zużycie prądu dom"
unique_id: energy_used
unit_of_measurement: 'kWh'
state: >
{% if states('sensor.total_yield') | float(0) > 0 and state_attr('sensor.sun2000_8ktl_m0','grid_exported_energy') | float(0) > 0 and state_attr('sensor.sun2000_8ktl_m0','grid_accumulated_energy') | float(0) > 0 %}
{{ '%0.2f' | format(states('sensor.total_yield') | float(0) -
state_attr('sensor.sun2000_8ktl_m0','grid_exported_energy') | float(0) +
state_attr('sensor.sun2000_8ktl_m0','grid_accumulated_energy') | float(0)) }}
{% endif %}
device_class: energy
state_class: total_increasing
I checked and sensors are visible in HA energy tab. In new format there are no friendly name option, so I had to change entity names in HA from GUI to have the same entity names as before.