mirror of
https://github.com/home-assistant/core.git
synced 2025-04-28 11:17:53 +00:00
added Yesss SMS platform (#10177)
* added Yesss SMS component requires YesssSMS==0.1.1b * requirements_all * coveragerc * fix * docstring fix * added Exception handling * requirements_all * fixing lint error, version bump for YesssSMS
This commit is contained in:
parent
df19172e56
commit
dd7d8d56bb
@ -450,6 +450,7 @@ omit =
|
|||||||
homeassistant/components/notify/telstra.py
|
homeassistant/components/notify/telstra.py
|
||||||
homeassistant/components/notify/twitter.py
|
homeassistant/components/notify/twitter.py
|
||||||
homeassistant/components/notify/xmpp.py
|
homeassistant/components/notify/xmpp.py
|
||||||
|
homeassistant/components/notify/yessssms.py
|
||||||
homeassistant/components/nuimo_controller.py
|
homeassistant/components/nuimo_controller.py
|
||||||
homeassistant/components/prometheus.py
|
homeassistant/components/prometheus.py
|
||||||
homeassistant/components/remote/harmony.py
|
homeassistant/components/remote/harmony.py
|
||||||
|
51
homeassistant/components/notify/yessssms.py
Normal file
51
homeassistant/components/notify/yessssms.py
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
"""
|
||||||
|
Support for the YesssSMS platform.
|
||||||
|
|
||||||
|
For more details about this platform, please refer to the documentation at
|
||||||
|
https://home-assistant.io/components/notify.yessssms/
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components.notify import (
|
||||||
|
PLATFORM_SCHEMA, BaseNotificationService)
|
||||||
|
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, CONF_RECIPIENT
|
||||||
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
|
REQUIREMENTS = ['YesssSMS==0.1.1b3']
|
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
vol.Required(CONF_USERNAME): cv.string,
|
||||||
|
vol.Required(CONF_PASSWORD): cv.string,
|
||||||
|
vol.Required(CONF_RECIPIENT): cv.string,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def get_service(hass, config, discovery_info=None):
|
||||||
|
"""Get the YesssSMS notification service."""
|
||||||
|
return YesssSMSNotificationService(
|
||||||
|
config[CONF_USERNAME], config[CONF_PASSWORD], config[CONF_RECIPIENT])
|
||||||
|
|
||||||
|
|
||||||
|
class YesssSMSNotificationService(BaseNotificationService):
|
||||||
|
"""Implement a notification service for the YesssSMS service."""
|
||||||
|
|
||||||
|
def __init__(self, username, password, recipient):
|
||||||
|
"""Initialize the service."""
|
||||||
|
from YesssSMS import YesssSMS
|
||||||
|
self.yesss = YesssSMS(username, password)
|
||||||
|
self._recipient = recipient
|
||||||
|
|
||||||
|
def send_message(self, message="", **kwargs):
|
||||||
|
"""Send a SMS message via Yesss.at's website."""
|
||||||
|
try:
|
||||||
|
self.yesss.send(self._recipient, message)
|
||||||
|
except ValueError as ex:
|
||||||
|
if str(ex).startswith("YesssSMS:"):
|
||||||
|
_LOGGER.error(str(ex))
|
||||||
|
except RuntimeError as ex:
|
||||||
|
if str(ex).startswith("YesssSMS:"):
|
||||||
|
_LOGGER.error(str(ex))
|
@ -51,6 +51,9 @@ TravisPy==0.3.5
|
|||||||
# homeassistant.components.notify.twitter
|
# homeassistant.components.notify.twitter
|
||||||
TwitterAPI==2.4.6
|
TwitterAPI==2.4.6
|
||||||
|
|
||||||
|
# homeassistant.components.notify.yessssms
|
||||||
|
YesssSMS==0.1.1b3
|
||||||
|
|
||||||
# homeassistant.components.abode
|
# homeassistant.components.abode
|
||||||
abodepy==0.12.1
|
abodepy==0.12.1
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user