Import persistent notification (part 5) (#63902)
This commit is contained in:
parent
03593aa21b
commit
b196064540
6 changed files with 18 additions and 9 deletions
|
@ -5,6 +5,7 @@ import logging
|
|||
import voluptuous as vol
|
||||
from vultr import Vultr as VultrAPI
|
||||
|
||||
from homeassistant.components import persistent_notification
|
||||
from homeassistant.const import CONF_API_KEY, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
@ -56,7 +57,8 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
vultr.update()
|
||||
except RuntimeError as ex:
|
||||
_LOGGER.error("Failed to make update API request because: %s", ex)
|
||||
hass.components.persistent_notification.create(
|
||||
persistent_notification.create(
|
||||
hass,
|
||||
"Error: {}" "".format(ex),
|
||||
title=NOTIFICATION_TITLE,
|
||||
notification_id=NOTIFICATION_ID,
|
||||
|
|
|
@ -7,6 +7,7 @@ import time
|
|||
import voluptuous as vol
|
||||
from waterfurnace.waterfurnace import WaterFurnace, WFCredentialError, WFException
|
||||
|
||||
from homeassistant.components import persistent_notification
|
||||
from homeassistant.const import (
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
|
@ -92,7 +93,8 @@ class WaterFurnaceData(threading.Thread):
|
|||
self._fails += 1
|
||||
if self._fails > MAX_FAILS:
|
||||
_LOGGER.error("Failed to refresh login credentials. Thread stopped")
|
||||
self.hass.components.persistent_notification.create(
|
||||
persistent_notification.create(
|
||||
self.hass,
|
||||
"Error:<br/>Connection to waterfurnace website failed "
|
||||
"the maximum number of times. Thread has stopped",
|
||||
title=NOTIFICATION_TITLE,
|
||||
|
|
|
@ -6,6 +6,7 @@ import voluptuous as vol
|
|||
from wirelesstagpy import WirelessTags
|
||||
from wirelesstagpy.exceptions import WirelessTagsException
|
||||
|
||||
from homeassistant.components import persistent_notification
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL,
|
||||
ATTR_VOLTAGE,
|
||||
|
@ -141,7 +142,8 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
hass.data[DOMAIN] = platform
|
||||
except (ConnectTimeout, HTTPError, WirelessTagsException) as ex:
|
||||
_LOGGER.error("Unable to connect to wirelesstag.net service: %s", str(ex))
|
||||
hass.components.persistent_notification.create(
|
||||
persistent_notification.create(
|
||||
hass,
|
||||
f"Error: {ex}<br />Please restart hass after fixing this.",
|
||||
title=NOTIFICATION_TITLE,
|
||||
notification_id=NOTIFICATION_ID,
|
||||
|
|
|
@ -6,6 +6,7 @@ import voluptuous as vol
|
|||
from xiaomi_gateway import XiaomiGateway, XiaomiGatewayDiscovery
|
||||
|
||||
from homeassistant import config_entries, core
|
||||
from homeassistant.components import persistent_notification
|
||||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL,
|
||||
ATTR_DEVICE_ID,
|
||||
|
@ -99,7 +100,8 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||
"""Service to add a new sub-device within the next 30 seconds."""
|
||||
gateway = call.data.get(ATTR_GW_MAC)
|
||||
gateway.write_to_hub(gateway.sid, join_permission="yes")
|
||||
hass.components.persistent_notification.async_create(
|
||||
persistent_notification.async_create(
|
||||
hass,
|
||||
"Join permission enabled for 30 seconds! "
|
||||
"Please press the pairing button of the new device once.",
|
||||
title="Xiaomi Aqara Gateway",
|
||||
|
|
|
@ -9,6 +9,7 @@ import time
|
|||
from miio import ChuangmiIr, DeviceException
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import persistent_notification
|
||||
from homeassistant.components.remote import (
|
||||
ATTR_DELAY_SECS,
|
||||
ATTR_NUM_REPEATS,
|
||||
|
@ -138,8 +139,8 @@ async def async_setup_platform(
|
|||
if "code" in message and message["code"]:
|
||||
log_msg = "Received command is: {}".format(message["code"])
|
||||
_LOGGER.info(log_msg)
|
||||
hass.components.persistent_notification.async_create(
|
||||
log_msg, title="Xiaomi Miio Remote"
|
||||
persistent_notification.async_create(
|
||||
hass, log_msg, title="Xiaomi Miio Remote"
|
||||
)
|
||||
return
|
||||
|
||||
|
@ -149,8 +150,8 @@ async def async_setup_platform(
|
|||
await asyncio.sleep(1)
|
||||
|
||||
_LOGGER.error("Timeout. No infrared command captured")
|
||||
hass.components.persistent_notification.async_create(
|
||||
"Timeout. No infrared command captured", title="Xiaomi Miio Remote"
|
||||
persistent_notification.async_create(
|
||||
hass, "Timeout. No infrared command captured", title="Xiaomi Miio Remote"
|
||||
)
|
||||
|
||||
platform = entity_platform.async_get_current_platform()
|
||||
|
|
|
@ -6,7 +6,6 @@ from async_timeout import timeout
|
|||
import pytest
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.bootstrap import SIGNAL_BOOTSTRAP_INTEGRATONS
|
||||
from homeassistant.components.websocket_api import const
|
||||
from homeassistant.components.websocket_api.auth import (
|
||||
TYPE_AUTH,
|
||||
|
@ -14,6 +13,7 @@ from homeassistant.components.websocket_api.auth import (
|
|||
TYPE_AUTH_REQUIRED,
|
||||
)
|
||||
from homeassistant.components.websocket_api.const import URL
|
||||
from homeassistant.const import SIGNAL_BOOTSTRAP_INTEGRATONS
|
||||
from homeassistant.core import Context, HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue