Skip to content

Commit

Permalink
v2024.7.6: fix #438, fix #442, #444
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenterheerdt committed Jul 19, 2024
1 parent d9eb029 commit c238a7c
Show file tree
Hide file tree
Showing 8 changed files with 564 additions and 10,981 deletions.
22 changes: 17 additions & 5 deletions custom_components/smart_irrigation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,14 @@ async def _async_update_all(self, *args):
if mapping is not None and weatherdata is not None:
weatherdata[const.RETRIEVED_AT] = datetime.datetime.now()
mapping_data = mapping[const.MAPPING_DATA]
mapping_data.append(weatherdata)
if isinstance(mapping_data, list):
mapping_data.append(weatherdata)
elif isinstance(mapping_data, str):
mapping_data = [weatherdata]
else:
_LOGGER.error(
f"[async_update_all]: mapping is unexpected type: {mapping_data}"
)
_LOGGER.debug(
"async_update_all for mapping {} new mapping_data: {}".format(
mapping_id, weatherdata
Expand Down Expand Up @@ -1507,10 +1514,15 @@ async def async_update_zone_config(self, zone_id: int = None, data: dict = {}):
res, weatherdata=sensor_values, forecastdata=forecastdata
)
# remove mapping sensor data
changes = {}
changes[const.MAPPING_DATA] = []
# disabled because calculating single zone shouldn't remove weather data
# self.store.async_update_mapping(mapping_id, changes=changes)

# only remove weather data if there are no other zones dependent on this mapping
dependent_zones = self._get_zones_that_use_this_mapping(mapping_id)
if zone_id in dependent_zones:
dependent_zones.remove(zone_id)
if not dependent_zones:
changes = {}
changes[const.MAPPING_DATA] = []
self.store.async_update_mapping(mapping_id, changes=changes)
self.store.async_update_zone(zone_id, data)
async_dispatcher_send(
self.hass, const.DOMAIN + "_config_updated", zone_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ class SOLRAD_behavior(Enum):
class PyETO(SmartIrrigationCalculationModule):
def __init__(self, hass, description, config: {}) -> None:
if config:
if CONF_PYETO_FORECAST_DAYS in config and not isinstance(
config[CONF_PYETO_FORECAST_DAYS], int
if (
CONF_PYETO_FORECAST_DAYS in config
and not isinstance(config[CONF_PYETO_FORECAST_DAYS], int)
and not config[CONF_PYETO_FORECAST_DAYS].isnumeric()
):
config[CONF_PYETO_FORECAST_DAYS] = DEFAULT_FORECAST_DAYS

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,6 +1,6 @@
"""Store constants."""

VERSION = "v2024.7.5"
VERSION = "v2024.7.6"
NAME = "Smart Irrigation"
MANUFACTURER = "@jeroenterheerdt"

Expand Down
Loading

0 comments on commit c238a7c

Please sign in to comment.