Clean-up, ordering, constants, and extend of schema (#2903)
* Clean-up, ordering, constants, and extend of schema * Put REQUIREMENTS back and re-add line breaks * Clean-up, ordering, constants, and extend of schema * Extend platform
This commit is contained in:
1 parent
8fc27cbe43
commit
e8c6e4d561
28 files changed
+232
-228
No files matched your search
@@ -5,27 +5,25 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.imap/
|
||||
"""
|
||||
import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
CONF_NAME, CONF_PORT, CONF_USERNAME, CONF_PASSWORD)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ICON = 'mdi:email-outline'
|
||||
|
||||
CONF_USER = "user"
|
||||
CONF_PASSWORD = "password"
|
||||
CONF_SERVER = "server"
|
||||
CONF_PORT = "port"
|
||||
CONF_NAME = "name"
|
||||
|
||||
DEFAULT_PORT = 993
|
||||
ICON = 'mdi:email-outline'
|
||||
|
||||
PLATFORM_SCHEMA = vol.Schema({
|
||||
vol.Required('platform'): 'imap',
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
vol.Required(CONF_USER): cv.string,
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Required(CONF_SERVER): cv.string,
|
||||
vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port,
|
||||
@@ -35,10 +33,10 @@ PLATFORM_SCHEMA = vol.Schema({
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the IMAP platform."""
|
||||
sensor = ImapSensor(config.get(CONF_NAME, None),
|
||||
config.get(CONF_USER),
|
||||
config.get(CONF_USERNAME),
|
||||
config.get(CONF_PASSWORD),
|
||||
config.get(CONF_SERVER),
|
||||
config.get(CONF_PORT, DEFAULT_PORT))
|
||||
config.get(CONF_PORT))
|
||||
|
||||
if sensor.connection:
|
||||
add_devices([sensor])
|
||||
|
||||
Reference in new issue
Block a user