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