ECONET_DATA = "econet"

ECONET_STATE_TO_HA = {
    "Energy Saver": STATE_ECO,
    "gas": STATE_GAS,
    "High Demand": STATE_HIGH_DEMAND,
    "Off": STATE_OFF,
    "Performance": STATE_PERFORMANCE,
    "Heat Pump Only": STATE_HEAT_PUMP,
    "Electric-Only": STATE_ELECTRIC,
    "Electric": STATE_ELECTRIC,
    "Heat Pump": STATE_HEAT_PUMP,
}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the EcoNet water heaters."""

    hass.data[ECONET_DATA] = {}
    hass.data[ECONET_DATA]["water_heaters"] = []

    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)

    econet = PyEcoNet(username, password)
    water_heaters = econet.get_water_heaters()
    hass_water_heaters = [
示例#2
0
    ATTR_MODEL,
    ATTR_FIRMWARE_VERSION,
    ATTR_HARDWARE_VERSION,
    SCHEMA,
    MAP,
    DUMMY_IP,
    DUMMY_TOKEN,
)

TYPE = 'water_heater'
_LOGGER = logging.getLogger(__name__)

DEFAULT_NAME = "Generic MIoT " + TYPE
DATA_KEY = TYPE + '.' + DOMAIN

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(SCHEMA)

SCAN_INTERVAL = timedelta(seconds=10)


# pylint: disable=unused-argument
@asyncio.coroutine
async def async_setup_platform(hass,
                               config,
                               async_add_devices,
                               discovery_info=None):
    await async_generic_setup_platform(
        hass,
        config,
        async_add_devices,
        discovery_info,
STATE_ATTRS_YUNMI = [
    "washStatus", "velocity", "waterTemp", "targetTemp", "errStatus",
    "hotWater", "needClean", "modeType", "appointStart", "appointEnd"
]

TOKEN_PATH = 'yunmi_water_heater.txt'
TOKEN_PATH = os.path.split(
    os.path.split(os.path.split(
        os.path.realpath(__file__))[0])[0])[0] + '/' + TOKEN_PATH

SUPPORT_FLAGS_HEATER = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_PHONE_NUMBER):
    cv.string,
    vol.Required(CONF_PASSWORD):
    cv.string,
    vol.Required(CONF_CLIENT_ID):
    cv.string
})


async def async_setup(hass, config):
    """Set up water_heater devices."""
    component = hass.data[DOMAIN] = EntityComponent(_LOGGER, DOMAIN, hass,
                                                    SCAN_INTERVAL)
    await component.async_setup(config)

    component.async_register_entity_service(SERVICE_SET_AWAY_MODE,
                                            SET_AWAY_MODE_SCHEMA,
                                            async_service_away_mode)
    component.async_register_entity_service(SERVICE_SET_TEMPERATURE,
REQUIREMENTS = ['pexpect']

CONF_MAC = 'mac'
CONF_KEY = 'key'
CONF_DEV = 'device'

OPERATION_LIST = [STATE_OFF, STATE_ELECTRIC]
SUPPORT_FLAGS_HEATER = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE)

ATTR_TIME_UPD = 'sync_time'

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_MAC): cv.string,
    vol.Required(CONF_KEY): cv.string,
    vol.Required(CONF_DEV): cv.string,
})

async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
    mac = config.get(CONF_MAC)
    key = config.get(CONF_KEY)
    device = config.get(CONF_DEV)

    if len(key) != 16:
        _LOGGER.error("key value is empty or wrong")
        return False

    mac_validation = bool(re.match('^' + '[\:\-]'.join(['([0-9a-f]{2})']*6) + '$', mac.lower()))
    if not mac_validation:
        _LOGGER.error("mac value is empty or wrong")
示例#5
0
ECONET_DATA = 'econet'

HA_STATE_TO_ECONET = {
    STATE_ECO: 'Energy Saver',
    STATE_ELECTRIC: 'Electric',
    STATE_HEAT_PUMP: 'Heat Pump',
    STATE_GAS: 'gas',
    STATE_HIGH_DEMAND: 'High Demand',
    STATE_OFF: 'Off',
    STATE_PERFORMANCE: 'Performance'
}

ECONET_STATE_TO_HA = {value: key for key, value in HA_STATE_TO_ECONET.items()}

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
    vol.Required(CONF_USERNAME): cv.string,
    vol.Required(CONF_PASSWORD): cv.string,
})


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the EcoNet water heaters."""
    from pyeconet.api import PyEcoNet

    hass.data[ECONET_DATA] = {}
    hass.data[ECONET_DATA]['water_heaters'] = []

    username = config.get(CONF_USERNAME)
    password = config.get(CONF_PASSWORD)

    econet = PyEcoNet(username, password)
    water_heaters = econet.get_water_heaters()
 async def discovery_update(self, discovery_payload):
     """Handle updated discovery message."""
     config = PLATFORM_SCHEMA(discovery_payload)
     self._config = config
     await self._subscribe_topics()
     self.async_write_ha_state()