Skip to content

Commit

Permalink
Reduce sleep when scraping. Remove minimum update interval. Closes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkastelec committed Apr 11, 2021
1 parent 3052e16 commit 4bc7257
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ custom_components
Configuration variables:
- `username`: Email address used for logging into WEM Portal
- `password`: Password used for logging into WEM Portal
- `scan_interval (Optional)`: Defines update frequency. Optional and in seconds (defaults to 30 min, minimum value is 15
min).
- `scan_interval (Optional)`: Defines update frequency. Optional and in seconds (defaults to 30 min). Setting update
frequency bellow 15 min is not recommended.

Add the following to your `configuration.yaml` file:

Expand Down
2 changes: 1 addition & 1 deletion custom_components/wemportal/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"documentation": "https://github.com/erikkastelec/hass-WEM-Portal",
"issue_tracker": "https://github.com/erikkastelec/hass-WEM-Portal/issues",
"dependencies": [],
"version": "1.1.3",
"version": "1.1.5",
"codeowners": [
"@erikkastelec"
],
Expand Down
2 changes: 1 addition & 1 deletion custom_components/wemportal/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async def async_update_data():
name="wem_portal_sensor",
update_method=async_update_data,
# Polling interval. Will only be polled if there are subscribers.
update_interval=max(config.get(CONF_SCAN_INTERVAL), timedelta(minutes=15)),
update_interval=config.get(CONF_SCAN_INTERVAL),
)

# Fetch initial data so we have data when entities subscribe
Expand Down
8 changes: 4 additions & 4 deletions custom_components/wemportal/wemportalapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def parse(self, response):
callback=self.navigate_to_expert_page)

def navigate_to_expert_page(self, response):
# sleep for 5 seconds to get proper language and updated data
time.sleep(5)
# sleep for 1 seconds to get proper language and updated data
time.sleep(1)
_LOGGER.debug("Print user page HTML: %s", response.text)
if response.url == 'https://www.wemportal.com/Web/login.aspx?AspxAutoDetectCookieSupport=1':
_LOGGER.debug("Authentication failed")
Expand Down Expand Up @@ -107,8 +107,8 @@ def generate_form_data(self, response):
}

def scrape_pages(self, response):
# sleep for 2 seconds to get proper language and updated data
time.sleep(2)
# sleep for 1 seconds to get proper language and updated data
time.sleep(1)
_LOGGER.debug("Print expert page HTML: %s", response.text)
if self.authErrorFlag:
yield {'authErrorFlag': True}
Expand Down
4 changes: 2 additions & 2 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Full restart of the Home Assistant is required. Restarting from GUI won't work,
Configuration variables:
- `username`: Email address used for logging into WEM Portal
- `password`: Password used for logging into WEM Portal
- `scan_interval (Optional)`: Defines update frequency. Optional and in seconds (defaults to 30 min, minimum value is 15
min).
- `scan_interval (Optional)`: Defines update frequency. Optional and in seconds (defaults to 30 min). Setting update
frequency bellow 15 min is not recommended.

Add the following to your `configuration.yaml` file:

Expand Down

0 comments on commit 4bc7257

Please sign in to comment.