Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
aneisch committed Feb 27, 2023
1 parent f78e9c7 commit 0031a75
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 75 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/check-ha-release-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ on:
jobs:
check-ha-config:
name: Check Configuration
runs-on: ubuntu-latest
#runs-on: ubuntu-latest
runs-on: self-hosted
steps:
- name: Log Trigger Type
run: 'echo "Trigger: ${{ github.event_name }}"'
Expand Down Expand Up @@ -78,4 +79,4 @@ jobs:
release_name: Release for v${{ github.event.client_payload.version }}
body: Release for v${{ github.event.client_payload.version }}
draft: false
prerelease: false
prerelease: false
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Entities in the [`camera`](https://www.home-assistant.io/components/camera) doma
Entities in the [`climate`](https://www.home-assistant.io/components/climate) domain | 1
Entities in the [`counter`](https://www.home-assistant.io/components/counter) domain | 1
Entities in the [`cover`](https://www.home-assistant.io/components/cover) domain | 5
Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 21
Entities in the [`device_tracker`](https://www.home-assistant.io/components/device_tracker) domain | 22
Entities in the [`fan`](https://www.home-assistant.io/components/fan) domain | 3
Entities in the [`group`](https://www.home-assistant.io/components/group) domain | 13
Entities in the [`input_boolean`](https://www.home-assistant.io/components/input_boolean) domain | 23
Expand All @@ -92,17 +92,17 @@ Entities in the [`remote`](https://www.home-assistant.io/components/remote) doma
Entities in the [`scene`](https://www.home-assistant.io/components/scene) domain | 2
Entities in the [`script`](https://www.home-assistant.io/components/script) domain | 46
Entities in the [`select`](https://www.home-assistant.io/components/select) domain | 22
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 355
Entities in the [`sensor`](https://www.home-assistant.io/components/sensor) domain | 357
Entities in the [`setter`](https://www.home-assistant.io/components/setter) domain | 1
Entities in the [`siren`](https://www.home-assistant.io/components/siren) domain | 1
Entities in the [`sun`](https://www.home-assistant.io/components/sun) domain | 1
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 148
Entities in the [`switch`](https://www.home-assistant.io/components/switch) domain | 149
Entities in the [`timer`](https://www.home-assistant.io/components/timer) domain | 1
Entities in the [`update`](https://www.home-assistant.io/components/update) domain | 25
Entities in the [`vacuum`](https://www.home-assistant.io/components/vacuum) domain | 1
Entities in the [`weather`](https://www.home-assistant.io/components/weather) domain | 2
Entities in the [`zone`](https://www.home-assistant.io/components/zone) domain | 6
**Total state objects** | **1139**
**Total state objects** | **1143**
## The HACS integrations/plugins that I use:
**Appdaemon**:<br>
[aneisch/follow_me_appdaemon](https://github.com/aneisch/follow_me_appdaemon)<br>
Expand Down
42 changes: 36 additions & 6 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,9 @@ def _write_file():

try:
await self.hass.async_add_executor_job(_write_file)
except BaseException as error: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as error:
self.log.error("Could not write data to %s - %s", file_path, error)
return False

Expand All @@ -476,7 +478,9 @@ async def async_can_update(self) -> int:
f"{reset.hour}:{reset.minute}:{reset.second}",
)
self.disable_hacs(HacsDisabledReason.RATE_LIMIT)
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
self.log.exception(exception)

return 0
Expand Down Expand Up @@ -515,7 +519,9 @@ async def async_github_api_method(
raise exception
except GitHubException as exception:
_exception = exception
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
self.log.exception(exception)
_exception = exception

Expand Down Expand Up @@ -726,7 +732,9 @@ async def async_download_file(self, url: str, *, headers: dict | None = None) ->
await asyncio.sleep(1)
continue

except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
self.log.exception("Download failed - %s", exception)

return None
Expand All @@ -742,7 +750,9 @@ async def async_recreate_entities(self) -> None:
entry=self.configuration.config_entry,
platforms=platforms,
)
self.hass.config_entries.async_setup_platforms(self.configuration.config_entry, platforms)
await self.hass.config_entries.async_forward_entry_setups(
self.configuration.config_entry, platforms
)

@callback
def async_dispatch(self, signal: HacsDispatchEvent, data: dict | None = None) -> None:
Expand All @@ -764,7 +774,18 @@ def set_active_categories(self) -> None:
if self.configuration.appdaemon:
self.enable_hacs_category(HacsCategory.APPDAEMON)
if self.configuration.netdaemon:
self.enable_hacs_category(HacsCategory.NETDAEMON)
downloaded_netdaemon = [
x
for x in self.repositories.list_downloaded
if x.data.category == HacsCategory.NETDAEMON
]
if len(downloaded_netdaemon) != 0:
self.log.warning(
"NetDaemon in HACS is deprectaded. It will stop working in the future. "
"Please remove all your current NetDaemon repositories from HACS "
"and download them manually if you want to continue using them."
)
self.enable_hacs_category(HacsCategory.NETDAEMON)

async def async_load_hacs_from_github(self, _=None) -> None:
"""Load HACS from GitHub."""
Expand Down Expand Up @@ -849,6 +870,15 @@ async def async_get_category_repositories_experimental(self, category: str) -> N
repository.repository_manifest.update_data(
{**dict(HACS_MANIFEST_KEYS_TO_EXPORT), **manifest}
)
self.async_dispatch(
HacsDispatchEvent.REPOSITORY,
{
"id": 1337,
"action": "update",
"repository": repository.data.full_name,
"repository_id": repository.data.id,
},
)

if category == "integration":
self.status.inital_fetch_done = True
Expand Down
6 changes: 3 additions & 3 deletions custom_components/hacs/manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"domain": "hacs",
"name": "HACS",
"codeowners": [
"@ludeeus"
],
Expand All @@ -12,12 +14,10 @@
"repairs"
],
"documentation": "https://hacs.xyz/docs/configuration/start",
"domain": "hacs",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/hacs/integration/issues",
"name": "HACS",
"requirements": [
"aiogithubapi>=22.10.1"
],
"version": "1.30.1"
"version": "1.31.0"
}
2 changes: 1 addition & 1 deletion custom_components/hacs/repairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def async_step_init(
) -> data_entry_flow.FlowResult:
"""Handle the first step of a fix flow."""

return await (self.async_step_confirm_restart())
return await self.async_step_confirm_restart()

async def async_step_confirm_restart(
self, user_input: dict[str, str] | None = None
Expand Down
50 changes: 32 additions & 18 deletions custom_components/hacs/repositories/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
("description", ""),
("downloads", 0),
("domain", None),
("etag_releases", None),
("etag_repository", None),
("full_name", ""),
("last_commit", None),
Expand Down Expand Up @@ -143,6 +144,7 @@ class RepositoryData:
domain: str = None
downloads: int = 0
etag_repository: str = None
etag_releases: str = None
file_name: str = ""
first_install: bool = False
full_name: str = ""
Expand Down Expand Up @@ -505,14 +507,18 @@ async def common_registration(self) -> None:
self.data.description = self.data.description

@concurrent(concurrenttasks=10, backoff_time=5)
async def common_update(self, ignore_issues=False, force=False) -> bool:
async def common_update(self, ignore_issues=False, force=False, skip_releases=False) -> bool:
"""Common information update steps of the repository."""
self.logger.debug("%s Getting repository information", self.string)

# Attach repository
current_etag = self.data.etag_repository
try:
await self.common_update_data(ignore_issues=ignore_issues, force=force)
await self.common_update_data(
ignore_issues=ignore_issues,
force=force,
skip_releases=skip_releases,
)
except HacsRepositoryExistException:
self.data.full_name = self.hacs.common.renamed_repositories[self.data.full_name]
await self.common_update_data(ignore_issues=ignore_issues, force=force)
Expand Down Expand Up @@ -746,9 +752,8 @@ def _info_file_variants() -> tuple[str, ...]:

def remove(self) -> None:
"""Run remove tasks."""
self.logger.info("%s Starting removal", self.string)

if self.hacs.repositories.is_registered(repository_id=str(self.data.id)):
self.logger.info("%s Starting removal", self.string)
self.hacs.repositories.unregister(self)

async def uninstall(self) -> None:
Expand Down Expand Up @@ -830,7 +835,9 @@ async def remove_local_directory(self) -> None:
"%s Presumed local content path %s does not exist", self.string, local_path
)

except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
self.logger.debug("%s Removing %s failed with %s", self.string, local_path, exception)
return False
return True
Expand Down Expand Up @@ -1048,6 +1055,7 @@ async def common_update_data(
ignore_issues: bool = False,
force: bool = False,
retry=False,
skip_releases=False,
) -> None:
"""Common update data."""
releases = []
Expand Down Expand Up @@ -1096,19 +1104,20 @@ async def common_update_data(
raise HacsException(f"{self} Repository has been requested to be removed.")

# Get releases.
try:
releases = await self.get_releases(
prerelease=self.data.show_beta,
returnlimit=self.hacs.configuration.release_limit,
)
if releases:
self.data.releases = True
self.releases.objects = releases
self.data.published_tags = [x.tag_name for x in self.releases.objects]
self.data.last_version = next(iter(self.data.published_tags))
if not skip_releases:
try:
releases = await self.get_releases(
prerelease=self.data.show_beta,
returnlimit=self.hacs.configuration.release_limit,
)
if releases:
self.data.releases = True
self.releases.objects = releases
self.data.published_tags = [x.tag_name for x in self.releases.objects]
self.data.last_version = next(iter(self.data.published_tags))

except HacsException:
self.data.releases = False
except HacsException:
self.data.releases = False

if not self.force_branch:
self.ref = self.version_to_download()
Expand All @@ -1118,6 +1127,9 @@ async def common_update_data(
if assets := release.assets:
downloads = next(iter(assets)).download_count
self.data.downloads = downloads
elif self.hacs.system.generator and self.repository_object:
await self.repository_object.set_last_commit()
self.data.last_commit = self.repository_object.last_commit

self.hacs.log.debug(
"%s Running checks against %s", self.string, self.ref.replace("tags/", "")
Expand Down Expand Up @@ -1247,7 +1259,9 @@ async def dowload_repository_content(self, content: FileInformation) -> None:
return
self.validate.errors.append(f"[{content.name}] was not downloaded.")

except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
self.validate.errors.append(f"Download was not completed [{exception}]")

async def async_remove_entity_device(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/hacs/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"release_limit": "Number of releases to show.",
"debug": "Enable debug.",
"appdaemon": "Enable AppDaemon apps discovery & tracking",
"netdaemon": "Enable NetDaemon apps discovery & tracking",
"netdaemon": "[DEPRECATED] Enable NetDaemon apps discovery & tracking",
"sidepanel_icon": "Side panel icon",
"sidepanel_title": "Side panel title"
}
Expand Down
4 changes: 3 additions & 1 deletion custom_components/hacs/utils/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def create(self) -> None:
self.local_path,
self.backup_path_full,
)
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
self.hacs.log.warning("Could not create backup: %s", exception)

def restore(self) -> None:
Expand Down
6 changes: 5 additions & 1 deletion custom_components/hacs/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ async def restore(self):
self.async_restore_repository(entry, repo_data)

self.logger.info("<HacsData restore> Restore done")
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
self.logger.critical(
"<HacsData restore> [%s] Restore Failed!", exception, exc_info=exception
)
Expand Down Expand Up @@ -282,6 +284,8 @@ def async_restore_repository(self, entry: str, repository_data: dict[str, Any]):
repository.data.description = repository_data.get("description", "")
repository.data.downloads = repository_data.get("downloads", 0)
repository.data.last_updated = repository_data.get("last_updated", 0)
if self.hacs.system.generator:
repository.data.etag_releases = repository_data.get("etag_releases")
repository.data.etag_repository = repository_data.get("etag_repository")
repository.data.topics = [
topic for topic in repository_data.get("topics", []) if topic not in TOPIC_FILTER
Expand Down
4 changes: 3 additions & 1 deletion custom_components/hacs/utils/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def load(self):
"""Load the data from disk if version matches."""
try:
data = json_util.load_json(self.path)
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
_LOGGER.critical(
"Could not load '%s', restore it from a backup or delete the file: %s",
self.path,
Expand Down
4 changes: 3 additions & 1 deletion custom_components/hacs/utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def render_template(hacs: HacsBase, content: str, context: HacsRepository) -> st
version_available=context.releases.last_release,
version_installed=context.display_installed_version,
)
except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
context.logger.debug(exception)
return content
5 changes: 3 additions & 2 deletions custom_components/hacs/websocket/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ async def hacs_repositories_add(
category=category,
)

except BaseException as exception: # lgtm [py/catch-base-exception] pylint: disable=broad-except
except (
BaseException # lgtm [py/catch-base-exception] pylint: disable=broad-except
) as exception:
hacs.async_dispatch(
HacsDispatchEvent.ERROR,
{
Expand All @@ -175,7 +177,6 @@ async def hacs_repositories_add(
)

else:

hacs.async_dispatch(
HacsDispatchEvent.ERROR,
{
Expand Down
2 changes: 1 addition & 1 deletion extras/Node-RED/flows.json

Large diffs are not rendered by default.

Loading

0 comments on commit 0031a75

Please sign in to comment.