示例#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()