mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Add Unify Circuit (#35756)
This commit is contained in:
parent
71ebf8738f
commit
1f3d3c3e5b
@ -122,6 +122,7 @@ omit =
|
|||||||
homeassistant/components/cast/*
|
homeassistant/components/cast/*
|
||||||
homeassistant/components/cert_expiry/helper.py
|
homeassistant/components/cert_expiry/helper.py
|
||||||
homeassistant/components/channels/*
|
homeassistant/components/channels/*
|
||||||
|
homeassistant/components/circuit/*
|
||||||
homeassistant/components/cisco_ios/device_tracker.py
|
homeassistant/components/cisco_ios/device_tracker.py
|
||||||
homeassistant/components/cisco_mobility_express/device_tracker.py
|
homeassistant/components/cisco_mobility_express/device_tracker.py
|
||||||
homeassistant/components/cisco_webex_teams/notify.py
|
homeassistant/components/cisco_webex_teams/notify.py
|
||||||
|
@ -68,6 +68,7 @@ homeassistant/components/bt_smarthub/* @jxwolstenholme
|
|||||||
homeassistant/components/buienradar/* @mjj4791 @ties
|
homeassistant/components/buienradar/* @mjj4791 @ties
|
||||||
homeassistant/components/cast/* @emontnemery
|
homeassistant/components/cast/* @emontnemery
|
||||||
homeassistant/components/cert_expiry/* @Cereal2nd @jjlawren
|
homeassistant/components/cert_expiry/* @Cereal2nd @jjlawren
|
||||||
|
homeassistant/components/circuit/* @braam
|
||||||
homeassistant/components/cisco_ios/* @fbradyirl
|
homeassistant/components/cisco_ios/* @fbradyirl
|
||||||
homeassistant/components/cisco_mobility_express/* @fbradyirl
|
homeassistant/components/cisco_mobility_express/* @fbradyirl
|
||||||
homeassistant/components/cisco_webex_teams/* @fbradyirl
|
homeassistant/components/cisco_webex_teams/* @fbradyirl
|
||||||
|
38
homeassistant/components/circuit/__init__.py
Normal file
38
homeassistant/components/circuit/__init__.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
"""The Unify Circuit component."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.const import CONF_NAME, CONF_URL
|
||||||
|
from homeassistant.helpers import config_validation as cv, discovery
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
DOMAIN = "circuit"
|
||||||
|
CONF_WEBHOOK = "webhook"
|
||||||
|
|
||||||
|
WEBHOOK_SCHEMA = vol.Schema(
|
||||||
|
{vol.Optional(CONF_NAME): cv.string, vol.Required(CONF_URL): cv.string}
|
||||||
|
)
|
||||||
|
|
||||||
|
CONFIG_SCHEMA = vol.Schema(
|
||||||
|
{
|
||||||
|
DOMAIN: vol.Schema(
|
||||||
|
{vol.Required(CONF_WEBHOOK): vol.All(cv.ensure_list, [WEBHOOK_SCHEMA])}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
extra=vol.ALLOW_EXTRA,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def async_setup(hass, config):
|
||||||
|
"""Set up the Unify Circuit component."""
|
||||||
|
webhooks = config[DOMAIN][CONF_WEBHOOK]
|
||||||
|
|
||||||
|
for webhook_conf in webhooks:
|
||||||
|
hass.async_create_task(
|
||||||
|
discovery.async_load_platform(hass, "notify", DOMAIN, webhook_conf, config)
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
7
homeassistant/components/circuit/manifest.json
Normal file
7
homeassistant/components/circuit/manifest.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"domain": "circuit",
|
||||||
|
"name": "Unify Circuit",
|
||||||
|
"documentation": "https://www.home-assistant.io/integrations/circuit",
|
||||||
|
"codeowners": ["@braam"],
|
||||||
|
"requirements": ["circuit-webhook==1.0.1"]
|
||||||
|
}
|
37
homeassistant/components/circuit/notify.py
Normal file
37
homeassistant/components/circuit/notify.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
"""Unify Circuit platform for notify component."""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from circuit_webhook import Circuit
|
||||||
|
|
||||||
|
from homeassistant.components.notify import BaseNotificationService
|
||||||
|
from homeassistant.const import CONF_URL
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_service(hass, config, discovery_info=None):
|
||||||
|
"""Get the Unify Circuit notification service."""
|
||||||
|
if discovery_info is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return CircuitNotificationService(discovery_info)
|
||||||
|
|
||||||
|
|
||||||
|
class CircuitNotificationService(BaseNotificationService):
|
||||||
|
"""Implement the notification service for Unify Circuit."""
|
||||||
|
|
||||||
|
def __init__(self, config):
|
||||||
|
"""Initialize the service."""
|
||||||
|
self.webhook_url = config[CONF_URL]
|
||||||
|
|
||||||
|
def send_message(self, message=None, **kwargs):
|
||||||
|
"""Send a message to the webhook."""
|
||||||
|
|
||||||
|
webhook_url = self.webhook_url
|
||||||
|
|
||||||
|
if webhook_url and message:
|
||||||
|
try:
|
||||||
|
circuit_message = Circuit(url=webhook_url)
|
||||||
|
circuit_message.post(text=message)
|
||||||
|
except RuntimeError as err:
|
||||||
|
_LOGGER.error("Could not send notification. Error: %s", err)
|
@ -403,6 +403,9 @@ buienradar==1.0.4
|
|||||||
# homeassistant.components.caldav
|
# homeassistant.components.caldav
|
||||||
caldav==0.6.1
|
caldav==0.6.1
|
||||||
|
|
||||||
|
# homeassistant.components.circuit
|
||||||
|
circuit-webhook==1.0.1
|
||||||
|
|
||||||
# homeassistant.components.cisco_mobility_express
|
# homeassistant.components.cisco_mobility_express
|
||||||
ciscomobilityexpress==0.3.3
|
ciscomobilityexpress==0.3.3
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user