Skip to content

Commit

Permalink
Merge pull request #29 from Pho3niX90/28-charge-discharge-time-slots-…
Browse files Browse the repository at this point in the history
…error-displaying-new-selection

Improve performance of Solis Modbus sensor
  • Loading branch information
Pho3niX90 authored Jan 3, 2024
2 parents 58d24ce + 128241a commit c6c777b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions 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.3.1"
POLL_INTERVAL_SECONDS = 5
VERSION = "1.3.2"
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.5.4"],
"version": "1.3.1"
"version": "1.3.2"
}
7 changes: 0 additions & 7 deletions custom_components/solis_modbus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
sensor_entities: List[SensorEntity] = []
sensor_derived_entities: List[SensorEntity] = []
hass.data[DOMAIN]['values'] = {}
hass.data[DOMAIN]['POLL_COUNTER'] = 0

sensors = [
{
Expand Down Expand Up @@ -579,7 +578,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, asyn
},
]


sensors_derived = [
{"type": "SDS", "name": "Solis Status String",
"unique": "solis_modbus_inverter_current_status_string", "multiplier": 0,
Expand Down Expand Up @@ -635,7 +633,6 @@ def async_update(now):

for sensor_group in sensors:
start_register = sensor_group['register_start']
scan_interval = sensor_group['scan_interval']

count = sum(len(entity.get('register', [])) for entity in sensor_group.get('entities', []))

Expand All @@ -655,11 +652,7 @@ def async_update(now):
for entity in hass.data[DOMAIN]["sensor_derived_entities"]:
entity.update()

hass.data[DOMAIN]['POLL_COUNTER'] += 1

# Schedule the update function to run every X seconds
async_track_time_interval(hass, async_update, timedelta(seconds=POLL_INTERVAL_SECONDS))

return True


Expand Down
5 changes: 3 additions & 2 deletions custom_components/solis_modbus/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def update(self):
_LOGGER.debug(f'Update time entity with hour = {hour}, minute = {minute}')

self._attr_native_value = time(hour=hour, minute=minute)
# self.async_write_ha_state()

@property
def device_info(self):
Expand All @@ -136,10 +137,10 @@ def set_native_value(self, value):
if self._attr_native_value == value:
return
_LOGGER.debug(f'set_native_value : register = {self._register}, value = {value}')
self._attr_native_value = value
self.schedule_update_ha_state()

async def async_set_value(self, value: time) -> None:
"""Set the time."""
_LOGGER.debug(f'async_set_value : register = {self._register}, value = {value}')
self._modbus_controller.write_holding_registers(self._register, [value.hour, value.minute])
self._attr_native_value = value
self.async_write_ha_state()

0 comments on commit c6c777b

Please sign in to comment.