Skip to content

Commit

Permalink
fixes charge issue/discharge amps issue (#56)
Browse files Browse the repository at this point in the history
* fixes charge issue/discharge amps issue
  • Loading branch information
Pho3niX90 committed May 3, 2024
1 parent 1a4162a commit 84bc1cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 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.4.7"
VERSION = "1.4.8"
POLL_INTERVAL_SECONDS = 15
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.6.8"],
"version": "1.4.7"
"version": "1.4.8"
}
8 changes: 5 additions & 3 deletions custom_components/solis_modbus/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,12 @@ async def async_setup_entry(hass, config_entry: ConfigEntry, async_add_devices):
@callback
def update(now):
"""Update Modbus data periodically."""
controller = hass.data[DOMAIN][CONTROLLER]

_LOGGER.info(f"calling number update for {len(hass.data[DOMAIN]['number_entities'])} groups")
hass.create_task(get_modbus_updates(hass))
hass.create_task(get_modbus_updates(hass, controller))

async def get_modbus_updates(hass):
controller = hass.data[DOMAIN][CONTROLLER]
async def get_modbus_updates(hass, controller):
if not controller.connected():
await controller.connect()
await asyncio.gather(
Expand Down Expand Up @@ -140,6 +141,7 @@ def update(self):

value: float = self._hass.data[DOMAIN]['values'][str(self._register)]
self._hass.create_task(self.update_values(value))
self.schedule_update_ha_state()

async def update_values(self, value):
if value == 0 and self._modbus_controller.connected():
Expand Down

0 comments on commit 84bc1cf

Please sign in to comment.