예제 #1
0
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"
예제 #2
0
 def _create_device(self):
     """Update the device with the latest data."""
     self.shutter = CameraProtect(self.device, self.api)
예제 #3
0
 def _create_device(self):
     """Update the device with the latest data."""
     self.shutter = CameraProtect(self.device, self.coordinator.client)
예제 #4
0
 async def async_update(self):
     """Update the device with the latest data."""
     await super().async_update()
     self.shutter = CameraProtect(self.device, self.api)
예제 #5
0
 def __init__(self, device, api):
     """Initialize the Somfy device."""
     super().__init__(device, api)
     self.shutter = CameraProtect(self.device, self.api)
예제 #6
0
 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)