Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion homeassistant/components/aladdin_connect/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from aladdin_connect import AladdinConnectClient
import voluptuous as vol

from homeassistant.components import persistent_notification
from homeassistant.components.cover import (
PLATFORM_SCHEMA as BASE_PLATFORM_SCHEMA,
CoverDeviceClass,
Expand Down Expand Up @@ -55,7 +56,8 @@ def setup_platform(
)
except (TypeError, KeyError, NameError, ValueError) as ex:
_LOGGER.error("%s", ex)
hass.components.persistent_notification.create(
persistent_notification.create(
hass,
"Error: {ex}<br />You will need to restart hass after fixing.",
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID,
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/alpha_vantage/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from alpha_vantage.timeseries import TimeSeries
import voluptuous as vol

from homeassistant.components import persistent_notification
from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
from homeassistant.const import ATTR_ATTRIBUTION, CONF_API_KEY, CONF_CURRENCY, CONF_NAME
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -79,7 +80,7 @@ def setup_platform(

if not symbols and not conversions:
msg = "No symbols or currencies configured."
hass.components.persistent_notification.create(msg, "Sensor alpha_vantage")
persistent_notification.create(hass, msg, "Sensor alpha_vantage")
_LOGGER.warning(msg)
return

Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/androidtv/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from androidtv.exceptions import LockNotAcquiredException
import voluptuous as vol

from homeassistant.components import persistent_notification
from homeassistant.components.media_player import PLATFORM_SCHEMA, MediaPlayerEntity
from homeassistant.components.media_player.const import (
SUPPORT_NEXT_TRACK,
Expand Down Expand Up @@ -534,7 +535,8 @@ async def learn_sendevent(self):
self.async_write_ha_state()

msg = f"Output from service '{SERVICE_LEARN_SENDEVENT}' from {self.entity_id}: '{output}'"
self.hass.components.persistent_notification.async_create(
persistent_notification.async_create(
self.hass,
msg,
title="Android TV",
)
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/arlo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from requests.exceptions import ConnectTimeout, HTTPError
import voluptuous as vol

from homeassistant.components import persistent_notification
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers import config_validation as cv
Expand Down Expand Up @@ -70,7 +71,8 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:

except (ConnectTimeout, HTTPError) as ex:
_LOGGER.error("Unable to connect to Netgear Arlo: %s", str(ex))
hass.components.persistent_notification.create(
persistent_notification.create(
hass,
f"Error: {ex}<br />You will need to restart hass after fixing.",
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID,
Expand Down
22 changes: 13 additions & 9 deletions homeassistant/components/broadlink/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
import voluptuous as vol

from homeassistant.components import persistent_notification
from homeassistant.components.remote import (
ATTR_ALTERNATIVE,
ATTR_COMMAND_TYPE,
Expand Down Expand Up @@ -317,7 +318,8 @@ async def _async_learn_ir_command(self, command):
_LOGGER.debug("Failed to enter learning mode: %s", err)
raise

self.hass.components.persistent_notification.async_create(
persistent_notification.async_create(
self.hass,
f"Press the '{command}' button.",
title="Learn command",
notification_id="learn_command",
Expand All @@ -339,8 +341,8 @@ async def _async_learn_ir_command(self, command):
)

finally:
self.hass.components.persistent_notification.async_dismiss(
notification_id="learn_command"
persistent_notification.async_dismiss(
self.hass, notification_id="learn_command"
)

async def _async_learn_rf_command(self, command):
Expand All @@ -354,7 +356,8 @@ async def _async_learn_rf_command(self, command):
_LOGGER.debug("Failed to sweep frequency: %s", err)
raise

self.hass.components.persistent_notification.async_create(
persistent_notification.async_create(
self.hass,
f"Press and hold the '{command}' button.",
title="Sweep frequency",
notification_id="sweep_frequency",
Expand All @@ -375,8 +378,8 @@ async def _async_learn_rf_command(self, command):
)

finally:
self.hass.components.persistent_notification.async_dismiss(
notification_id="sweep_frequency"
persistent_notification.async_dismiss(
self.hass, notification_id="sweep_frequency"
)

await asyncio.sleep(1)
Expand All @@ -388,7 +391,8 @@ async def _async_learn_rf_command(self, command):
_LOGGER.debug("Failed to enter learning mode: %s", err)
raise

self.hass.components.persistent_notification.async_create(
persistent_notification.async_create(
self.hass,
f"Press the '{command}' button again.",
title="Learn command",
notification_id="learn_command",
Expand All @@ -410,8 +414,8 @@ async def _async_learn_rf_command(self, command):
)

finally:
self.hass.components.persistent_notification.async_dismiss(
notification_id="learn_command"
persistent_notification.async_dismiss(
self.hass, notification_id="learn_command"
)

async def async_delete_command(self, **kwargs):
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/cloud/alexa_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import async_timeout
from hass_nabucasa import Cloud, cloud_api

from homeassistant.components import persistent_notification
from homeassistant.components.alexa import (
DOMAIN as ALEXA_DOMAIN,
config as alexa_config,
Expand Down Expand Up @@ -158,7 +159,8 @@ async def async_get_access_token(self):
if body["reason"] in ("RefreshTokenNotFound", "UnknownRegion"):
if self.should_report_state:
await self._prefs.async_update(alexa_report_state=False)
self.hass.components.persistent_notification.async_create(
persistent_notification.async_create(
self.hass,
f"There was an error reporting state to Alexa ({body['reason']}). "
"Please re-link your Alexa skill via the Alexa app to "
"continue using it.",
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import aiohttp
from hass_nabucasa.client import CloudClient as Interface

from homeassistant.components import persistent_notification
from homeassistant.components.alexa import (
errors as alexa_errors,
smart_home as alexa_sh,
Expand Down Expand Up @@ -163,9 +164,7 @@ async def logout_cleanups(self) -> None:
@callback
def user_message(self, identifier: str, title: str, message: str) -> None:
"""Create a message for user to UI."""
self._hass.components.persistent_notification.async_create(
message, title, identifier
)
persistent_notification.async_create(self._hass, message, title, identifier)

@callback
def dispatcher_message(self, identifier: str, data: Any = None) -> None:
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/decora_wifi/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from decora_wifi.models.residential_account import ResidentialAccount
import voluptuous as vol

from homeassistant.components import persistent_notification
from homeassistant.components.light import (
ATTR_BRIGHTNESS,
ATTR_TRANSITION,
Expand Down Expand Up @@ -54,8 +55,8 @@ def setup_platform(
if success is None:
msg = "Failed to log into myLeviton Services. Check credentials."
_LOGGER.error(msg)
hass.components.persistent_notification.create(
msg, title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID
persistent_notification.create(
hass, msg, title=NOTIFICATION_TITLE, notification_id=NOTIFICATION_ID
)
return

Expand Down
7 changes: 5 additions & 2 deletions homeassistant/components/demo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from random import random

from homeassistant import bootstrap, config_entries
from homeassistant.components import persistent_notification
from homeassistant.components.recorder.statistics import (
async_add_external_statistics,
get_last_statistics,
Expand Down Expand Up @@ -163,8 +164,10 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return False

# Set up example persistent notification
hass.components.persistent_notification.async_create(
"This is an example of a persistent notification.", title="Example Notification"
persistent_notification.async_create(
hass,
"This is an example of a persistent notification.",
title="Example Notification",
)

async def demo_start_listener(_event):
Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/demo/button.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Demo platform that offers a fake button entity."""
from __future__ import annotations

from homeassistant.components import persistent_notification
from homeassistant.components.button import ButtonEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import DEVICE_DEFAULT_NAME
Expand Down Expand Up @@ -60,6 +61,6 @@ def __init__(

async def async_press(self) -> None:
"""Send out a persistent notification."""
self.hass.components.persistent_notification.async_create(
"Button pressed", title="Button"
persistent_notification.async_create(
self.hass, "Button pressed", title="Button"
)