# Path: config/hass/custom_components/aarlo/pyaarlo/constant.py
# LAMP_STATE_KEY = 'lampState'
# 
# Path: config/hass/custom_components/aarlo/pyaarlo/device.py
# class ArloChildDevice(ArloDevice):
# 
#     def __init__(self, name, arlo, attrs):
#         super().__init__(name, arlo, attrs)
# 
#         self._parent_id = attrs.get('parentId', None)
#         self._arlo.debug('parent is {}'.format(self._parent_id))
#         self._arlo.debug('resource is {}'.format(self.resource_id))
# 
#     @property
#     def resource_type(self):
#         return "child"
# 
#     @property
#     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)
# 
#     @property
#     def battery_tech(self):
#         return self._arlo.st.get([self._device_id, BATTERY_TECH_KEY], 'None')
# 
#     @property
#     def charging(self):
#         return self._arlo.st.get([self._device_id, CHARGING_KEY], 'off').lower() == 'on'
# 
#     @property
#     def charger_type(self):
#         return self._arlo.st.get([self._device_id, CHARGER_KEY], 'None')
# 
#     @property
#     def wired(self):
#         return self.charger_type.lower() != 'none'
# 
#     @property
#     def wired_only(self):
#         return self.battery_tech.lower() == 'none' and self.wired
# 
#     @property
#     def signal_strength(self):
#         return self._arlo.st.get([self._device_id, SIGNAL_STR_KEY], 3)
# 
#     @property
#     def is_unavailable(self):
#         return self._arlo.st.get([self._device_id, CONNECTION_KEY], 'unknown') == 'unavailable'
# 
#     @property
#     def too_cold(self):
#         return self._arlo.st.get([self._device_id, CONNECTION_KEY], 'unknown') == 'thermalShutdownCold'
# 
#     @property
#     def state(self):
#         if self.is_unavailable:
#             return 'unavailable'
#         if not self.is_on:
#             return 'turned off'
#         if self.too_cold:
#             return 'offline, too cold'
#         return 'idle'


from .constant import LAMP_STATE_KEY
from .device import ArloChildDevice


class ArloLight(ArloChildDevice):

    def __init__(self, name, arlo, attrs):
        super().__init__(name, arlo, attrs)

    @property
    def resource_type(self):
        return "lights"

    def _event_handler(self, resource, event):
        self._arlo.debug(self.name + ' LIGHT got one ' + resource)

        # pass on to lower layer
        super()._event_handler(resource, event)

    @property
    def is_on(self):

# Path: config/hass/custom_components/aarlo/pyaarlo/constant.py
# LAMP_STATE_KEY = 'lampState'
# 
# Path: config/hass/custom_components/aarlo/pyaarlo/device.py
# class ArloChildDevice(ArloDevice):
# 
#     def __init__(self, name, arlo, attrs):
#         super().__init__(name, arlo, attrs)
# 
#         self._parent_id = attrs.get('parentId', None)
#         self._arlo.debug('parent is {}'.format(self._parent_id))
#         self._arlo.debug('resource is {}'.format(self.resource_id))
# 
#     @property
#     def resource_type(self):
#         return "child"
# 
#     @property
#     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)
# 
#     @property
#     def battery_tech(self):
#         return self._arlo.st.get([self._device_id, BATTERY_TECH_KEY], 'None')
# 
#     @property
#     def charging(self):
#         return self._arlo.st.get([self._device_id, CHARGING_KEY], 'off').lower() == 'on'
# 
#     @property
#     def charger_type(self):
#         return self._arlo.st.get([self._device_id, CHARGER_KEY], 'None')
# 
#     @property
#     def wired(self):
#         return self.charger_type.lower() != 'none'
# 
#     @property
#     def wired_only(self):
#         return self.battery_tech.lower() == 'none' and self.wired
# 
#     @property
#     def signal_strength(self):
#         return self._arlo.st.get([self._device_id, SIGNAL_STR_KEY], 3)
# 
#     @property
#     def is_unavailable(self):
#         return self._arlo.st.get([self._device_id, CONNECTION_KEY], 'unknown') == 'unavailable'
# 
#     @property
#     def too_cold(self):
#         return self._arlo.st.get([self._device_id, CONNECTION_KEY], 'unknown') == 'thermalShutdownCold'
# 
#     @property
#     def state(self):
#         if self.is_unavailable:
#             return 'unavailable'
#         if not self.is_on:
#             return 'turned off'
#         if self.too_cold:
#             return 'offline, too cold'
#         return 'idle'


# Path: config/hass/custom_components/aarlo/pyaarlo/light.py
from .constant import LAMP_STATE_KEY
from .device import ArloChildDevice



class ArloLight(ArloChildDevice):

    def __init__(self, name, arlo, attrs):
        super().__init__(name, arlo, attrs)

    @property
    def resource_type(self):
        return "lights"

    def _event_handler(self, resource, event):
        self._arlo.debug(self.name + ' LIGHT got one ' + resource)

        # pass on to lower layer
        super()._event_handler(resource, event)

    @property
    def is_on(self):

        return self._arlo.st.get([self._device_id, LAMP_STATE_KEY], "off") == "on"