Example #1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the VeSync switch platform."""
    from pyvesync.vesync import VeSync

    switches = []

    manager = VeSync(config.get(CONF_USERNAME), config.get(CONF_PASSWORD))

    if not manager.login():
        _LOGGER.error("Unable to login to VeSync")
        return

    manager.update()

    if manager.devices is not None and manager.devices:
        if len(manager.devices) == 1:
            count_string = 'switch'
        else:
            count_string = 'switches'

        _LOGGER.info("Discovered %d VeSync %s",
                     len(manager.devices), count_string)

        for switch in manager.devices:
            switches.append(VeSyncSwitchHA(switch))
            _LOGGER.info("Added a VeSync switch named '%s'",
                         switch.device_name)
    else:
        _LOGGER.info("No VeSync devices found")

    add_devices(switches)
Example #2
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the VeSync switch platform."""
    from pyvesync.vesync import VeSync

    switches = []

    manager = VeSync(config.get(CONF_USERNAME), config.get(CONF_PASSWORD))

    if not manager.login():
        _LOGGER.error("Unable to login to VeSync")
        return

    manager.update()

    if manager.devices is not None and manager.devices:
        if len(manager.devices) == 1:
            count_string = 'switch'
        else:
            count_string = 'switches'

        _LOGGER.info("Discovered %d VeSync %s",
                     len(manager.devices), count_string)

        for switch in manager.devices:
            switches.append(VeSyncSwitchHA(switch))
            _LOGGER.info("Added a VeSync switch named '%s'",
                         switch.device_name)
    else:
        _LOGGER.info("No VeSync devices found")

    add_entities(switches)
Example #3
0
def setup(hass, config):
    """Set up the VeSync component."""
    from pyvesync.vesync import VeSync

    conf = config[DOMAIN]

    manager = VeSync(conf.get(CONF_USERNAME), conf.get(CONF_PASSWORD),
                     time_zone=conf.get(CONF_TIME_ZONE))

    if not manager.login():
        _LOGGER.error("Unable to login to VeSync")
        return

    manager.update()

    hass.data[DOMAIN] = {
        'manager': manager
    }

    discovery.load_platform(hass, 'switch', DOMAIN, {}, config)

    return True
class EtekcityAdapter(Adapter):
    """Adapter for Etekcity smart home devices."""
    def __init__(self, verbose=False):
        """
        Initialize the object.

        verbose -- whether or not to enable verbose logging
        """
        self.name = self.__class__.__name__
        Adapter.__init__(self,
                         'etekcity-adapter',
                         'etekcity-adapter',
                         verbose=verbose)

        self.manager = None

        database = Database(self.package_name)
        if database.open():
            config = database.load_config()

            if 'username' in config and len(config['username']) > 0 and \
                    'password' in config and len(config['password']) > 0:
                self.manager = VeSync(config['username'], config['password'])
                self.manager.login()

            database.close()

        self.pairing = False
        self.start_pairing(_TIMEOUT)

    def start_pairing(self, timeout):
        """
        Start the pairing process.

        timeout -- Timeout in seconds at which to quit pairing
        """
        if self.manager is None or self.pairing:
            return

        self.pairing = True

        self.manager.update()

        for dev in self.manager.bulbs:
            _id = 'etekcity-' + dev.uuid
            if _id not in self.devices:
                device = EtekcityBulb(self, _id, dev)
                self.handle_device_added(device)

        for dev in self.manager.outlets:
            _id = 'etekcity-' + dev.uuid
            if _id not in self.devices:
                device = EtekcityOutlet(self, _id, dev)
                self.handle_device_added(device)

        for dev in self.manager.switches:
            _id = 'etekcity-' + dev.uuid
            if _id not in self.devices:
                device = EtekcitySwitch(self, _id, dev)
                self.handle_device_added(device)

        self.pairing = False

    def cancel_pairing(self):
        """Cancel the pairing process."""
        self.pairing = False
Example #5
0
"""Etekcity VeSync integration.""" 
import logging import voluptuous as vol from homeassistant.const import (CONF_USERNAME, CONF_PASSWORD, CONF_TIME_ZONE) from homeassistant.helpers import config_validation as cv from homeassistant.helpers import discovery _LOGGER = logging.getLogger(__name__) DOMAIN = 'vesync' CONFIG_SCHEMA = vol.Schema({ DOMAIN: vol.Schema({ vol.Required(CONF_USERNAME): cv.string, vol.Required(CONF_PASSWORD): cv.string, vol.Optional(CONF_TIME_ZONE): cv.string, }), }, extra=vol.ALLOW_EXTRA) def setup(hass, config): """Set up the VeSync component.""" from pyvesync.vesync import VeSync conf = config[DOMAIN] manager = VeSync(conf.get(CONF_USERNAME), conf.get(CONF_PASSWORD), time_zone=conf.get(CONF_TIME_ZONE)) if not manager.login(): _LOGGER.error("Unable to login to VeSync") return manager.update() hass.data[DOMAIN] = { 'manager': manager } discovery.load_platform(hass, 'switch', DOMAIN, {}, config) return True
Example #6
0
from pyvesync.vesync import VeSync

a = VeSync('*****@*****.**', 'Microsoft1!1')

a.login()

a.update()
Example #7
0
#!/usr/bin/python
from pyvesync.vesync import VeSync
import json

Outlets = []

manager = VeSync("USER_EMAIL", "PASSWORD")
manager.login()
manager.update()

# Get electricity metrics of devices
#print manager.devices[0].device_name
for switch in manager.devices:
    #print("Switch %s is currently using %s watts" % (switch.device_name, switch.get_power()))
    #print("It has used %skWh of electricity today" % (switch.get_kwh_today()))
    #print(switch.device_status)
    #print(switch.device_type)
    #device = Outlet()
    #device.DeviceName = switch.device_name
    #Outlets.append(device)
    x = {
        "name": "VeSync",
        "DeviceName": switch.device_name,
        "State": switch.device_status,
        "CurrentPower": switch.get_power(),
        "Type": switch.device_type,
        "TodayPower": switch.get_kwh_today(),
        "ConnectionStatus": switch.connection_status,
        "DeviceStatus": switch.device_status
    }
    Outlets.append(x)