Skip to content

Commit

Permalink
Merge pull request #23 from Pho3niX90/bugfix/issue_22
Browse files Browse the repository at this point in the history
Bugfix/issue 22
  • Loading branch information
Pho3niX90 authored Dec 15, 2023
2 parents 71bfcb6 + 1c86e29 commit a000c1c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/solis_modbus/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DOMAIN = "solis_modbus"
CONTROLLER = "modbus_controller"
VERSION = "1.2.1"
VERSION = "1.3.0"
POLL_INTERVAL_SECONDS = 5
MANUFACTURER = "Solis"
MODEL = "S6"
2 changes: 1 addition & 1 deletion custom_components/solis_modbus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"issue_tracker": "https://github.com/Pho3niX90/solis_modbus/issues",
"quality_scale": "silver",
"requirements": ["pymodbus==3.5.4"],
"version": "1.2.1"
"version": "1.3.0"
}
30 changes: 29 additions & 1 deletion custom_components/solis_modbus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,20 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
"decimal_places": 1,
"unit_of_measurement": UnitOfPower.WATT,
"state_class": SensorStateClass.MEASUREMENT,
"register": ['33051', '33052']}
"register": ['33051', '33052']},

{"type": "SDS", "name": "Solis Battery Charge Power",
"unique": "solis_modbus_inverter_battery_charge_power", "device_class": SensorDeviceClass.POWER,
"decimal_places": 1,
"unit_of_measurement": UnitOfPower.WATT,
"state_class": SensorStateClass.MEASUREMENT,
"register": ['33149', '33150', '33135', '0']},
{"type": "SDS", "name": "Solis Battery Discharge Power",
"unique": "solis_modbus_inverter_battery_discharge_power", "device_class": SensorDeviceClass.POWER,
"decimal_places": 1,
"unit_of_measurement": UnitOfPower.WATT,
"state_class": SensorStateClass.MEASUREMENT,
"register": ['33149', '33150', '33135', '1']}
]

for sensor_group in sensors:
Expand Down Expand Up @@ -999,6 +1012,21 @@ def update(self):
r1_value = self._hass.data[DOMAIN]['values'][self._register[0]] / (10 ** self._decimal_places)
r2_value = self._hass.data[DOMAIN]['values'][self._register[1]] / (10 ** self._decimal_places)
n_value = round(r1_value * r2_value)
if '33135' in self._register and len(self._register) == 4:
registers = self._register.copy()
self._register = registers[:2]

p_value = get_value(self)
d_w_value = registers[3]
d_value = self._hass.data[DOMAIN]['values'][registers[2]]

self._register = registers

if str(d_value) == str(d_w_value):
n_value = round(p_value * 10)
else:
n_value = 0


self._attr_available = True
self._attr_native_value = n_value
Expand Down

0 comments on commit a000c1c

Please sign in to comment.