Skip to content

Commit

Permalink
Add power derating entities
Browse files Browse the repository at this point in the history
Fixes #683
  • Loading branch information
wlcrs committed Apr 16, 2024
1 parent c3dc92c commit 472a578
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 4 deletions.
6 changes: 3 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
"documentation": "https://github.com/wlcrs/huawei_solar/wiki",
"issue_tracker": "https://github.com/wlcrs/huawei_solar/issues",
"requirements": [
"huawei-solar==2.3.0b6"
"huawei-solar==2.3.0b7"
],
"codeowners": [
"@wlcrs"
],
"iot_class": "local_polling",
"version": "1.4.0a2",
"version": "1.4.0a3",
"loggers": [
"huawei_solar",
"pymodbus"
]
}
}
32 changes: 31 additions & 1 deletion number.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ def context(self):
return {"register_names": registers}


INVERTER_NUMBER_DESCRIPTIONS: tuple[HuaweiSolarNumberEntityDescription, ...] = (
HuaweiSolarNumberEntityDescription(
key=rn.ACTIVE_POWER_PERCENTAGE_DERATING,
native_max_value=100,
native_step=0.1,
native_min_value=0,
icon="mdi:transmission-tower-off",
native_unit_of_measurement=PERCENTAGE,
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
),
HuaweiSolarNumberEntityDescription(
key=rn.ACTIVE_POWER_FIXED_VALUE_DERATING,
static_maximum_key=rn.P_MAX,
native_step=1,
native_min_value=0,
icon="mdi:transmission-tower-off",
native_unit_of_measurement=UnitOfPower.WATT,
entity_category=EntityCategory.CONFIG,
),
)

ENERGY_STORAGE_NUMBER_DESCRIPTIONS: tuple[HuaweiSolarNumberEntityDescription, ...] = (
HuaweiSolarNumberEntityDescription(
key=rn.STORAGE_MAXIMUM_CHARGING_POWER,
Expand Down Expand Up @@ -157,7 +179,15 @@ async def async_setup_entry(
if not ucs.configuration_update_coordinator:
continue

slave_entities: list[HuaweiSolarNumberEntity] = []
slave_entities: list[HuaweiSolarNumberEntity] = [
await HuaweiSolarNumberEntity.create(
ucs.configuration_update_coordinator,
ucs.bridge,
entity_description,
ucs.device_infos["inverter"],
)
for entity_description in INVERTER_NUMBER_DESCRIPTIONS
]

if ucs.bridge.battery_type != rv.StorageProductModel.NONE:
assert ucs.device_infos["connected_energy_storage"]
Expand Down
6 changes: 6 additions & 0 deletions strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
},
"entity": {
"number": {
"active_power_percentage_derating": {
"name": "Power derating (by percentage)"
},
"active_power_fixed_value_derating": {
"name": "Power derating"
},
"storage_maximum_charging_power": {
"name": "Maximum charging power"
},
Expand Down
1 change: 1 addition & 0 deletions switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def __init__(
key=rn.STARTUP,
icon="mdi:power-standby",
entity_category=EntityCategory.CONFIG,
translation_key=rn.STARTUP,
)

self._attr_device_info = device_info
Expand Down
6 changes: 6 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
},
"entity": {
"number": {
"active_power_percentage_derating": {
"name": "Power derating (by percentage)"
},
"active_power_fixed_value_derating": {
"name": "Power derating"
},
"storage_backup_power_state_of_charge": {
"name": "Backup power SOC"
},
Expand Down
6 changes: 6 additions & 0 deletions translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
},
"entity": {
"number": {
"active_power_percentage_derating": {
"name": "Vermogensbeperking (percentage)"
},
"active_power_fixed_value_derating": {
"name": "Vermogensbeperking"
},
"storage_backup_power_state_of_charge": {
"name": "Noodvermogen batterijpercentage"
},
Expand Down

0 comments on commit 472a578

Please sign in to comment.