Пример #1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Verisure platform."""
    alarms = []
    if int(hub.config.get("alarm", "1")):
        hub.update_alarms()
        alarms.extend([VerisureAlarm(value.id) for value in hub.alarm_status.values()])
    add_devices(alarms)
Пример #2
0
    def check_imagelist(self):
        """Check the contents of the image list."""
        hub.update_smartcam_imagelist()
        if (self._device_id not in hub.smartcam_dict or
                not hub.smartcam_dict[self._device_id]):
            return
        images = hub.smartcam_dict[self._device_id]
        new_image_id = images[0]
        _LOGGER.debug('self._device_id=%s, self._images=%s, '
                      'self._new_image_id=%s', self._device_id,
                      images, new_image_id)
        if (new_image_id == '-1' or
                self._image_id == new_image_id):
            _LOGGER.debug('The image is the same, or loading image_id')
            return
        _LOGGER.debug('Download new image %s', new_image_id)
        hub.my_pages.smartcam.download_image(self._device_id,
                                             new_image_id,
                                             self._directory_path)
        _LOGGER.debug('Old image_id=%s', self._image_id)
        self.delete_image(self)

        self._image_id = new_image_id
        self._image = os.path.join(self._directory_path,
                                   '{}{}'.format(
                                       self._image_id,
                                       '.jpg'))
Пример #3
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Verisure platform."""
    locks = []
    if int(hub.config.get("locks", "1")):
        hub.update_locks()
        locks.extend([VerisureDoorlock(device_id) for device_id in hub.lock_status.keys()])
    add_devices(locks)
Пример #4
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the Verisure platform."""
    alarms = []
    if int(hub.config.get(CONF_ALARM, 1)):
        hub.update_overview()
        alarms.append(VerisureAlarm())
    add_devices(alarms)
Пример #5
0
    def update(self):
        """Update lock status."""
        hub.update_locks()

        if hub.lock_status[self._id].status == "unlocked":
            self._state = STATE_UNLOCKED
        elif hub.lock_status[self._id].status == "locked":
            self._state = STATE_LOCKED
        elif hub.lock_status[self._id].status != "pending":
            _LOGGER.error("Unknown lock state %s", hub.lock_status[self._id].status)
Пример #6
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Verisure switch platform."""
    if not int(hub.config.get('smartplugs', '1')):
        return False

    hub.update_smartplugs()
    switches = []
    switches.extend([
        VerisureSmartplug(value.deviceLabel)
        for value in hub.smartplug_status.values()])
    add_devices(switches)
Пример #7
0
def set_arm_state(state, code=None):
    """Send set arm state command."""
    transaction_id = hub.session.set_arm_state(code, state)[
        'armStateChangeTransactionId']
    _LOGGER.info('verisure set arm state %s', state)
    transaction = {}
    while 'result' not in transaction:
        sleep(0.5)
        transaction = hub.session.get_arm_state_transaction(transaction_id)
    # pylint: disable=unexpected-keyword-arg
    hub.update_overview(no_throttle=True)
Пример #8
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Verisure lock platform."""
    locks = []
    if int(hub.config.get(CONF_LOCKS, 1)):
        hub.update_overview()
        locks.extend([
            VerisureDoorlock(device_label)
            for device_label in hub.get(
                "$.doorLockStatusList[*].deviceLabel")])

    add_entities(locks)
Пример #9
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Verisure switch platform."""
    if not int(hub.config.get(CONF_SMARTPLUGS, 1)):
        return False

    hub.update_overview()
    switches = []
    switches.extend([
        VerisureSmartplug(device_label)
        for device_label in hub.get('$.smartPlugs[*].deviceLabel')])
    add_entities(switches)
Пример #10
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Verisure binary sensors."""
    sensors = []
    hub.update_overview()

    if int(hub.config.get(CONF_DOOR_WINDOW, 1)):
        sensors.extend([
            VerisureDoorWindowSensor(device_label)
            for device_label in hub.get(
                "$.doorWindow.doorWindowDevice[*].deviceLabel")])
    add_entities(sensors)
Пример #11
0
    def update(self):
        """ Update lock status """
        hub.update_locks()

        if hub.lock_status[self._id].status == 'unlocked':
            self._state = STATE_UNLOCKED
        elif hub.lock_status[self._id].status == 'locked':
            self._state = STATE_LOCKED
        elif hub.lock_status[self._id].status != 'pending':
            _LOGGER.error(
                'Unknown lock state %s',
                hub.lock_status[self._id].status)
Пример #12
0
    def update(self):
        """Update lock status."""
        hub.update_locks()

        if hub.lock_status[self._id].status == 'unlocked':
            self._state = STATE_UNLOCKED
        elif hub.lock_status[self._id].status == 'locked':
            self._state = STATE_LOCKED
        elif hub.lock_status[self._id].status != 'pending':
            _LOGGER.error(
                "Unknown lock state %s", hub.lock_status[self._id].status)
        self._changed_by = hub.lock_status[self._id].name
Пример #13
0
 def update(self):
     """Update alarm status."""
     hub.update_overview()
     status = hub.get_first("$.armState.statusType")
     if status == 'DISARMED':
         self._state = STATE_ALARM_DISARMED
     elif status == 'ARMED_HOME':
         self._state = STATE_ALARM_ARMED_HOME
     elif status == 'ARMED_AWAY':
         self._state = STATE_ALARM_ARMED_AWAY
     elif status != 'PENDING':
         _LOGGER.error('Unknown alarm state %s', status)
     self._changed_by = hub.get_first("$.armState.name")
Пример #14
0
    def update(self):
        """Update alarm status."""
        hub.update_alarms()

        if hub.alarm_status[self._id].status == "unarmed":
            self._state = STATE_ALARM_DISARMED
        elif hub.alarm_status[self._id].status == "armedhome":
            self._state = STATE_ALARM_ARMED_HOME
        elif hub.alarm_status[self._id].status == "armed":
            self._state = STATE_ALARM_ARMED_AWAY
        elif hub.alarm_status[self._id].status != "pending":
            _LOGGER.error("Unknown alarm state %s", hub.alarm_status[self._id].status)
        self._changed_by = hub.alarm_status[self._id].name
Пример #15
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Camera."""
    if not int(hub.config.get(CONF_SMARTCAM, 1)):
        return False
    directory_path = hass.config.config_dir
    if not os.access(directory_path, os.R_OK):
        _LOGGER.error("file path %s is not readable", directory_path)
        return False
    hub.update_smartcam()
    smartcams = []
    smartcams.extend([
        VerisureSmartcam(hass, value.deviceLabel, directory_path)
        for value in hub.smartcam_status.values()])
    add_devices(smartcams)
Пример #16
0
    def update(self):
        """ Update alarm status """
        hub.update_alarms()

        if hub.alarm_status[self._id].status == 'unarmed':
            self._state = STATE_ALARM_DISARMED
        elif hub.alarm_status[self._id].status == 'armedhome':
            self._state = STATE_ALARM_ARMED_HOME
        elif hub.alarm_status[self._id].status == 'armed':
            self._state = STATE_ALARM_ARMED_AWAY
        elif hub.alarm_status[self._id].status != 'pending':
            _LOGGER.error(
                'Unknown alarm state %s',
                hub.alarm_status[self._id].status)
Пример #17
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Verisure Camera."""
    if not int(hub.config.get(CONF_SMARTCAM, 1)):
        return False
    directory_path = hass.config.config_dir
    if not os.access(directory_path, os.R_OK):
        _LOGGER.error("file path %s is not readable", directory_path)
        return False
    hub.update_overview()
    smartcams = []
    smartcams.extend([
        VerisureSmartcam(hass, device_label, directory_path)
        for device_label in hub.get(
            "$.customerImageCameras[*].deviceLabel")])
    add_entities(smartcams)
Пример #18
0
 def update(self):
     """Update lock status."""
     if time() - self._change_timestamp < 10:
         return
     hub.update_overview()
     status = hub.get_first(
         "$.doorLockStatusList[?(@.deviceLabel=='%s')].lockedState",
         self._device_label)
     if status == 'UNLOCKED':
         self._state = STATE_UNLOCKED
     elif status == 'LOCKED':
         self._state = STATE_LOCKED
     elif status != 'PENDING':
         _LOGGER.error('Unknown lock state %s', status)
     self._changed_by = hub.get_first(
         "$.doorLockStatusList[?(@.deviceLabel=='%s')].userString",
         self._device_label)
Пример #19
0
 def is_on(self):
     """Return true if on."""
     if time() - self._change_timestamp < 10:
         return self._state
     self._state = hub.get_first(
         "$.smartPlugs[?(@.deviceLabel == '%s')].currentState",
         self._device_label) == "ON"
     return self._state
Пример #20
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the Verisure platform."""
    sensors = []

    if int(hub.config.get('thermometers', '1')):
        hub.update_climate()
        sensors.extend([
            VerisureThermometer(value.id)
            for value in hub.climate_status.values()
            if hasattr(value, 'temperature') and value.temperature
            ])

    if int(hub.config.get('hygrometers', '1')):
        hub.update_climate()
        sensors.extend([
            VerisureHygrometer(value.id)
            for value in hub.climate_status.values()
            if hasattr(value, 'humidity') and value.humidity
            ])

    if int(hub.config.get('mouse', '1')):
        hub.update_mousedetection()
        sensors.extend([
            VerisureMouseDetection(value.deviceLabel)
            for value in hub.mouse_status.values()
            # is this if needed?
            if hasattr(value, 'amountText') and value.amountText
            ])

    add_devices(sensors)
Пример #21
0
    def check_imagelist(self):
        """Check the contents of the image list."""
        hub.update_smartcam_imageseries()
        image_ids = hub.get_image_info(
            "$.imageSeries[?(@.deviceLabel=='%s')].image[0].imageId",
            self._device_label)
        if not image_ids:
            return
        new_image_id = image_ids[0]
        if new_image_id in ('-1', self._image_id):
            _LOGGER.debug("The image is the same, or loading image_id")
            return
        _LOGGER.debug("Download new image %s", new_image_id)
        new_image_path = os.path.join(
            self._directory_path, '{}{}'.format(new_image_id, '.jpg'))
        hub.session.download_image(
            self._device_label, new_image_id, new_image_path)
        _LOGGER.debug("Old image_id=%s", self._image_id)
        self.delete_image(self)

        self._image_id = new_image_id
        self._image = new_image_path
Пример #22
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Verisure platform."""
    sensors = []
    hub.update_overview()

    if int(hub.config.get(CONF_THERMOMETERS, 1)):
        sensors.extend([
            VerisureThermometer(device_label)
            for device_label in hub.get(
                '$.climateValues[?(@.temperature)].deviceLabel')])

    if int(hub.config.get(CONF_HYDROMETERS, 1)):
        sensors.extend([
            VerisureHygrometer(device_label)
            for device_label in hub.get(
                '$.climateValues[?(@.humidity)].deviceLabel')])

    if int(hub.config.get(CONF_MOUSE, 1)):
        sensors.extend([
            VerisureMouseDetection(device_label)
            for device_label in hub.get(
                "$.eventCounts[?(@.deviceType=='MOUSE1')].deviceLabel")])

    add_entities(sensors)
Пример #23
0
 def update(self):
     """Update the sensor."""
     hub.update_climate()
Пример #24
0
 def update(self):
     """Get the latest date of the smartplug."""
     hub.update_overview()
Пример #25
0
 def available(self):
     """Return True if entity is available."""
     return hub.get_first("$.doorLockStatusList[?(@.deviceLabel=='%s')]",
                          self._device_label) is not None
Пример #26
0
 def available(self):
     """Return True if entity is available."""
     return hub.get_first(
         "$.doorWindow.doorWindowDevice[?(@.deviceLabel=='%s')]",
         self._device_label) is not None
Пример #27
0
 def update(self):
     """Get the latest date of the smartplug."""
     hub.update_overview()
Пример #28
0
 def state(self):
     """Return the state of the device."""
     return hub.get_first(
         "$.climateValues[?(@.deviceLabel=='%s')].humidity",
         self._device_label)
Пример #29
0
 def name(self):
     """Return the name of the device."""
     return hub.get_first(
         "$.climateValues[?(@.deviceLabel=='%s')].deviceArea",
         self._device_label) + " humidity"
Пример #30
0
 def name(self):
     """Return the name of the lock."""
     return hub.get_first(
         "$.doorLockStatusList[?(@.deviceLabel=='%s')].area",
         self._device_label)
Пример #31
0
 def name(self):
     """Return the name of the device."""
     return hub.get_first("$.eventCounts[?(@.deviceLabel=='%s')].area",
                          self._device_label) + " mouse"
Пример #32
0
 def state(self):
     """Return the state of the device."""
     return hub.get_first(
         "$.eventCounts[?(@.deviceLabel=='%s')].detections",
         self._device_label)
Пример #33
0
 def name(self):
     """Return the name of the binary sensor."""
     return hub.get_first(
         "$.doorWindow.doorWindowDevice[?(@.deviceLabel=='%s')].area",
         self._device_label)
Пример #34
0
 def is_on(self):
     """Return the state of the sensor."""
     return hub.get_first(
         "$.doorWindow.doorWindowDevice[?(@.deviceLabel=='%s')].state",
         self._device_label) == "OPEN"
Пример #35
0
 def name(self):
     """Return the name of this camera."""
     return hub.get_first(
         "$.customerImageCameras[?(@.deviceLabel=='%s')].area",
         self._device_label)
Пример #36
0
 def update(self):
     """Update the state of the sensor."""
     hub.update_overview()
Пример #37
0
 def name(self):
     """Return the name of the device."""
     return hub.get_first(
         "$.climateValues[?(@.deviceLabel=='%s')].deviceArea",
         self._device_label) + " humidity"
Пример #38
0
 def name(self):
     """Return the name or location of the smartplug."""
     return hub.get_first(
         "$.smartPlugs[?(@.deviceLabel == '%s')].area",
         self._device_label)
Пример #39
0
 def state(self):
     """Return the state of the device."""
     return hub.get_first(
         "$.climateValues[?(@.deviceLabel=='%s')].humidity",
         self._device_label)
Пример #40
0
 def available(self):
     """Return True if entity is available."""
     return hub.get_first(
         "$.smartPlugs[?(@.deviceLabel == '%s')]",
         self._device_label) is not None
Пример #41
0
 def update(self):
     """Get the latest date of the smartplug."""
     hub.update_smartplugs()
Пример #42
0
 def update(self):
     """Update the sensor."""
     hub.update_mousedetection()
Пример #43
0
 def available(self):
     """Return True if entity is available."""
     return hub.get_first(
         "$.climateValues[?(@.deviceLabel=='%s')].temperature",
         self._device_label) is not None
Пример #44
0
 def update(self):
     """Update the sensor."""
     hub.update_overview()
Пример #45
0
 def update(self):
     hub.update_smartplugs()