Skip to content

Commit

Permalink
v2024.7.1 fixing issue where sensor subscriptions weren't restored af…
Browse files Browse the repository at this point in the history
…ter reboot
  • Loading branch information
jeroenterheerdt committed Jul 7, 2024
1 parent b1f7284 commit 386a2c8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
45 changes: 25 additions & 20 deletions custom_components/smart_irrigation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
# Finish up by setting factory defaults if needed for zones, mappings and modules
await store.set_up_factory_defaults()

await coordinator.update_subscriptions()
return True


Expand Down Expand Up @@ -1323,6 +1324,7 @@ async def async_update_mapping_config(
async_dispatcher_send(
self.hass, const.DOMAIN + "_config_updated", mapping_id
)
self.update_subscriptions()
else:
# create a mapping
self.store.async_create_mapping(data)
Expand All @@ -1337,23 +1339,26 @@ def check_mapping_sources(self, mapping_id):
static_in_mapping = False
if mapping_id is not None:
mapping = self.store.get_mapping(mapping_id)
for the_map in mapping[const.MAPPING_MAPPINGS].values():
if not isinstance(the_map, str):
if (
the_map.get(const.MAPPING_CONF_SOURCE)
== const.MAPPING_CONF_SOURCE_WEATHER_SERVICE
):
owm_in_mapping = True
if (
the_map.get(const.MAPPING_CONF_SOURCE)
== const.MAPPING_CONF_SOURCE_SENSOR
):
sensor_in_mapping = True
if (
the_map.get(const.MAPPING_CONF_SOURCE)
== const.MAPPING_CONF_SOURCE_STATIC_VALUE
):
static_in_mapping = True
if mapping is not None:
for the_map in mapping[const.MAPPING_MAPPINGS].values():
if not isinstance(the_map, str):
if (
the_map.get(const.MAPPING_CONF_SOURCE)
== const.MAPPING_CONF_SOURCE_WEATHER_SERVICE
):
owm_in_mapping = True
if (
the_map.get(const.MAPPING_CONF_SOURCE)
== const.MAPPING_CONF_SOURCE_SENSOR
):
sensor_in_mapping = True
if (
the_map.get(const.MAPPING_CONF_SOURCE)
== const.MAPPING_CONF_SOURCE_STATIC_VALUE
):
static_in_mapping = True
else:
_LOGGER.debug(f"[check_mapping_sources] mapping {mapping_id} is None")
_LOGGER.debug(
"check_mapping_sources for mapping_id {} returns OWM: {}, sensor: {}, static: {}".format(
mapping_id, owm_in_mapping, sensor_in_mapping, static_in_mapping
Expand Down Expand Up @@ -1657,9 +1662,9 @@ async def async_update_zone_config(self, zone_id: int = None, data: dict = {}):
elif self.store.get_zone(zone_id):
# modify a zone
entry = self.store.async_update_zone(zone_id, data)
async_dispatcher_send(
self.hass, const.DOMAIN + "_config_updated", zone_id
) # make sure to update the HA entity here by listening to this in sensor.py.
async_dispatcher_send(self.hass, const.DOMAIN + "_config_updated", zone_id)
self.update_subscriptions()
# make sure to update the HA entity here by listening to this in sensor.py.
# this should be called by changes from the UI (by user) or by a calculation module (updating a duration), which should be done in python
else:
# create a zone
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.0"
VERSION = "v2024.7.1"
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.7.0";
export const VERSION = "v2024.7.1";
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.7.0"
"version": "v2024.7.1"
}

0 comments on commit 386a2c8

Please sign in to comment.