mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
parent
dfcab456c6
commit
1719bc6fd3
@ -275,7 +275,6 @@ omit =
|
||||
homeassistant/components/heatmiser/climate.py
|
||||
homeassistant/components/hikvision/binary_sensor.py
|
||||
homeassistant/components/hikvisioncam/switch.py
|
||||
homeassistant/components/hipchat/notify.py
|
||||
homeassistant/components/hitron_coda/device_tracker.py
|
||||
homeassistant/components/hive/*
|
||||
homeassistant/components/hlk_sw16/*
|
||||
|
@ -1 +0,0 @@
|
||||
"""The hipchat component."""
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"domain": "hipchat",
|
||||
"name": "Hipchat",
|
||||
"documentation": "https://www.home-assistant.io/integrations/hipchat",
|
||||
"requirements": [
|
||||
"hipnotify==1.0.8"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
"""HipChat platform for notify component."""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_ROOM, CONF_TOKEN
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from homeassistant.components.notify import (
|
||||
ATTR_DATA,
|
||||
ATTR_TARGET,
|
||||
PLATFORM_SCHEMA,
|
||||
BaseNotificationService,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_COLOR = "color"
|
||||
CONF_NOTIFY = "notify"
|
||||
CONF_FORMAT = "format"
|
||||
|
||||
DEFAULT_COLOR = "yellow"
|
||||
DEFAULT_FORMAT = "text"
|
||||
DEFAULT_HOST = "https://api.hipchat.com/"
|
||||
DEFAULT_NOTIFY = False
|
||||
|
||||
VALID_COLORS = {"yellow", "green", "red", "purple", "gray", "random"}
|
||||
VALID_FORMATS = {"text", "html"}
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_ROOM): vol.Coerce(int),
|
||||
vol.Required(CONF_TOKEN): cv.string,
|
||||
vol.Optional(CONF_COLOR, default=DEFAULT_COLOR): vol.In(VALID_COLORS),
|
||||
vol.Optional(CONF_FORMAT, default=DEFAULT_FORMAT): vol.In(VALID_FORMATS),
|
||||
vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string,
|
||||
vol.Optional(CONF_NOTIFY, default=DEFAULT_NOTIFY): cv.boolean,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def get_service(hass, config, discovery_info=None):
|
||||
"""Get the HipChat notification service."""
|
||||
return HipchatNotificationService(
|
||||
config[CONF_TOKEN],
|
||||
config[CONF_ROOM],
|
||||
config[CONF_COLOR],
|
||||
config[CONF_NOTIFY],
|
||||
config[CONF_FORMAT],
|
||||
config[CONF_HOST],
|
||||
)
|
||||
|
||||
|
||||
class HipchatNotificationService(BaseNotificationService):
|
||||
"""Implement the notification service for HipChat."""
|
||||
|
||||
def __init__(
|
||||
self, token, default_room, default_color, default_notify, default_format, host
|
||||
):
|
||||
"""Initialize the service."""
|
||||
self._token = token
|
||||
self._default_room = default_room
|
||||
self._default_color = default_color
|
||||
self._default_notify = default_notify
|
||||
self._default_format = default_format
|
||||
self._host = host
|
||||
|
||||
self._rooms = {}
|
||||
self._get_room(self._default_room)
|
||||
|
||||
def _get_room(self, room):
|
||||
"""Get Room object, creating it if necessary."""
|
||||
from hipnotify import Room
|
||||
|
||||
if room not in self._rooms:
|
||||
self._rooms[room] = Room(
|
||||
token=self._token, room_id=room, endpoint_url=self._host
|
||||
)
|
||||
return self._rooms[room]
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message."""
|
||||
color = self._default_color
|
||||
notify = self._default_notify
|
||||
message_format = self._default_format
|
||||
|
||||
if kwargs.get(ATTR_DATA) is not None:
|
||||
data = kwargs.get(ATTR_DATA)
|
||||
if (data.get(CONF_COLOR) is not None) and (
|
||||
data.get(CONF_COLOR) in VALID_COLORS
|
||||
):
|
||||
color = data.get(CONF_COLOR)
|
||||
if (data.get(CONF_NOTIFY) is not None) and isinstance(
|
||||
data.get(CONF_NOTIFY), bool
|
||||
):
|
||||
notify = data.get(CONF_NOTIFY)
|
||||
if (data.get(CONF_FORMAT) is not None) and (
|
||||
data.get(CONF_FORMAT) in VALID_FORMATS
|
||||
):
|
||||
message_format = data.get(CONF_FORMAT)
|
||||
|
||||
targets = kwargs.get(ATTR_TARGET, [self._default_room])
|
||||
|
||||
for target in targets:
|
||||
room = self._get_room(target)
|
||||
room.notify(
|
||||
msg=message, color=color, notify=notify, message_format=message_format
|
||||
)
|
@ -627,9 +627,6 @@ herepy==0.6.3.1
|
||||
# homeassistant.components.hikvisioncam
|
||||
hikvision==0.4
|
||||
|
||||
# homeassistant.components.hipchat
|
||||
hipnotify==1.0.8
|
||||
|
||||
# homeassistant.components.harman_kardon_avr
|
||||
hkavr==0.0.5
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user