コード例 #1
0
    def __init__(self, name, code, username, password, url):
        """Initialize the iAlarm status."""

        self._name = name
        self._code = str(code) if code else None
        self._username = username
        self._password = password
        self._url = url
        self._state = None
        self._client = IAlarm(username, password, url)
コード例 #2
0
    def __init__(self, name, username, password, url):
        """Initialize the iAlarm status."""
        from pyialarm import IAlarm

        self._name = name
        self._username = username
        self._password = password
        self._url = url
        self._state = None
        self._client = IAlarm(username, password, url)
コード例 #3
0
ファイル: ialarm.py プロジェクト: subutux/home-assistant
    def __init__(self, name, username, password, url):
        """Initialize the iAlarm status."""
        from pyialarm import IAlarm

        self._name = name
        self._username = username
        self._password = password
        self._url = url
        self._state = None
        self._client = IAlarm(username, password, url)
コード例 #4
0
ファイル: ialarm.py プロジェクト: subutux/home-assistant
class IAlarmPanel(alarm.AlarmControlPanel):
    """Representation of an iAlarm status."""

    def __init__(self, name, username, password, url):
        """Initialize the iAlarm status."""
        from pyialarm import IAlarm

        self._name = name
        self._username = username
        self._password = password
        self._url = url
        self._state = None
        self._client = IAlarm(username, password, url)

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Return the state of the device."""
        status = self._client.get_status()
        _LOGGER.debug('iAlarm status: %s', status)
        if status:
            status = int(status)

        if status == self._client.DISARMED:
            state = STATE_ALARM_DISARMED
        elif status == self._client.ARMED_AWAY:
            state = STATE_ALARM_ARMED_AWAY
        elif status == self._client.ARMED_STAY:
            state = STATE_ALARM_ARMED_HOME
        elif status == self._client.TRIGGERED:
            state = STATE_ALARM_TRIGGERED
        else:
            state = None

        self._state = state

    def alarm_disarm(self, code=None):
        """Send disarm command."""
        self._client.disarm()

    def alarm_arm_away(self, code=None):
        """Send arm away command."""
        self._client.arm_away()

    def alarm_arm_home(self, code=None):
        """Send arm home command."""
        self._client.arm_stay()
コード例 #5
0
class IAlarmPanel(alarm.AlarmControlPanel):
    """Representation of an iAlarm status."""
    def __init__(self, name, username, password, url):
        """Initialize the iAlarm status."""
        from pyialarm import IAlarm

        self._name = name
        self._username = username
        self._password = password
        self._url = url
        self._state = None
        self._client = IAlarm(username, password, url)

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Return the state of the device."""
        status = self._client.get_status()
        _LOGGER.debug('iAlarm status: %s', status)
        if status:
            status = int(status)

        if status == self._client.DISARMED:
            state = STATE_ALARM_DISARMED
        elif status == self._client.ARMED_AWAY:
            state = STATE_ALARM_ARMED_AWAY
        elif status == self._client.ARMED_STAY:
            state = STATE_ALARM_ARMED_HOME
        elif status == self._client.TRIGGERED:
            state = STATE_ALARM_TRIGGERED
        else:
            state = None

        self._state = state

    def alarm_disarm(self, code=None):
        """Send disarm command."""
        self._client.disarm()

    def alarm_arm_away(self, code=None):
        """Send arm away command."""
        self._client.arm_away()

    def alarm_arm_home(self, code=None):
        """Send arm home command."""
        self._client.arm_stay()
コード例 #6
0
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
    """Set up iAlarm config."""
    host = entry.data[CONF_HOST]
    port = entry.data[CONF_PORT]
    ialarm = IAlarm(host, port)

    try:
        async with timeout(10):
            mac = await hass.async_add_executor_job(ialarm.get_mac)
    except (asyncio.TimeoutError, ConnectionError) as ex:
        raise ConfigEntryNotReady from ex

    coordinator = IAlarmDataUpdateCoordinator(hass, ialarm, mac)
    await coordinator.async_config_entry_first_refresh()

    hass.data.setdefault(DOMAIN, {})

    hass.data[DOMAIN][entry.entry_id] = {
        DATA_COORDINATOR: coordinator,
    }

    hass.config_entries.async_setup_platforms(entry, PLATFORMS)

    return True
コード例 #7
0
class IAlarmPanel(alarm.AlarmControlPanel):
    """Representation of an iAlarm status."""
    def __init__(self, name, code, username, password, url):
        """Initialize the iAlarm status."""
        from pyialarm import IAlarm

        self._name = name
        self._code = str(code) if code else None
        self._username = username
        self._password = password
        self._url = url
        self._state = None
        self._client = IAlarm(username, password, url)

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def code_format(self):
        """Return one or more digits/characters."""
        if self._code is None:
            return None
        if isinstance(self._code, str) and re.search('^\\d+$', self._code):
            return alarm.FORMAT_NUMBER
        return alarm.FORMAT_TEXT

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Return the state of the device."""
        status = self._client.get_status()
        _LOGGER.debug('iAlarm status: %s', status)
        if status:
            status = int(status)

        if status == self._client.DISARMED:
            state = STATE_ALARM_DISARMED
        elif status == self._client.ARMED_AWAY:
            state = STATE_ALARM_ARMED_AWAY
        elif status == self._client.ARMED_STAY:
            state = STATE_ALARM_ARMED_HOME
        elif status == self._client.TRIGGERED:
            state = STATE_ALARM_TRIGGERED
        else:
            state = None

        self._state = state

    def alarm_disarm(self, code=None):
        """Send disarm command."""
        if self._validate_code(code):
            self._client.disarm()

    def alarm_arm_away(self, code=None):
        """Send arm away command."""
        if self._validate_code(code):
            self._client.arm_away()

    def alarm_arm_home(self, code=None):
        """Send arm home command."""
        if self._validate_code(code):
            self._client.arm_stay()

    def _validate_code(self, code):
        """Validate given code."""
        check = self._code is None or code == self._code
        if not check:
            _LOGGER.warning("Wrong code entered")
        return check
コード例 #8
0
class IAlarmPanel(alarm.AlarmControlPanel):
    """Representation of an iAlarm status."""

    def __init__(self, name, code, username, password, url):
        """Initialize the iAlarm status."""
        from pyialarm import IAlarm

        self._name = name
        self._code = str(code) if code else None
        self._username = username
        self._password = password
        self._url = url
        self._state = None
        self._client = IAlarm(username, password, url)

    @property
    def name(self):
        """Return the name of the device."""
        return self._name

    @property
    def code_format(self):
        """Return one or more digits/characters."""
        if self._code is None:
            return None
        if isinstance(self._code, str) and re.search('^\\d+$', self._code):
            return alarm.FORMAT_NUMBER
        return alarm.FORMAT_TEXT

    @property
    def state(self):
        """Return the state of the device."""
        return self._state

    def update(self):
        """Return the state of the device."""
        status = self._client.get_status()
        _LOGGER.debug('iAlarm status: %s', status)
        if status:
            status = int(status)

        if status == self._client.DISARMED:
            state = STATE_ALARM_DISARMED
        elif status == self._client.ARMED_AWAY:
            state = STATE_ALARM_ARMED_AWAY
        elif status == self._client.ARMED_STAY:
            state = STATE_ALARM_ARMED_HOME
        elif status == self._client.TRIGGERED:
            state = STATE_ALARM_TRIGGERED
        else:
            state = None

        self._state = state

    def alarm_disarm(self, code=None):
        """Send disarm command."""
        if self._validate_code(code):
            self._client.disarm()

    def alarm_arm_away(self, code=None):
        """Send arm away command."""
        if self._validate_code(code):
            self._client.arm_away()

    def alarm_arm_home(self, code=None):
        """Send arm home command."""
        if self._validate_code(code):
            self._client.arm_stay()

    def _validate_code(self, code):
        """Validate given code."""
        check = self._code is None or code == self._code
        if not check:
            _LOGGER.warning("Wrong code entered")
        return check
コード例 #9
0
async def _get_device_mac(hass: core.HomeAssistant, host, port):
    ialarm = IAlarm(host, port)
    return await hass.async_add_executor_job(ialarm.get_mac)