Skip to content

Commit

Permalink
Merge pull request #11 from tijsverkoyen/more-data
Browse files Browse the repository at this point in the history
Add support for String inverter, EMI, Grid meter, Battery and Power Sensor
  • Loading branch information
tijsverkoyen authored Nov 15, 2022
2 parents 37a2880 + 0c0c684 commit 54f1322
Show file tree
Hide file tree
Showing 9 changed files with 1,044 additions and 140 deletions.
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ When this is done, just install the repository.

The configuration happens in the configuration flow when you add the integration.

## Configuration
### Kiosk
## Kiosk
FusionSolar has a kiosk mode. The kiosk is a dashboard that is accessible for everyone that has the url.
The integration uses a JSON REST api that is also consumed by the kiosk.

Expand All @@ -24,8 +23,25 @@ The integration updates the data every 10 minutes.

If you need more accurate information you should use the OpenAPI mode.

### OpenAPI
## OpenAPI
You will need an OpenAPI account from Huawei for this to work. [More information](https://forum.huawei.com/enterprise/en/communicate-with-fusionsolar-through-an-openapi-account/thread/591478-100027)

The integration updates the total yields (current day, current month, current year, lifetime) every 10 minutes.
The integration will expose the different devices (Residential inverter, String inverter, Battery, Dongle, ...) in
your plant/station.

### Realtime data
The devices that support realtime information (getDevRealKpi api call):
* String inverter
* EMI
* Grid meter
* Residential inverter
* Battery
* Power Sensor

The exposed entities can be different per device. These are documented in the "Interface reference" that you can
request from Huawei. But the names are pretty self explanatory.

The realtime data is updated every minute.

### Total yields
The integration updates the total yields (current day, current month, current year, lifetime) every 10 minutes.
2 changes: 2 additions & 0 deletions custom_components/fusion_solar/fusion_solar/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
ATTR_DEVICE_REAL_KPI_ACTIVE_POWER = 'active_power'

PARAM_DEVICE_TYPE_ID_STRING_INVERTER = 1
PARAM_DEVICE_TYPE_ID_EMI = 10
PARAM_DEVICE_TYPE_ID_GRID_METER = 17
PARAM_DEVICE_TYPE_ID_RESIDENTIAL_INVERTER = 38
PARAM_DEVICE_TYPE_ID_BATTERY = 39
PARAM_DEVICE_TYPE_ID_POWER_SENSOR = 47
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from homeassistant.helpers.entity import Entity, EntityCategory

from .openapi.device import FusionSolarDevice
from ..const import DOMAIN


class FusionSolarDeviceAttributeEntity(Entity):
def __init__(
self,
device: FusionSolarDevice,
name,
attribute,
value
):
"""Initialize the entity"""
self._device = device
self._name = name
self._attribute = attribute
self._device_info = device.device_info()
self._value = value

@property
def unique_id(self) -> str:
return f'{DOMAIN}-{self._device.device_id}-{self._attribute}'

@property
def name(self):
return f'{self._device.readable_name} - {self._name}'

@property
def state(self):
return self._value

@property
def device_info(self) -> dict:
return self._device_info

@property
def entity_category(self) -> str:
return EntityCategory.DIAGNOSTIC

@property
def should_poll(self) -> bool:
return False


class FusionSolarDeviceLatitudeEntity(FusionSolarDeviceAttributeEntity):
_attr_icon = 'mdi:latitude'


class FusionSolarDeviceLongitudeEntity(FusionSolarDeviceAttributeEntity):
_attr_icon = 'mdi:longitude'
14 changes: 12 additions & 2 deletions custom_components/fusion_solar/fusion_solar/openapi/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class FusionSolarDevice:
def __init__(
self,
id: str,
device_id: str,
name: str,
station_code: str,
esn_code: str,
Expand All @@ -14,7 +14,7 @@ def __init__(
longitude: float,
latitude: float
):
self.device_id = id
self.device_id = device_id
self.name = name
self.station_code = station_code
self.esn_code = esn_code
Expand Down Expand Up @@ -83,3 +83,13 @@ def device_info(self):
'sw_version': self.software_version,
'via_device': (DOMAIN, self.station_code)
}

@property
def readable_name(self):
if self.name == self.esn_code:
return self.name

if self.esn_code is not None and self.esn_code != '':
return f'{self.name} ({self.esn_code})'

return self.name
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ def device_info(self):
'manufacturer': 'Huawei FusionSolar',
'model': 'Station'
}

@property
def readable_name(self):
if self.name is not None and self.name != '':
return self.name

return self.code
Loading

0 comments on commit 54f1322

Please sign in to comment.