diff --git a/custom_components/wyzeapi/light.py b/custom_components/wyzeapi/light.py index fe681238..959f7305 100644 --- a/custom_components/wyzeapi/light.py +++ b/custom_components/wyzeapi/light.py @@ -64,9 +64,18 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, for camera in await camera_service.get_cameras(): - # Only model that I know of that has a floodlight - if camera.product_model == "WYZE_CAKP2JFUS": - lights.append(WyzeCamerafloodlight(camera, camera_service)) + if ( + (camera.product_model == "WYZE_CAKP2JFUS" and camera.device_params['dongle_product_model'] == "HL_CFL") or # Cam v3 with floodlight accessory + (camera.product_model == "LD_CFP") or # Floodlight Pro + (camera.product_model == "HL_CFL2") # Floodlight v2 + ): + lights.append(WyzeCamerafloodlight(camera, camera_service, "floodlight")) + + elif ((camera.product_model == "WYZE_CAKP2JFUS" or camera.product_model == "HL_CAM4") and camera.device_params['dongle_product_model'] == "HL_CAM3SS"): # Cam v3 with lamp socket accessory + lights.append(WyzeCamerafloodlight(camera, camera_service, "lampsocket")) + + elif (camera.product_model == "AN_RSCW"): # Battery cam pro (integrated spotlight) + lights.append(WyzeCamerafloodlight(camera, camera_service, "spotlight")) async_add_entities(lights, True) @@ -367,10 +376,10 @@ class WyzeCamerafloodlight(LightEntity): _available: bool _just_updated = False - def __init__(self, camera: Camera, camera_service: CameraService) -> None: + def __init__(self, camera: Camera, camera_service: CameraService, light_type: str) -> None: self._device = camera self._service = camera_service - self._is_on = False + self._light_type = light_type @token_exception_handler async def async_turn_on(self, **kwargs) -> None: @@ -412,11 +421,11 @@ def is_on(self): @property def name(self) -> str: - return f"{self._device.nickname} floodlight" + return f"{self._device.nickname} {"Lamp Socket" if self._light_type == "lampsocket" else ("Floodlight" if self._light_type == "floodlight" else "Spotlight")}" @property def unique_id(self): - return f"{self._device.mac}-floodlight" + return f"{self._device.mac}-{self._light_type}" @property def device_info(self): @@ -453,7 +462,8 @@ async def async_added_to_hass(self) -> None: @property def icon(self): """Return the icon to use in the frontend.""" - return "mdi:track-light" + + return "mdi:lightbulb" if self._light_type == "lampsocket" else ("mdi:track-light" if self._light_type == "floodlight" else "mdi:spotlight") @property def color_mode(self): diff --git a/custom_components/wyzeapi/sensor.py b/custom_components/wyzeapi/sensor.py index 25394f83..c831a53d 100644 --- a/custom_components/wyzeapi/sensor.py +++ b/custom_components/wyzeapi/sensor.py @@ -235,6 +235,7 @@ def should_poll(self) -> bool: @property def device_info(self): + """Return the device info.""" return { "identifiers": { (DOMAIN, self._camera.mac) @@ -245,7 +246,9 @@ def device_info(self): self._camera.mac, ) }, - "name": f"{self._camera.nickname}.battery" + "name": self._camera.nickname, + "model": self._camera.product_model, + "manufacturer": "WyzeLabs" } @property diff --git a/custom_components/wyzeapi/siren.py b/custom_components/wyzeapi/siren.py index ccdcfea6..ce3c941c 100644 --- a/custom_components/wyzeapi/siren.py +++ b/custom_components/wyzeapi/siren.py @@ -43,8 +43,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, camera_service = await client.camera_service sirens = [] for camera in await camera_service.get_cameras(): - # The Campan and V2 cameras don't have a siren - if camera.product_model not in ["WYZECP1_JEF", "WYZEC1-JZ"]: + # The campan v1, v2 camera, and video doorbell pro don't have sirens + if camera.product_model not in ["WYZECP1_JEF", "WYZEC1-JZ", "GW_BE1"]: sirens.append(WyzeCameraSiren(camera, camera_service)) async_add_entities(sirens, True) diff --git a/custom_components/wyzeapi/switch.py b/custom_components/wyzeapi/switch.py index f7c2caeb..f12ec160 100644 --- a/custom_components/wyzeapi/switch.py +++ b/custom_components/wyzeapi/switch.py @@ -27,7 +27,8 @@ _LOGGER = logging.getLogger(__name__) ATTRIBUTION = "Data provided by Wyze" SCAN_INTERVAL = timedelta(seconds=30) -MOTION_SWITCH_UNSUPPORTED = ["GW_BE1", "LD_CFP"] # Doorbell Cam, Floodlight Pro +MOTION_SWITCH_UNSUPPORTED = ["GW_BE1", "GW_GC1", "GW_GC2"] # Video doorbell pro, OG, OG 3x Telephoto +POWER_SWITCH_UNSUPPORTED = ["GW_BE1"] # Video doorbell pro (device has no off function) # noinspection DuplicatedCode @token_exception_handler @@ -64,8 +65,15 @@ async def async_setup_entry( camera_switches = await camera_service.get_cameras() for switch in camera_switches: - switches.extend([WyzeSwitch(camera_service, switch)]) + + # Notification toggle switch switches.extend([WyzeCameraNotificationSwitch(camera_service, switch)]) + + # IoT Power switch + if switch.product_model not in POWER_SWITCH_UNSUPPORTED: + switches.extend([WyzeSwitch(camera_service, switch)]) + + # Motion toggle switch if switch.product_model not in MOTION_SWITCH_UNSUPPORTED: switches.extend([WyzeCameraMotionSwitch(camera_service, switch)]) @@ -320,18 +328,16 @@ class WyzeCameraNotificationSwitch(SwitchEntity): _available: bool - def __init__(self, service: CameraService, device: Device): + def __init__(self, service: CameraService, device: Camera): """Initialize a Wyze Notification Switch.""" self._service = service - self._device = Camera(device.raw_dict) + self._device = device @property def device_info(self): """Return the device info.""" return { - "identifiers": { - (DOMAIN, self._device.mac) - }, + "identifiers": {(DOMAIN, self._device.mac)}, "name": self._device.nickname, "manufacturer": "WyzeLabs", "model": self._device.product_model @@ -409,10 +415,10 @@ class WyzeCameraMotionSwitch(SwitchEntity): _available: bool - def __init__(self, service: CameraService, device: Device) -> None: + def __init__(self, service: CameraService, device: Camera) -> None: """Initialize a Wyze Notification Switch.""" self._service = service - self._device = Camera(device.raw_dict) + self._device = device @property def device_info(self):