Add Gammu based local SMS notifications (#31233)
* Add sms integration Committer: ocalvo <oscar@calvonet.com> * Fix PyLint * Update requirements
This commit is contained in:
1 parent
ec2d378a19
commit
d813618d0d
8 files changed
+97
No files matched your search
@@ -0,0 +1,33 @@
|
||||
"""The sms component."""
|
||||
import logging
|
||||
|
||||
import gammu # pylint: disable=import-error, no-member
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_DEVICE
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{DOMAIN: vol.Schema({vol.Required(CONF_DEVICE): cv.isdevice})},
|
||||
extra=vol.ALLOW_EXTRA,
|
||||
)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Configure Gammu state machine."""
|
||||
conf = config[DOMAIN]
|
||||
device = conf.get(CONF_DEVICE)
|
||||
gateway = gammu.StateMachine() # pylint: disable=no-member
|
||||
try:
|
||||
gateway.SetConfig(0, dict(Device=device, Connection="at"))
|
||||
gateway.Init()
|
||||
except gammu.GSMError as exc: # pylint: disable=no-member
|
||||
_LOGGER.error("Failed to initialize, error %s", exc)
|
||||
return False
|
||||
else:
|
||||
hass.data[DOMAIN] = gateway
|
||||
return True
|
||||
Reference in new issue
Block a user