# Path: config/hass/custom_components/aarlo/pyaarlo/constant.py
# BATTERY_KEY = 'batteryLevel'
# 
# BATTERY_TECH_KEY = 'batteryTech'
# 
# CHARGING_KEY = 'chargingState'
# 
# CHARGER_KEY = 'chargerTech'
# 
# CONNECTION_KEY = 'connectionState'
# 
# RESOURCE_KEYS = [ACTIVITY_STATE_KEY, AIR_QUALITY_KEY, AUDIO_DETECTED_KEY, BATTERY_KEY, BATTERY_TECH_KEY,
#                  BRIGHTNESS_KEY, CONNECTION_KEY, CHARGER_KEY, CHARGING_KEY, FLIP_KEY, HUMIDITY_KEY, LAMP_STATE_KEY,
#                  MIRROR_KEY, MOTION_DETECTED_KEY, MOTION_ENABLED_KEY,
#                  MOTION_SENS_KEY, POWER_SAVE_KEY, PRIVACY_KEY,
#                  SIGNAL_STR_KEY, SIREN_STATE_KEY, TEMPERATURE_KEY,
#                  AUDIO_CONFIG_KEY, AUDIO_PLAYLIST_KEY, AUDIO_STATUS_KEY, AUDIO_SPEAKER_KEY, AUDIO_TRACK_KEY, AUDIO_POSITION_KEY]
# 
# RESOURCE_UPDATE_KEYS = [ACTIVITY_STATE_KEY, AIR_QUALITY_KEY, AUDIO_DETECTED_KEY, BATTERY_KEY, BATTERY_TECH_KEY,
#                         CHARGER_KEY, CHARGING_KEY, CONNECTION_KEY, LAMP_STATE_KEY,
#                         HUMIDITY_KEY, MOTION_DETECTED_KEY, PRIVACY_KEY,
#                         SIGNAL_STR_KEY, SIREN_STATE_KEY, TEMPERATURE_KEY,
#                         AUDIO_CONFIG_KEY, AUDIO_PLAYLIST_KEY, AUDIO_STATUS_KEY, AUDIO_SPEAKER_KEY, AUDIO_TRACK_KEY, AUDIO_POSITION_KEY]
# 
# SIGNAL_STR_KEY = 'signalStrength'
# 
# XCLOUD_ID_KEY = 'xCloudId'


import threading
from .constant import (BATTERY_KEY, BATTERY_TECH_KEY, CHARGING_KEY, CHARGER_KEY,
                       CONNECTION_KEY, RESOURCE_KEYS,
                       RESOURCE_UPDATE_KEYS, SIGNAL_STR_KEY,
                       XCLOUD_ID_KEY)
    def resource_id(self):
        """ Shortcut for mostly used resource id.

        Some devices - certain cameras - can provide other types.
        """
        return self.resource_type + "/" + self._device_id

    @property
    def parent_id(self):
        if self._parent_id is not None:
            # self._arlo.debug('real parent is {}'.format(self._parent_id))
            return self._parent_id
        # self._arlo.debug('fake parent is {}'.format(self.device_id))
        return self.device_id

    @property
    def base_station(self):
        # look for real parents
        for base in self._arlo.base_stations:
            if base.device_id == self.parent_id:
                return base
        # some cameras don't have base stations... it's its own basestation...
        for base in self._arlo.base_stations:
            if base.device_id == self.device_id:
                return base
        # no idea!
        return self._arlo.base_stations[0]

    @property
    def battery_level(self):

# Path: config/hass/custom_components/aarlo/pyaarlo/constant.py
# BATTERY_KEY = 'batteryLevel'
# 
# BATTERY_TECH_KEY = 'batteryTech'
# 
# CHARGING_KEY = 'chargingState'
# 
# CHARGER_KEY = 'chargerTech'
# 
# CONNECTION_KEY = 'connectionState'
# 
# RESOURCE_KEYS = [ACTIVITY_STATE_KEY, AIR_QUALITY_KEY, AUDIO_DETECTED_KEY, BATTERY_KEY, BATTERY_TECH_KEY,
#                  BRIGHTNESS_KEY, CONNECTION_KEY, CHARGER_KEY, CHARGING_KEY, FLIP_KEY, HUMIDITY_KEY, LAMP_STATE_KEY,
#                  MIRROR_KEY, MOTION_DETECTED_KEY, MOTION_ENABLED_KEY,
#                  MOTION_SENS_KEY, POWER_SAVE_KEY, PRIVACY_KEY,
#                  SIGNAL_STR_KEY, SIREN_STATE_KEY, TEMPERATURE_KEY,
#                  AUDIO_CONFIG_KEY, AUDIO_PLAYLIST_KEY, AUDIO_STATUS_KEY, AUDIO_SPEAKER_KEY, AUDIO_TRACK_KEY, AUDIO_POSITION_KEY]
# 
# RESOURCE_UPDATE_KEYS = [ACTIVITY_STATE_KEY, AIR_QUALITY_KEY, AUDIO_DETECTED_KEY, BATTERY_KEY, BATTERY_TECH_KEY,
#                         CHARGER_KEY, CHARGING_KEY, CONNECTION_KEY, LAMP_STATE_KEY,
#                         HUMIDITY_KEY, MOTION_DETECTED_KEY, PRIVACY_KEY,
#                         SIGNAL_STR_KEY, SIREN_STATE_KEY, TEMPERATURE_KEY,
#                         AUDIO_CONFIG_KEY, AUDIO_PLAYLIST_KEY, AUDIO_STATUS_KEY, AUDIO_SPEAKER_KEY, AUDIO_TRACK_KEY, AUDIO_POSITION_KEY]
# 
# SIGNAL_STR_KEY = 'signalStrength'
# 
# XCLOUD_ID_KEY = 'xCloudId'


# Path: config/hass/custom_components/aarlo/pyaarlo/device.py
import threading
from .constant import (BATTERY_KEY, BATTERY_TECH_KEY, CHARGING_KEY, CHARGER_KEY,
                       CONNECTION_KEY, RESOURCE_KEYS,
                       RESOURCE_UPDATE_KEYS, SIGNAL_STR_KEY,
                       XCLOUD_ID_KEY)

    def resource_id(self):
        """ Shortcut for mostly used resource id.

        Some devices - certain cameras - can provide other types.
        """
        return self.resource_type + "/" + self._device_id

    @property
    def parent_id(self):
        if self._parent_id is not None:
            # self._arlo.debug('real parent is {}'.format(self._parent_id))
            return self._parent_id
        # self._arlo.debug('fake parent is {}'.format(self.device_id))
        return self.device_id

    @property
    def base_station(self):
        # look for real parents
        for base in self._arlo.base_stations:
            if base.device_id == self.parent_id:
                return base
        # some cameras don't have base stations... it's its own basestation...
        for base in self._arlo.base_stations:
            if base.device_id == self.device_id:
                return base
        # no idea!
        return self._arlo.base_stations[0]

    @property
    def battery_level(self):

        return self._arlo.st.get([self._device_id, BATTERY_KEY], 100)