diff --git a/custom_components/hacs/base.py b/custom_components/hacs/base.py index 692ee6602d2..ba3a9b7f930 100644 --- a/custom_components/hacs/base.py +++ b/custom_components/hacs/base.py @@ -159,7 +159,6 @@ class HacsStatus: startup: bool = True new: bool = False - background_task: bool = False reloading_data: bool = False upgrading_all: bool = False @@ -556,7 +555,6 @@ async def async_register_repository( async def startup_tasks(self, _event=None) -> None: """Tasks that are started after setup.""" await self.async_set_stage(HacsStage.STARTUP) - self.status.background_task = True self.status.startup = False self.hass.bus.async_fire("hacs/status", {}) @@ -568,7 +566,6 @@ async def startup_tasks(self, _event=None) -> None: if queue_task := self.tasks.get("prosess_queue"): await queue_task.execute_task() - self.status.background_task = False self.hass.bus.async_fire("hacs/status", {}) async def async_download_file(self, url: str) -> bytes | None: diff --git a/custom_components/hacs/diagnostics.py b/custom_components/hacs/diagnostics.py index 2480d9265ce..3727172d246 100644 --- a/custom_components/hacs/diagnostics.py +++ b/custom_components/hacs/diagnostics.py @@ -26,7 +26,6 @@ async def async_get_config_entry_diagnostics( "stage": hacs.stage, "version": hacs.version, "disabled_reason": hacs.system.disabled_reason, - "background_task": hacs.status.background_task, "new": hacs.status.new, "startup": hacs.status.startup, "categories": hacs.common.categories, diff --git a/custom_components/hacs/sensor.py b/custom_components/hacs/sensor.py index b57b8cdd369..f453c0dac15 100644 --- a/custom_components/hacs/sensor.py +++ b/custom_components/hacs/sensor.py @@ -66,8 +66,6 @@ def device_info(self) -> dict[str, any]: @callback def _update(self) -> None: """Update the sensor.""" - if self.hacs.status.background_task: - return repositories = [ repository diff --git a/custom_components/hacs/tasks/manager.py b/custom_components/hacs/tasks/manager.py index eb05971018d..18f223387e2 100644 --- a/custom_components/hacs/tasks/manager.py +++ b/custom_components/hacs/tasks/manager.py @@ -65,7 +65,6 @@ def get(self, slug: str) -> HacsTask | None: async def async_execute_runtume_tasks(self) -> None: """Execute the the execute methods of each runtime task if the stage matches.""" - self.hacs.status.background_task = True await asyncio.gather( *( task.execute_task() @@ -73,4 +72,3 @@ async def async_execute_runtume_tasks(self) -> None: if task.stages is not None and self.hacs.stage in task.stages ) ) - self.hacs.status.background_task = False diff --git a/custom_components/hacs/tasks/prosess_queue.py b/custom_components/hacs/tasks/prosess_queue.py index a16b384723c..7fdfaba4611 100644 --- a/custom_components/hacs/tasks/prosess_queue.py +++ b/custom_components/hacs/tasks/prosess_queue.py @@ -35,11 +35,7 @@ async def async_execute(self) -> None: f"Can update {can_update} repositories, items in queue {self.hacs.queue.pending_tasks}", ) if can_update != 0: - self.hacs.status.background_task = True - self.hass.bus.async_fire("hacs/status", {}) try: await self.hacs.queue.execute(can_update) except HacsExecutionStillInProgress: pass - self.hacs.status.background_task = False - self.hass.bus.async_fire("hacs/status", {}) diff --git a/custom_components/hacs/tasks/setup_websocket_api.py b/custom_components/hacs/tasks/setup_websocket_api.py index 254349117e0..7a1f3e3fb30 100644 --- a/custom_components/hacs/tasks/setup_websocket_api.py +++ b/custom_components/hacs/tasks/setup_websocket_api.py @@ -458,7 +458,7 @@ async def hacs_status(hass, connection, msg): msg["id"], { "startup": hacs.status.startup, - "background_task": hacs.status.background_task, + "background_task": False, "lovelace_mode": hacs.core.lovelace_mode, "reloading_data": hacs.status.reloading_data, "upgrading_all": hacs.status.upgrading_all, diff --git a/custom_components/hacs/tasks/update_all_repositories.py b/custom_components/hacs/tasks/update_all_repositories.py index b91866cd7cf..7784207c9d1 100644 --- a/custom_components/hacs/tasks/update_all_repositories.py +++ b/custom_components/hacs/tasks/update_all_repositories.py @@ -22,15 +22,11 @@ class Task(HacsTask): async def async_execute(self) -> None: """Execute the task.""" self.hacs.log.debug("Starting recurring background task for all repositories") - self.hacs.status.background_task = True - self.hass.bus.async_fire("hacs/status", {}) for repository in self.hacs.repositories.list_all: if repository.data.category in self.hacs.common.categories: self.hacs.queue.add(repository.common_update()) - self.hacs.status.background_task = False await self.hacs.data.async_write() - self.hass.bus.async_fire("hacs/status", {}) self.hass.bus.async_fire("hacs/repository", {"action": "reload"}) self.hacs.log.debug("Recurring background task for all repositories done") diff --git a/custom_components/hacs/tasks/update_downloaded_repositories.py b/custom_components/hacs/tasks/update_downloaded_repositories.py index c3f73a748a8..63f230e5a84 100644 --- a/custom_components/hacs/tasks/update_downloaded_repositories.py +++ b/custom_components/hacs/tasks/update_downloaded_repositories.py @@ -24,8 +24,6 @@ class Task(HacsTask): async def async_execute(self) -> None: """Execute the task.""" self.hacs.log.debug("Starting recurring background task for installed repositories") - self.hacs.status.background_task = True - self.hass.bus.async_fire("hacs/status", {}) for repository in self.hacs.repositories.list_all: if self.hacs.status.startup and repository.data.full_name == HacsGitHubRepo.INTEGRATION: @@ -36,7 +34,5 @@ async def async_execute(self) -> None: ): self.hacs.queue.add(repository.update_repository()) - self.hacs.status.background_task = False - self.hass.bus.async_fire("hacs/status", {}) await self.hacs.data.async_write() self.hacs.log.debug("Recurring background task for installed repositories done") diff --git a/custom_components/hacs/utils/data.py b/custom_components/hacs/utils/data.py index 6698dfa00e0..5b88cb644a3 100644 --- a/custom_components/hacs/utils/data.py +++ b/custom_components/hacs/utils/data.py @@ -41,7 +41,7 @@ def __init__(self, hacs: HacsBase): async def async_write(self, force: bool = False) -> None: """Write content to the store files.""" - if not force and (self.hacs.status.background_task or self.hacs.system.disabled): + if not force and self.hacs.system.disabled: return self.logger.debug("Saving data") diff --git a/tests/conftest.py b/tests/conftest.py index ac55d21abb4..96ca5c5fe8e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -128,7 +128,6 @@ async def hacs(hass: HomeAssistant): hacs_obj.core.ha_version = AwesomeVersion(HAVERSION) hacs_obj.version = hacs_obj.integration.version hacs_obj.configuration.token = TOKEN - hacs_obj.status.background_task = False ## New GitHub client hacs_obj.githubapi = GitHubAPI( diff --git a/tests/hacsbase/test_hacsbase_data.py b/tests/hacsbase/test_hacsbase_data.py index 4f4aedd6b87..4e3f7c169a5 100644 --- a/tests/hacsbase/test_hacsbase_data.py +++ b/tests/hacsbase/test_hacsbase_data.py @@ -20,7 +20,6 @@ async def test_hacs_data_async_write1(hacs, repository): @pytest.mark.asyncio async def test_hacs_data_async_write2(hacs): data = HacsData(hacs) - hacs.status.background_task = False hacs.system.disabled_reason = None hacs.repositories = HacsRepositories() await data.async_write() diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 8f7e77770f0..315053bb4e3 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -90,42 +90,6 @@ async def test_sensor_update_event(hacs: HacsBase, hass: HomeAssistant): assert sensor.state == 1 -@pytest.mark.asyncio -async def test_sensor_update_event_background_task(hacs: HacsBase, hass: HomeAssistant): - sensor = await sensor_setup(hacs, hass) - - repository = HacsIntegrationRepository(hacs, "test/one") - repository.data.update_data( - { - "id": "123", - "installed": True, - "installed_version": "1", - "last_version": "2", - } - ) - hacs.repositories.register(repository) - - repository = HacsIntegrationRepository(hacs, "test/two") - repository.data.update_data( - { - "id": "321", - "installed": True, - "installed_version": "1", - "last_version": "1", - } - ) - hacs.repositories.register(repository) - - hacs.common.categories = {"integration"} - assert sensor.state is None - hacs.status.background_task = True - - hass.bus.async_fire("hacs/status", {}) - - await hass.async_block_till_done() - assert sensor.state is None - - @pytest.mark.asyncio async def test_sensor_update_manual(hacs: HacsBase, hass: HomeAssistant): sensor = await sensor_setup(hacs, hass)