Skip to content

Commit

Permalink
v2024.8.1-beta-8 disabling last entry data handling for now due to is…
Browse files Browse the repository at this point in the history
…sues caused by it
  • Loading branch information
jeroenterheerdt committed Aug 15, 2024
1 parent b765c93 commit 8391ae4
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 47 deletions.
89 changes: 46 additions & 43 deletions custom_components/smart_irrigation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,63 +593,66 @@ async def async_continuous_update_for_mapping(self, mapping_id):
_LOGGER.info(
f"[async_continuous_update_for_mapping] for sensor group {mapping_id}: zone {z} is not automatic, skipping."
)
# disabling this for now
# remove weather data from this mapping unless there are zones we did not calculate!
_LOGGER.debug(
f"[async_continuous_update_for_mapping] for sensor group {mapping_id}: zones_to_calculate: {zones_to_calculate}. if this is empty this means that all zones for this sensor group have been calculated and therefore we can remove the weather data"
)
if zones_to_calculate and len(zones_to_calculate) > 0:
_LOGGER.debug(
f"[async_continuous_update_for_mapping] for sensor group {mapping_id}: did not calculate all zones, keeping weather data for the sensor group."
)
else:
_LOGGER.debug(
f"clearing weather data for sensor group {mapping_id} since we calculated all dependent zones."
)
changes = {}
changes = self.clear_weatherdata_for_mapping(mapping)
self.store.async_update_mapping(mapping_id, changes=changes)
# _LOGGER.debug(
# f"[async_continuous_update_for_mapping] for sensor group {mapping_id}: zones_to_calculate: {zones_to_calculate}. if this is empty this means that all zones for this sensor group have been calculated and therefore we can remove the weather data"
# )
# if zones_to_calculate and len(zones_to_calculate) > 0:
# _LOGGER.debug(
# f"[async_continuous_update_for_mapping] for sensor group {mapping_id}: did not calculate all zones, keeping weather data for the sensor group."
# )
# else:
# _LOGGER.debug(
# f"clearing weather data for sensor group {mapping_id} since we calculated all dependent zones."
# )
# changes = {}
# changes = self.clear_weatherdata_for_mapping(mapping)
# self.store.async_update_mapping(mapping_id, changes=changes)

else:
_LOGGER.info(
f"[async_continuous_update_for_mapping] for sensor group {mapping_id}: sensor group does use weather service, skipping automatic update to avoid API calls that can incur costs."
)

def clear_weatherdata_for_mapping(self, mapping):
data_last_entry = {}
# Turning off the last entry retrieval for now
#
# data_last_entry = {}
# find the last entry for each key in the mapping
_LOGGER.debug(
f"[clear_weatherdata_for_mapping] finding last entry for each key in the sensor group."
)
_LOGGER.debug(
f"[clear_weatherdata_for_mapping] keys in sensor group {mapping}: {mapping.get(const.MAPPING_MAPPINGS)}"
)
if mapping.get(const.MAPPING_DATA):
for key in mapping.get(const.MAPPING_MAPPINGS):
for e in reversed(mapping.get(const.MAPPING_DATA)):
if key in e:
data_last_entry[key] = e[key]
continue # continue instead of break to continue to the next key
_LOGGER.debug(
f"[clear_weatherdata_for_mapping] last entry for each key in the sensor group: {data_last_entry}"
)
# _LOGGER.debug(
# f"[clear_weatherdata_for_mapping] finding last entry for each key in the sensor group."
# )
# _LOGGER.debug(
# f"[clear_weatherdata_for_mapping] keys in sensor group {mapping}: {mapping.get(const.MAPPING_MAPPINGS)}"
# )
# if mapping.get(const.MAPPING_DATA):
# for key in mapping.get(const.MAPPING_MAPPINGS):
# for e in reversed(mapping.get(const.MAPPING_DATA)):
# if key in e:
# data_last_entry[key] = e[key]
# continue # continue instead of break to continue to the next key
# _LOGGER.debug(
# f"[clear_weatherdata_for_mapping] last entry for each key in the sensor group: {data_last_entry}"
# )
# update the number of data points on zones that use this mapping
zones = self._get_zones_that_use_this_mapping(mapping.get(const.MAPPING_ID))
changes2 = {
const.ZONE_NUMBER_OF_DATA_POINTS: 0,
}
for z in zones:
self.store.async_update_zone(z, changes2)
async_dispatcher_send(
self.hass,
const.DOMAIN + "_config_updated",
z,
)
async_dispatcher_send(self.hass, const.DOMAIN + "_update_frontend")
# zones = self._get_zones_that_use_this_mapping(mapping.get(const.MAPPING_ID))
# changes2 = {
# const.ZONE_NUMBER_OF_DATA_POINTS: 0,
# }
# for z in zones:
# self.store.async_update_zone(z, changes2)
# async_dispatcher_send(
# self.hass,
# const.DOMAIN + "_config_updated",
# z,
# )
# async_dispatcher_send(self.hass, const.DOMAIN + "_update_frontend")

changes = {
const.MAPPING_DATA: [],
const.MAPPING_DATA_LAST_UPDATED: None,
const.MAPPING_DATA_LAST_ENTRY: data_last_entry,
# const.MAPPING_DATA_LAST_ENTRY: data_last_entry,
}
return changes

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.8.1-beta-7"
VERSION = "v2024.8.1-beta-8"
NAME = "Smart Irrigation"
MANUFACTURER = "@jeroenterheerdt"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11389,7 +11389,7 @@
.narrow=${this.narrow}
></ha-menu-button>
<div class="main-title">${ji("title", this.hass.language)}</div>
<div class="version">${"v2024.8.1-beta-7"}</div>
<div class="version">${"v2024.8.1-beta-8"}</div>
</div>
<ha-tabs
Expand Down
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.8.1-beta-7";
export const VERSION = "v2024.8.1-beta-8";
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.8.1-beta-7"
"version": "v2024.8.1-beta-8"
}

0 comments on commit 8391ae4

Please sign in to comment.