Exemplo n.º 1
0
    def __init__(self, name, resource):
        """Initialize the myStrom switch."""
        from pymystrom.switch import MyStromPlug

        self._name = name
        self._resource = resource
        self.data = {}
        self.plug = MyStromPlug(self._resource)
        self._available = True
Exemplo n.º 2
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Find and return myStrom switch."""
    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)

    try:
        MyStromPlug(host).get_status()
    except MyStromConnectionError:
        _LOGGER.error("No route to device: %s", host)
        raise PlatformNotReady()

    add_entities([MyStromSwitch(name, host)])
Exemplo n.º 3
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Find and return myStrom switch."""
    from pymystrom.switch import MyStromPlug, exceptions

    name = config.get(CONF_NAME)
    host = config.get(CONF_HOST)

    try:
        MyStromPlug(host).get_status()
    except exceptions.MyStromConnectionError:
        _LOGGER.error("No route to device: %s", host)
        return

    add_entities([MyStromSwitch(name, host)])