Hello Home Assistant Community,
I use Home Assistant since a few year, but only recently started to extend the functionality.
With the Energy management feature released, I was triggered to get my solar inverter integrated with Home Assistant.
As there is no official integration for Kostal Piko inverters yet, I started to gather the information and setup an integration based on the Restful / template sensors.
Currently I am getting deeper into the setup of custom components, though I would still need some time to get this running. Until then I would share my configuration.yaml and groups.yaml so that anyone with a similar setup can try it out and give me suggestion on what to optimize
Basic setup:
- Kostal Piko inverters share there information locally through an undocumented Rest API
- The API URL: http://<inverter-ip/api/dxs.json?dxsEntries=&dxsEntries=…
- Overview about the dxsIds I sniffed from the local website
#Kostal Piko Inverter Rest sensor
#dxsIds Overview:
# General:
# 16780544 - Inverter type
# 16777984 - Inverter name
# 33556736 - DC Input - Total (W)
# 67109120 - Output power (W)
# 83888128 - Self-consumption (W)
# 16780032 - Operation Status 0- , 1- , 2- , 3-Feed in (MPP)
# PV-Generator:
# 33555202 - DC Input 1 - Voltage (V)
# 33555201 - DC Input 1 - Current (A)
# 33555203 - DC Input 1 - Power (W)
# 33555458 - DC Input 2 - Voltage (V)
# 33555457 - DC Input 2 - Current (A)
# 33555459 - DC Input 2 - Power (W)
# Battery:
# 33556226 - Battery voltage (V)
# 33556229 - Battery charging level (%)
# 33556238 - Battery current (A)
# 33556230 - Battery Status 0-Charging 1-Discharging
# 33556228 - Battery loading cycles
# 33556227 - Battery temperature (°C)
# Home:
# 83886336 - Current home consumption solar (W)
# 83886592 - Current home consumption battery (W)
# 83886848 - Current home consumption external (W)
# 83887106 - Home consumption phase 1 (W)
# 83887362 - Home consumption phase 2 (W)
# 83887618 - Home consumption phase 3 (W)
# Grid:
# 67109120 - Grid Output power (W)
# 67110400 - Grid frequency (%)
# 67110656 - Grid Cos phi
# 67110144 - Grid Limitation on (%)
# 67109378 - Grid Voltage phase 1 (V)
# 67109377 - Grid Current phase 1 (A)
# 67109379 - Grid Power phase 1 (W)
# 67109634 - Grid Voltage phase 2 (V)
# 67109633 - Grid Current phase 2 (A)
# 67109635 - Grid Power phase 2 (W)
# 67109890 - Grid Voltage phase 3 (V)
# 67109889 - Grid Current phase 3 (A)
# 67109891 - Grid Power phase 3 (W)
# Statistics Day:
# 251658754 - Yield (kWh)
# 251659010 - Home-consumption (kWh)
# 251659266 - Self-consumption (kWh)
# 251659278 - Self-consumption rate (%)
# 251659279 - Degree of self-sifficiency (%)
# Statistics Total:
# 251658753 - Yield (kWh)
# 251659009 - Home-consumption (kWh)
# 251659265 - Self-consumption (kWh)
# 251659280 - Self-consumption rate (%)
# 251659281 - Degree of self-sufficiency (%)
# 251658496 - Operation time (h)
- the maximum number of dxsIds per Rest sensor is 25 → Therefore I separated them into 3 rest sensor
Afterwards the JSON response is parsed into seperate template entities and group together into 3 groups.
The energy values are gather for daily and total from the inverter statistics directly. Additionally the Power values for output power, solar, battery and external consumption are summed up by the integration platforms.
Be careful, the calculations for the energy board are not perfect right now and needs to be verified against the kostal web portal and the calculation logic of the Home Assistant Energy Dashboard.
Configuration YAML:
Rest & Template sensors:
#Kostal Piko Inverter Rest sensor
#dxsIds Overview:
# General:
# 16780544 - Inverter type
# 16777984 - Inverter name
# 33556736 - DC Input - Total (W)
# 67109120 - Output power (W)
# 83888128 - Self-consumption (W)
# 16780032 - Operation Status 0- , 1- , 2- , 3-Feed in (MPP)
# PV-Generator:
# 33555202 - DC Input 1 - Voltage (V)
# 33555201 - DC Input 1 - Current (A)
# 33555203 - DC Input 1 - Power (W)
# 33555458 - DC Input 2 - Voltage (V)
# 33555457 - DC Input 2 - Current (A)
# 33555459 - DC Input 2 - Power (W)
# Battery:
# 33556226 - Battery voltage (V)
# 33556229 - Battery charging level (%)
# 33556238 - Battery current (A)
# 33556230 - Battery Status 0-Charging 1-Discharging
# 33556228 - Battery loading cycles
# 33556227 - Battery temperature (°C)
# Home:
# 83886336 - Current home consumption solar (W)
# 83886592 - Current home consumption battery (W)
# 83886848 - Current home consumption external (W)
# 83887106 - Home consumption phase 1 (W)
# 83887362 - Home consumption phase 2 (W)
# 83887618 - Home consumption phase 3 (W)
# Grid:
# 67109120 - Grid Output power (W)
# 67110400 - Grid frequency (%)
# 67110656 - Grid Cos phi
# 67110144 - Grid Limitation on (%)
# 67109378 - Grid Voltage phase 1 (V)
# 67109377 - Grid Current phase 1 (A)
# 67109379 - Grid Power phase 1 (W)
# 67109634 - Grid Voltage phase 2 (V)
# 67109633 - Grid Current phase 2 (A)
# 67109635 - Grid Power phase 2 (W)
# 67109890 - Grid Voltage phase 3 (V)
# 67109889 - Grid Current phase 3 (A)
# 67109891 - Grid Power phase 3 (W)
# Statistics Day:
# 251658754 - Yield (kWh)
# 251659010 - Home-consumption (kWh)
# 251659266 - Self-consumption (kWh)
# 251659278 - Self-consumption rate (%)
# 251659279 - Degree of self-sifficiency (%)
# Statistics Total:
# 251658753 - Yield (kWh)
# 251659009 - Home-consumption (kWh)
# 251659265 - Self-consumption (kWh)
# 251659280 - Self-consumption rate (%)
# 251659281 - Degree of self-sufficiency (%)
# 251658496 - Operation time (h)
rest:
- scan_interval: 10
resource: "http://192.168.178.86/api/dxs.json?\
dxsEntries=16780544\
&dxsEntries=16777984\
&dxsEntries=33556736\
&dxsEntries=67109120\
&dxsEntries=83888128\
&dxsEntries=16780032\
&dxsEntries=33555202\
&dxsEntries=33555201\
&dxsEntries=33555203\
&dxsEntries=33555458\
&dxsEntries=33555457\
&dxsEntries=33555459\
&dxsEntries=33556226\
&dxsEntries=33556229\
&dxsEntries=33556238\
&dxsEntries=33556230\
&dxsEntries=33556228\
&dxsEntries=33556227\
&dxsEntries=83886336\
&dxsEntries=83886592\
&dxsEntries=83886848\
&dxsEntries=83887106\
&dxsEntries=83887362\
&dxsEntries=83887618"
sensor:
- name: "kostal_piko"
value_template: "{{ value_json.dxsEntries[0]['value'] }}"
json_attributes:
- dxsEntries
- scan_interval: 60
resource: "http://192.168.178.86/api/dxs.json?\
dxsEntries=67109120\
&dxsEntries=67110400\
&dxsEntries=67110656\
&dxsEntries=67110144\
&dxsEntries=67109378\
&dxsEntries=67109377\
&dxsEntries=67109379\
&dxsEntries=67109634\
&dxsEntries=67109633\
&dxsEntries=67109635\
&dxsEntries=67109890\
&dxsEntries=67109889\
&dxsEntries=67109891"
sensor:
- name: "kostal_piko_grid"
value_template: "{{ value_json.dxsEntries[0]['value'] }}"
json_attributes:
- dxsEntries
- scan_interval: 60
resource: "http://192.168.178.86/api/dxs.json?\
dxsEntries=251658754\
&dxsEntries=251659010\
&dxsEntries=251659266\
&dxsEntries=251659278\
&dxsEntries=251659279\
&dxsEntries=251658753\
&dxsEntries=251659009\
&dxsEntries=251659265\
&dxsEntries=251659280\
&dxsEntries=251659281\
&dxsEntries=251658496"
sensor:
- name: "kostal_piko_statistic"
value_template: "{{ value_json.dxsEntries[0]['value'] }}"
json_attributes:
- dxsEntries
template:
unique_id: "kostal_"
sensor:
# General:
- name: "Kostal Inverter type"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[0]['value'] }}"
unique_id: "kostal_inverter_type"
- name: "Kostal Inverter Name"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[1]['value'] }}"
unique_id: "kostal_inverter_name"
- name: "DC-Input Total"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[2]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_dc_input_total"
- name: "Output Power"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[3]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_output_power"
- name: "Self Consumption"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[4]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_self_consumption"
- name: "Feed external"
state: "{{ (state_attr('sensor.kostal_piko', 'dxsEntries')[3]['value'] | float | round(2)) - (state_attr('sensor.kostal_piko', 'dxsEntries')[4]['value'] | float | round(2)) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_feed_external"
- name: "Operation Status"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[5]['value'] }}"
unique_id: "operation_status"
# PV-Generator:
- name: "DC Input 1 - Voltage"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[6]['value'] | float | round(2) }}"
device_class: voltage
state_class: measurement
unit_of_measurement: "V"
unique_id: "kostal_dc_input_1_voltage"
- name: "DC Input 1 - Current"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[7]['value'] | float | round(2) }}"
device_class: current
state_class: measurement
unit_of_measurement: "A"
unique_id: "kostal_dc_input_1_current"
- name: "DC Input 1 - Power"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[8]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_dc_input_1_power"
- name: "DC Input 2 - Voltage"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[9]['value'] | float | round(2) }}"
device_class: voltage
state_class: measurement
unit_of_measurement: "V"
unique_id: "kostal_dc_input_2_voltage"
- name: "DC Input 2 - Current"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[10]['value'] | float | round(2) }}"
device_class: current
state_class: measurement
unit_of_measurement: "A"
unique_id: "kostal_dc_input_2_current"
- name: "DC Input 2 - Power"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[11]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_dc_input_2_power"
# Battery:
- name: "Battery voltage"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[12]['value'] | float | round(2) }}"
device_class: voltage
state_class: measurement
unit_of_measurement: "V"
unique_id: "kostal_battery_voltage"
- name: "Battery charging level"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[13]['value'] | float | round(2) }}"
device_class: power_factor
state_class: measurement
unit_of_measurement: "%"
unique_id: "kostal_battery_charging_level"
- name: "Battery current"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[14]['value'] | float | round(2) }}"
device_class: current
state_class: measurement
unit_of_measurement: "A"
unique_id: "kostal_battery_current"
- name: "Battery status"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[15]['value'] }}"
unique_id: "kostal_battery_status"
- name: "Battery loading cycles"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[16]['value']}}"
unique_id: "kostal_battery_loading_cycles"
- name: "Battery temperature"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[17]['value'] | float | round(2) }}"
device_class: temperature
state_class: measurement
unit_of_measurement: "°C"
unique_id: "kostal_battery_temperature"
# Home:
- name: "Current home consumption solar"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[18]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_home_consumption_solar"
- name: "Current home consumption battery"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[19]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_home_consumption_battery"
- name: "Current home consumption external"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[20]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_home_consumption_external"
- name: "Home consumption phase 1"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[21]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_home_consumption_phase_1"
- name: "Home consumption phase 2"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[22]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_home_consumption_phase_2"
- name: "Home consumption phase 3"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[23]['value'] | float | round(2) }}"
device_class: power
state_class: measurement
unit_of_measurement: "W"
unique_id: "kostal_home_consumption_phase_3"
# Statistics Day:
- name: "Yield - Total per Day"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[0]['value'] | float | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
unique_id: "kostal_yield_daily"
- name: "Home consumption - Total per Day"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[1]['value'] | float | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
unique_id: "kostal_home_consumption_daily"
- name: "Self consumption - Total per Day"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[2]['value'] | float | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
unique_id: "kostal_self_consumption_daily"
- name: "Grid consumption - Total per Day"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[1]['value'] - state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[2]['value'] | float | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
unique_id: "kostal_grid_consumption_daily"
- name: "Grid feed - Total per Day"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[0]['value'] - state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[2]['value'] | float | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
unique_id: "kostal_grid_feed_daily"
- name: "Self consumption rate - per Day"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[3]['value'] | float | round(2) }}"
device_class: power_factor
state_class: measurement
unit_of_measurement: "%"
unique_id: "kostal_self_consumption_rate_daily"
- name: "Degree of self-sufficiency - per Day"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[4]['value'] | float | round(2) }}"
device_class: power_factor
state_class: measurement
unit_of_measurement: "%"
unique_id: "kostal_degree_self_sufficiency_daily"
# Statistics Total:
- name: "Yield - Total"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[3]['value'] | float / 60 | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
unique_id: "kostal_yield_total"
- name: "Home consumption - Total"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[6]['value'] | float | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
unique_id: "kostal_home_consumption_total"
- name: "Self consumption - Total"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[7]['value'] | float | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "kWh"
unique_id: "kostal_self_consumption_total"
- name: "Grid consumption - Total"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[20]['value'] | float / 60 | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
unique_id: "kostal_grid_consumption_total"
- name: "Battery consumption - Total"
state: "{{ state_attr('sensor.kostal_piko', 'dxsEntries')[19]['value'] | float / 60 | round(2) }}"
device_class: energy
state_class: total_increasing
unit_of_measurement: "Wh"
unique_id: "kostal_battery_consumption_total"
- name: "Self consumption rate - Total"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[8]['value'] | float | round(2) }}"
device_class: power_factor
state_class: measurement
unit_of_measurement: "%"
unique_id: "self_consumption_rate_total"
- name: "Degree of self-sufficiency - Total"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[9]['value'] | float | round(2) }}"
device_class: power_factor
state_class: measurement
unit_of_measurement: "%"
unique_id: "degree_self_sufficiency_total"
- name: "Operation time"
state: "{{ state_attr('sensor.kostal_piko_statistic', 'dxsEntries')[10]['value'] }}"
unit_of_measurement: "h"
unique_id: "operation_time"
Sensor Platform Integration:
- platform: integration
source: sensor.kostal_output_power
name: Output power Total
unit_prefix: k
round: 2
- platform: integration
source: sensor.kostal_home_consumption_solar
name: Consumption solar Total
unit_prefix: k
round: 2
- platform: integration
source: sensor.kostal_home_consumption_battery
name: Consumption battery Total
unit_prefix: k
round: 2
- platform: integration
source: sensor.kostal_home_consumption_external
name: Consumption external Total
unit_prefix: k
round: 2
- platform: integration
source: sensor.kostal_self_consumption
name: Self consumption Total
unit_prefix: k
round: 2
- platform: integration
source: sensor.kostal_feed_external
name: Feed external Total
unit_prefix: k
round: 2
Group YAML:
photovoltaik:
name: Photovoltaik
entities:
- sensor.kostal_inverter_type
- sensor.kostal_inverter_name
- sensor.kostal_dc_input_total
- sensor.kostal_output_power
- sensor.kostal_inverter_type
- sensor.kostal_operation_status
- sensor.kostal_dc_input_1_voltage
- sensor.kostal_dc_input_1_current
- sensor.kostal_dc_input_1_power
- sensor.kostal_dc_input_2_voltage
- sensor.kostal_dc_input_2_current
- sensor.kostal_dc_input_2_power
- sensor.kostal_operation_time
homebattery:
name: Hausbatterie
entities:
- sensor.kostal_battery_charging_level
- sensor.kostal_battery_status
- sensor.kostal_battery_voltage
- sensor.kostal_battery_current
- sensor.kostal_battery_loading_cycles
- sensor.kostal_battery_temperature
- sensor.kostal_battery_charging_daily
- sensor.kostal_battery_consumption_total
homeenergy:
name: Hausenergie
entities:
- sensor.kostal_self_consumption
- sensor.kostal_self_consumption_rate_daily
- sensor.kostal_self_consumption_rate_total
- sensor.kostal_self_consumption_daily
- sensor.kostal_self_consumption_total
- sensor.kostal_feed_external
- sensor.kostal_home_consumption_solar
- sensor.kostal_home_consumption_battery
- sensor.kostal_home_consumption_external
- sensor.kostal_home_consumption_phase_1
- sensor.kostal_home_consumption_phase_2
- sensor.kostal_home_consumption_phase_3
- sensor.kostal_home_consumption_daily
- sensor.kostal_degree_self_sufficiency_daily
- sensor.kostal_degree_self_sufficiency_total
- sensor.kostal_yield_daily
- sensor.kostal_grid_consumption_daily
- sensor.kostal_grid_consumption_total
I am open to any optimization potential and support in creating a custom component out of it.
Be aware that this was only tested with a Piko 10 BA inverter based on a newer Software version offering the Rest API. It should work on other Piko inverters with the same API available as well. But the dxsIds maybe different.
Thanks and happy trying!