Skip to content

Commit

Permalink
version 0.0.11 - fixing #6
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenterheerdt committed May 26, 2020
1 parent 91447b1 commit 35283ce
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
6 changes: 1 addition & 5 deletions custom_components/smart_irrigation/OWMClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, api_key, latitude, longitude):
self.url = OWM_URL.format(latitude, longitude, api_key)

def get_data(self):
"""Return data."""
"""Return data."""
try:
r = requests.get(self.url)
d = json.loads(r.text)
Expand All @@ -36,7 +36,3 @@ def get_data(self):
_LOGGER.error("Failed to get OWM URL {}".format(r.text))
_LOGGER.error(Ex.strerror)
raise Ex

async def async_get_data(self):
"""Return data."""
return self.get_data()
4 changes: 2 additions & 2 deletions custom_components/smart_irrigation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async def _async_update_last_of_day(self, *args):
_LOGGER.info(
"Updating for last time today, calculating adjusted run time for next irrigation time!"
)
data = await self._async_update_data()
data = await self.hass.async_add_executor_job(self.api.get_data)
self._update_last_of_day()
_LOGGER.info("Bucket for today is: {} mm".format(self.bucket))
return data
Expand All @@ -243,7 +243,7 @@ async def _async_update_data(self):
"""Update data via library."""
_LOGGER.info("Updating Smart Irrigation Data")
try:
data = await self.api.async_get_data()
data = await self.hass.async_add_executor_job(self.api.get_data)
return data
except Exception as exception:
raise UpdateFailed(exception)
14 changes: 7 additions & 7 deletions custom_components/smart_irrigation/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ async def async_step_step3(self, user_input=None):
self._errors = {}

# only a single instance is allowed
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
# if self._async_current_entries():
# return self.async_abort(reason="single_instance_allowed")

if user_input is not None:
user_input[CONF_API_KEY] = self._api_key
Expand All @@ -67,8 +67,8 @@ async def async_step_step2(self, user_input=None):
self._errors = {}

# only a single instance is allowed
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
# if self._async_current_entries():
# return self.async_abort(reason="single_instance_allowed")

if user_input is not None:
reference_et = [
Expand Down Expand Up @@ -110,8 +110,8 @@ async def async_step_user(self, user_input=None):
self._errors = {}

# only a single instance is allowed
if self._async_current_entries():
return self.async_abort(reason="single_instance_allowed")
# if self._async_current_entries():
# return self.async_abort(reason="single_instance_allowed")

if user_input is not None:
valid_api = await self._test_api_key(user_input[CONF_API_KEY])
Expand Down Expand Up @@ -208,7 +208,7 @@ async def _test_api_key(self, api_key):
)

try:
client.get_data()
await self.hass.async_add_executor_job(client.get_data)
return True
except Exception as Ex:
_LOGGER.error(Ex.strerror)
Expand Down
3 changes: 1 addition & 2 deletions custom_components/smart_irrigation/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DOMAIN = "smart_irrigation"
NAME = "Smart Irrigation"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.9"
VERSION = "0.0.11"

ISSUE_URL = "https://github.com/jeroenterheerdt/HASmartIrrigation/issues"

Expand Down Expand Up @@ -93,7 +93,6 @@
-------------------------------------------------------------------
{NAME}
Version: {VERSION}
This is a custom integration! You will see warnings related to 'detected I/O inside the event loop'. This is normal and might be solved in future releases.
If you have any issues with this you need to open an issue here:
{ISSUE_URL}
-------------------------------------------------------------------
Expand Down

0 comments on commit 35283ce

Please sign in to comment.