Skip to content

Commit

Permalink
Minimized the loading time
Browse files Browse the repository at this point in the history
Minimized the loading time of this component. More decent values now (~1s on docker; ~35s on RPi3)!
  • Loading branch information
plmilord authored Jan 15, 2022
1 parent 21ee132 commit 191d10e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Time sync with Home Assistant | ✓
- [x] Allow the installation of this custom component through the Home Assistant integrations menu (use of config_flow.py)
- [ ] Allow the installation of this custom component through HACS
- [ ] Bring back the ability to configure this custom component via the entries in configuration.yaml
- [ ] Investigate why it takes so long to load the component on an RPi (~2s on docker; ~85s on RPi3)
- [x] Investigate why it takes so long to load the component on an RPi (~2s on docker; ~85s on RPi3)
- [ ] Add programming capability for filter cycles
- [ ] Change the way I update entities (from polling mode to subscribing to updates)
- [ ] Customize entity IDs with **Spa Client** custom name to allow multiple integrations in the same Home Assistant instance
Expand Down
4 changes: 2 additions & 2 deletions custom_components/spaclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ async def async_setup_entry(hass, config_entry):
hass.loop.create_task(spa.read_all_msg())
hass.loop.create_task(spa.keep_alive_call())

spa.print_variables()

for component in SPACLIENT_COMPONENTS:
hass.async_create_task(hass.config_entries.async_forward_entry_setup(config_entry, component))

spa.print_variables()
return True


Expand Down
16 changes: 5 additions & 11 deletions custom_components/spaclient/spaclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,17 +708,15 @@ def send_message(self, type, payload):
message = prefix + bytes([length]) + type + payload + bytes([checksum]) + prefix

try:
#_LOGGER.info("send_message : %s", message) #Validation point
self.s.send(message)
except IOError as e:
#_LOGGER.info("send_message - IOError = %s", e) #Validation point
if e.errno != 11:
self.get_socket()

async def send_module_identification_request(self):
self.send_message(b'\x0a\xbf\x04', bytes([]))
while self.module_identification_loaded == False:
self.send_message(b'\x0a\xbf\x04', bytes([]))
await asyncio.sleep(.1)
self.read_msg()

async def keep_alive_call(self):
Expand All @@ -743,27 +741,23 @@ async def set_current_time(self):
self.send_message(b'\x0a\xbf\x21', bytes([now.hour]) + bytes([now.minute]))

async def send_configuration_request(self):
self.send_message(b'\x0a\xbf\x22', b'\x00' + b'\x00' + b'\x01')
while self.configuration_loaded == False:
self.send_message(b'\x0a\xbf\x22', b'\x00' + b'\x00' + b'\x01')
await asyncio.sleep(.1)
self.read_msg()

async def send_filter_cycles_request(self):
self.send_message(b'\x0a\xbf\x22', b'\x01' + b'\x00' + b'\x00')
while self.filter_cycles_loaded == False:
self.send_message(b'\x0a\xbf\x22', b'\x01' + b'\x00' + b'\x00')
await asyncio.sleep(.1)
self.read_msg()

async def send_information_request(self):
self.send_message(b'\x0a\xbf\x22', b'\x02' + b'\x00' + b'\x00')
while self.information_loaded == False:
self.send_message(b'\x0a\xbf\x22', b'\x02' + b'\x00' + b'\x00')
await asyncio.sleep(.1)
self.read_msg()

async def send_additional_information_request(self):
self.send_message(b'\x0a\xbf\x22', b'\x04' + b'\x00' + b'\x00')
while self.additional_information_loaded == False:
self.send_message(b'\x0a\xbf\x22', b'\x04' + b'\x00' + b'\x00')
await asyncio.sleep(.1)
self.read_msg()

def send_preferences_request(self): #Not use yet!
Expand Down

0 comments on commit 191d10e

Please sign in to comment.