Skip to content

Commit

Permalink
Merge pull request #208 from michalbiesek/fix-missing-efs
Browse files Browse the repository at this point in the history
Add missing device type ESS
  • Loading branch information
tijsverkoyen authored Nov 24, 2024
2 parents e3098de + 215b317 commit 8f1454c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
6 changes: 4 additions & 2 deletions custom_components/fusion_solar/device_real_kpi_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from .const import DOMAIN
from .fusion_solar.const import ATTR_DEVICE_REAL_KPI_DEV_ID, ATTR_DEVICE_REAL_KPI_DATA_ITEM_MAP, \
PARAM_DEVICE_TYPE_ID_STRING_INVERTER, PARAM_DEVICE_TYPE_ID_EMI, PARAM_DEVICE_TYPE_ID_GRID_METER, \
PARAM_DEVICE_TYPE_ID_RESIDENTIAL_INVERTER, PARAM_DEVICE_TYPE_ID_BATTERY, PARAM_DEVICE_TYPE_ID_POWER_SENSOR
PARAM_DEVICE_TYPE_ID_RESIDENTIAL_INVERTER, PARAM_DEVICE_TYPE_ID_BATTERY, PARAM_DEVICE_TYPE_ID_POWER_SENSOR, \
PARAM_DEVICE_TYPE_ID_C_I_UTILITY_ESS
from .fusion_solar.openapi.openapi_api import FusionSolarOpenApiError, FusionSolarOpenApiAccessFrequencyTooHighError

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -85,7 +86,8 @@ def device_ids_grouped_per_type_id(self):
# skip devices wherefore no real kpi data is available
if device.type_id not in [PARAM_DEVICE_TYPE_ID_STRING_INVERTER, PARAM_DEVICE_TYPE_ID_EMI,
PARAM_DEVICE_TYPE_ID_GRID_METER, PARAM_DEVICE_TYPE_ID_RESIDENTIAL_INVERTER,
PARAM_DEVICE_TYPE_ID_BATTERY, PARAM_DEVICE_TYPE_ID_POWER_SENSOR]:
PARAM_DEVICE_TYPE_ID_BATTERY, PARAM_DEVICE_TYPE_ID_POWER_SENSOR,
PARAM_DEVICE_TYPE_ID_C_I_UTILITY_ESS]:
continue

device_from_registry = device_registry.async_get_device(identifiers={(DOMAIN, device.device_id)})
Expand Down
1 change: 1 addition & 0 deletions custom_components/fusion_solar/fusion_solar/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@
PARAM_DEVICE_TYPE_ID_GRID_METER = 17
PARAM_DEVICE_TYPE_ID_POWER_SENSOR = 47
PARAM_DEVICE_TYPE_ID_RESIDENTIAL_INVERTER = 38
PARAM_DEVICE_TYPE_ID_C_I_UTILITY_ESS = 41
PARAM_DEVICE_TYPE_ID_STRING_INVERTER = 1
2 changes: 2 additions & 0 deletions custom_components/fusion_solar/fusion_solar/openapi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def device_type(self) -> str:
return 'Battery'
if self.type_id == 40:
return 'Backup box'
if self.type_id == 41:
return 'ESS'
if self.type_id == 45:
return 'PLC'
if self.type_id == 46:
Expand Down
17 changes: 16 additions & 1 deletion custom_components/fusion_solar/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ATTR_STATION_REAL_KPI_TOTAL_CURRENT_MONTH_ENERGY, ATTR_STATION_REAL_KPI_TOTAL_LIFETIME_ENERGY, \
ATTR_DATA_COLLECT_TIME, ATTR_KPI_YEAR_INVERTER_POWER, ATTR_DEVICE_REAL_KPI_ACTIVE_POWER, \
PARAM_DEVICE_TYPE_ID_STRING_INVERTER, PARAM_DEVICE_TYPE_ID_GRID_METER, PARAM_DEVICE_TYPE_ID_RESIDENTIAL_INVERTER, \
PARAM_DEVICE_TYPE_ID_POWER_SENSOR, PARAM_DEVICE_TYPE_ID_EMI, PARAM_DEVICE_TYPE_ID_BATTERY
PARAM_DEVICE_TYPE_ID_POWER_SENSOR, PARAM_DEVICE_TYPE_ID_EMI, PARAM_DEVICE_TYPE_ID_BATTERY, PARAM_DEVICE_TYPE_ID_C_I_UTILITY_ESS
from .fusion_solar.kiosk.kiosk import FusionSolarKiosk
from .fusion_solar.kiosk.kiosk_api import FusionSolarKioskApi, FusionSolarKioskApiError
from .fusion_solar.openapi.openapi_api import FusionSolarOpenApi, FusionSolarOpenApiError
Expand Down Expand Up @@ -556,6 +556,21 @@ async def add_entities_for_stations(hass, async_add_entities, stations, api: Fus
{'class': 'FusionSolarRealtimeDeviceDataStateBinarySensor', 'attribute': 'run_state', 'name': 'Status'},
]

if device.type_id == PARAM_DEVICE_TYPE_ID_C_I_UTILITY_ESS:
entities_to_create = [
{'class': 'FusionSolarRealtimeDeviceDataPowerInWattSensor', 'attribute': 'ch_discharge_power',
'name': 'Charge/Discharge power'},
{'class': 'FusionSolarRealtimeDeviceDataBatterySensor', 'attribute': 'battery_soc',
'name': 'Battery state of charge (SOC)'},
{'class': 'FusionSolarRealtimeDeviceDataSensor', 'attribute': 'battery_soh',
'name': 'Battery state of health (SOH)'},
{'class': 'FusionSolarRealtimeDeviceDataEnergyTotalIncreasingSensor', 'attribute': 'charge_cap',
'name': 'Charging capacity'},
{'class': 'FusionSolarRealtimeDeviceDataEnergyTotalIncreasingSensor', 'attribute': 'discharge_cap',
'name': 'Discharging capacity'},
{'class': 'FusionSolarRealtimeDeviceDataStateBinarySensor', 'attribute': 'run_state', 'name': 'Status'},
]

if device.type_id == PARAM_DEVICE_TYPE_ID_POWER_SENSOR:
entities_to_create = [
{'class': 'FusionSolarRealtimeDeviceDataTranslatedSensor', 'attribute': 'meter_status',
Expand Down

0 comments on commit 8f1454c

Please sign in to comment.