Skip to content

Commit

Permalink
Replace deprecated hass.components usage (#3528)
Browse files Browse the repository at this point in the history
* Replace deprecated hass.components usage

* lint

* Apply suggestions from code review

Co-authored-by: Martin Hjelmare <[email protected]>

* Update custom_components/hacs/base.py

* Restrict to 0 reported issues

* Revert "Restrict to 0 reported issues"

This reverts commit 19e3f1a.

---------

Co-authored-by: Erik Montnemery <[email protected]>
Co-authored-by: Martin Hjelmare <[email protected]>
  • Loading branch information
3 people authored May 7, 2024
1 parent c0a1d6e commit 70aa89c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion custom_components/hacs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from aiogithubapi import AIOGitHubAPIException, GitHub, GitHubAPI
from aiogithubapi.const import ACCEPT_HEADERS
from awesomeversion import AwesomeVersion
from homeassistant.components.frontend import async_remove_panel
from homeassistant.components.lovelace.system_health import system_health_info
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.const import Platform, __version__ as HAVERSION
Expand Down Expand Up @@ -266,7 +267,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
try:
if hass.data.get("frontend_panels", {}).get("hacs"):
hacs.log.info("Removing sidepanel")
hass.components.frontend.async_remove_panel("hacs")
async_remove_panel(hass, "hacs")
except AttributeError:
pass

Expand Down
7 changes: 5 additions & 2 deletions custom_components/hacs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
from aiogithubapi.objects.repository import AIOGitHubAPIRepository
from aiohttp.client import ClientSession, ClientTimeout
from awesomeversion import AwesomeVersion
from homeassistant.components.persistent_notification import (
async_create as async_create_persistent_notification,
)
from homeassistant.config_entries import ConfigEntry, ConfigEntryState
from homeassistant.const import EVENT_HOMEASSISTANT_FINAL_WRITE, Platform
from homeassistant.core import HomeAssistant, callback
Expand Down Expand Up @@ -628,8 +631,8 @@ async def startup_tasks(self, _=None) -> None:
for repo in critical:
if not repo["acknowledged"]:
self.log.critical("URGENT!: Check the HACS panel!")
self.hass.components.persistent_notification.create(
title="URGENT!", message="**Check the HACS panel!**"
async_create_persistent_notification(
self.hass, title="URGENT!", message="**Check the HACS panel!**"
)
break

Expand Down
4 changes: 3 additions & 1 deletion custom_components/hacs/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
from typing import TYPE_CHECKING

from homeassistant.components.frontend import async_register_built_in_panel
from homeassistant.core import HomeAssistant, callback

from .const import DOMAIN, URL_BASE
Expand Down Expand Up @@ -65,7 +66,8 @@ def async_register_frontend(hass: HomeAssistant, hacs: HacsBase) -> None:

# Add to sidepanel if needed
if DOMAIN not in hass.data.get("frontend_panels", {}):
hass.components.frontend.async_register_built_in_panel(
async_register_built_in_panel(
hass,
component_name="custom",
sidebar_title=hacs.configuration.sidepanel_title,
sidebar_icon=hacs.configuration.sidepanel_icon,
Expand Down

0 comments on commit 70aa89c

Please sign in to comment.