Skip to content

Commit

Permalink
v2024.5.0 improvements to handling of OWM API versioning removal
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenterheerdt committed May 10, 2024
1 parent 011688a commit 7c20680
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 11 deletions.
67 changes: 60 additions & 7 deletions custom_components/smart_irrigation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
if const.CONF_OWM_API_KEY in entry.options:
hass.data[const.DOMAIN][const.CONF_OWM_API_KEY] = entry.options.get(
const.CONF_OWM_API_KEY
).strip()
hass.data[const.DOMAIN][const.CONF_OWM_API_VERSION] = entry.options.get(
const.CONF_OWM_API_VERSION
)
)
if hass.data[const.DOMAIN][const.CONF_OWM_API_KEY] is not None:
hass.data[const.DOMAIN][const.CONF_OWM_API_KEY] = hass.data[
const.DOMAIN
][const.CONF_OWM_API_KEY].strip()
if const.CONF_OWM_API_VERSION in entry.options:
hass.data[const.DOMAIN][const.CONF_OWM_API_VERSION] = entry.options.get(
const.CONF_OWM_API_VERSION
)

# check if API version is 2.5, force it to be 3.0. API keys should still be valid.
if hass.data[const.DOMAIN][const.CONF_OWM_API_VERSION] == "2.5":
hass.data[const.DOMAIN][const.CONF_OWM_API_VERSION] = "3.0"
if const.CONF_OWM_API_VERSION in hass.data[const.DOMAIN]:
if hass.data[const.DOMAIN][const.CONF_OWM_API_VERSION] == "2.5":
hass.data[const.DOMAIN][const.CONF_OWM_API_VERSION] = "3.0"
coordinator = SmartIrrigationCoordinator(hass, session, entry, store)

device_registry = dr.async_get(hass)
Expand Down Expand Up @@ -1426,7 +1432,55 @@ def _reset_event_fired_today(self, *args):
@callback
def async_get_all_modules(self):
"""Get all ModuleEntries"""
# disabling the use of loadModules here because of HA DEV warning ("Detected blocking call to import_module inside the event loop") and I don't know how to fix it
res = []
"""res.append(
{
"name": "PyETO",
"description": "Calculate duration based on the FAO56 calculation from the PyETO library.",
"config": {},
"schema": [
{
"type": "boolean",
"name": "coastal",
"optional": True,
"default": False,
},
{
"type": "select",
"options": [...],
"name": "solrad_behavior",
"required": True,
"default": {"name": "EstimateFromTemp", "value": "1"},
},
{
"type": "integer",
"name": "forecast_days",
"required": True,
"default": 0,
},
],
}
)
res.append(
{
"name": "Static",
"description": "'Dummy' module with a static configurable delta.",
"config": {},
"schema": [
{"type": "float", "name": "delta", "required": True, "default": 0.0}
],
}
)
res.append(
{
"name": "Passthrough",
"description": "Passthrough module that returns the value of an Evapotranspiration sensor as delta.",
"config": {},
"schema": [],
}
)"""

mods = loadModules(const.MODULE_DIR)
for mod in mods:
m = getattr(mods[mod]["module"], mods[mod]["class"])
Expand All @@ -1439,7 +1493,6 @@ def async_get_all_modules(self):
"schema": s.schema_serialized(),
}
)

return res

async def async_remove_entity(self, zone_id: str):
Expand Down
2 changes: 1 addition & 1 deletion custom_components/smart_irrigation/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Store constants."""


VERSION = "v2024.4.5"
VERSION = "v2024.5.0"
NAME = "Smart Irrigation"
MANUFACTURER = "@jeroenterheerdt"

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion custom_components/smart_irrigation/frontend/src/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const VERSION = "v2024.4.5";
export const VERSION = "v2024.5.0";
export const REPO = "https://github.com/jeroenterheerdt/HASmartIrrigation;";
export const ISSUES_URL = REPO + "/issues";

Expand Down
2 changes: 1 addition & 1 deletion custom_components/smart_irrigation/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "local_push",
"issue_tracker": "https://github.com/jeroenterheerdt/HASmartIrrigation/issues",
"requirements": [],
"version": "v2024.4.5"
"version": "v2024.5.0"
}

0 comments on commit 7c20680

Please sign in to comment.