class SomfyCameraShutter(SomfyEntity, SwitchEntity): """Representation of a Somfy Camera Shutter device.""" def __init__(self, coordinator, device_id, api): """Initialize the Somfy device.""" super().__init__(coordinator, device_id, api) self._create_device() def _create_device(self): """Update the device with the latest data.""" self.shutter = CameraProtect(self.device, self.api) def turn_on(self, **kwargs) -> None: """Turn the entity on.""" self.shutter.open_shutter() def turn_off(self, **kwargs): """Turn the entity off.""" self.shutter.close_shutter() @property def is_on(self) -> bool: """Return True if entity is on.""" return self.shutter.get_shutter_position() == "opened"
def _create_device(self): """Update the device with the latest data.""" self.shutter = CameraProtect(self.device, self.api)
def _create_device(self): """Update the device with the latest data.""" self.shutter = CameraProtect(self.device, self.coordinator.client)
async def async_update(self): """Update the device with the latest data.""" await super().async_update() self.shutter = CameraProtect(self.device, self.api)
def __init__(self, device, api): """Initialize the Somfy device.""" super().__init__(device, api) self.shutter = CameraProtect(self.device, self.api)
def device(self): api = SomfyApi("foo", "faa", "https://whatever.com") device_path = os.path.join(CURRENT_DIR, "camera.json") with open(device_path, "r") as get_device: device = Device(**json.loads(get_device.read())) return CameraProtect(device, api)