Skip to content

Commit 2d79145

Browse files
authored
Merge pull request #466 from hultenvp/Feed-in-Power-Limit
Feed in power limit
2 parents 36a5865 + 4c7b4a7 commit 2d79145

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

custom_components/solis/control_const.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,18 @@ class SolisButtonEntityDescription(ButtonEntityDescription):
340340
icon="mdi:dip-switch",
341341
)
342342
],
343+
"696": [
344+
SolisNumberEntityDescription(
345+
name="Feed in Power Limit",
346+
key="feed_in_power_limit",
347+
icon="mdi:transmission-tower-export",
348+
native_unit_of_measurement=UnitOfPower.WATT,
349+
device_class=NumberDeviceClass.POWER,
350+
native_min_value=0,
351+
native_max_value=24000,
352+
native_step=100,
353+
)
354+
],
343355
"5161": [
344356
SolisSelectEntityDescription(
345357
name="Inverter energy export on/off Control Switch",
@@ -1076,6 +1088,18 @@ class SolisButtonEntityDescription(ButtonEntityDescription):
10761088
icon="mdi:dip-switch",
10771089
)
10781090
],
1091+
"696": [
1092+
SolisNumberEntityDescription(
1093+
name="Feed in Power Limit",
1094+
key="feed_in_power_limit",
1095+
icon="mdi:transmission-tower-export",
1096+
native_unit_of_measurement=UnitOfPower.WATT,
1097+
device_class=NumberDeviceClass.POWER,
1098+
native_min_value=0,
1099+
native_max_value=24000,
1100+
native_step=100,
1101+
)
1102+
],
10791103
"5162": [
10801104
SolisSelectEntityDescription(
10811105
name="Inverter energy export on/off Control Switch",

custom_components/solis/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"domain": "solis",
3-
"version": "3.11.0",
3+
"version": "3.12.0",
44
"config_flow": true,
55
"name": "Solis Inverter",
66
"iot_class": "cloud_polling",

custom_components/solis/number.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import logging
3+
import re
34
from datetime import datetime
45

56
from homeassistant.components.number import NumberEntity
@@ -97,9 +98,14 @@ def do_update(self, value, last_updated):
9798
# When the data from the API changes this method will be called with value as the new value
9899
# return super().do_update(value, last_updated)
99100
_LOGGER.debug(f"Update state for {self._name}")
101+
_LOGGER.debug(f" value: {value}{self._attr_native_unit_of_measurement}")
100102

101103
value = self.split(value)
102104

105+
# Convert hectowatts to watts for Home Assistant
106+
if re.search(r"Solis Feed in Power Limit$", self._name) and value is not None:
107+
value = str(int(value) * 100)
108+
103109
if self.hass and self._attr_native_value != value:
104110
self._attr_native_value = value
105111
self._attributes[LAST_UPDATED] = last_updated
@@ -124,4 +130,8 @@ async def async_set_native_value(self, value: float) -> None:
124130
self._attributes[LAST_UPDATED] = datetime.now()
125131
self.async_write_ha_state()
126132
if not self._button:
127-
await self.write_control_data(str(value))
133+
# Convert watts to hectowatts for API
134+
api_value = value
135+
if re.search(r"Solis Feed in Power Limit$", self._name) and value is not None:
136+
api_value = str(int(value) / 100)
137+
await self.write_control_data(str(api_value))

custom_components/solis/sensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
_LOGGER = logging.getLogger(__name__)
4444

4545
# VERSION
46-
VERSION = "3.11.0"
46+
VERSION = "3.12.0"
4747

4848
# ATTRIBUTES
4949
LAST_UPDATED = "Last updated"

0 commit comments

Comments
 (0)