CONF_MIN_DUR,
    CONF_MIN_HUMIDITY,
    CONF_SENSOR,
    CONF_STALE_DURATION,
    CONF_TARGET_HUMIDITY,
    CONF_WET_TOLERANCE,
    HYGROSTAT_SCHEMA,
)

_LOGGER = logging.getLogger(__name__)

ATTR_SAVED_HUMIDITY = "saved_humidity"

SUPPORT_FLAGS = 0

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(HYGROSTAT_SCHEMA.schema)


async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    """Set up the generic hygrostat platform."""
    if discovery_info:
        config = discovery_info
    name = config[CONF_NAME]
    switch_entity_id = config[CONF_HUMIDIFIER]
    sensor_entity_id = config[CONF_SENSOR]
    min_humidity = config.get(CONF_MIN_HUMIDITY)
    max_humidity = config.get(CONF_MAX_HUMIDITY)
    target_humidity = config.get(CONF_TARGET_HUMIDITY)
    device_class = config.get(CONF_DEVICE_CLASS)
    min_cycle_duration = config.get(CONF_MIN_DUR)
    sensor_stale_duration = config.get(CONF_STALE_DURATION)
Example #2
0
    CONF_CONTROL_PARAMS,
    CONF_CLOUD,
    CONF_MODEL,
    ATTR_STATE_VALUE,
    ATTR_MODEL,
    ATTR_FIRMWARE_VERSION,
    ATTR_HARDWARE_VERSION,
    SCHEMA,
)

_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = "Generic MIoT humidifier"
DATA_KEY = "humidifier." + DOMAIN

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(SCHEMA)

SCAN_INTERVAL = timedelta(seconds=2)
# pylint: disable=unused-argument


@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up the sensor from config."""

    if DATA_KEY not in hass.data:
        hass.data[DATA_KEY] = {}

    host = config.get(CONF_HOST)
    token = config.get(CONF_TOKEN)
    mapping = config.get(CONF_MAPPING)
DEFAULT_TYPE = DEHUMIDIFIER_TYPE
DEFAULT_HUMIDITY = 50
DEFAULT_START_DELTA = 0.1
DEFAULT_STOP_DELTA = 0.1
DEFAULT_SWITCH_STATE = STATE_OFF
MIN_HUMIDITY = 0
MAX_HUMIDITY = 100

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Optional(CONF_NAME, default=DEFAULT_NAME):
    cv.string,
    vol.Required(CONF_SENSOR_ID):
    cv.string,
    vol.Required(CONF_SWITCH_ID):
    cv.string,
    vol.Optional(CONF_TYPE, default=DEFAULT_TYPE):
    vol.All(cv.string, vol.In(TYPES)),
    vol.Optional(CONF_START_DELTA, default=DEFAULT_START_DELTA):
    vol.Coerce(float),
    vol.Optional(CONF_STOP_DELTA, default=DEFAULT_STOP_DELTA):
    vol.Coerce(float),
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the dehumidifier platform."""
    name = config[CONF_NAME]
    sensor_id = config[CONF_SENSOR_ID]
    switch_id = config[CONF_SWITCH_ID]
    device_class = DEVICE_CLASS_DEHUMIDIFIER
    if config[CONF_TYPE] == HUMIDIFIER_TYPE: