def setup_platform(hass, config, add_devices, discovery_info=None):
    if shutil.which("raspistill") is None:
        _LOGGER.error("Error: raspistill not found")
        return False

    setup_config = (
        {
            "name": config.get("name", "Raspberry Pi Camera"),
            "image_width": int(config.get("image_width", "640")),
            "image_height": int(config.get("image_height", "480")),
            "image_quality": int(config.get("image_quality", "7")),
            "image_rotation": int(config.get("image_rotation", "0")),
            "timelapse": int(config.get("timelapse", "2000")),
            "horizontal_flip": int(config.get("horizontal_flip", "0")),
            "vertical_flip": int(config.get("vertical_flip", "0")),
            "file_path": config.get("file_path",
                                    os.path.join(os.path.dirname(__file__),
                                                 'image.jpg'))
        }
    )

    # check filepath given is writable
    if not os.access(setup_config["file_path"], os.W_OK):
        _LOGGER.error("Error: file path is not writable")
        return False

    add_devices([
        RaspberryCamera(setup_config)
    ])
Setup the Raspberry Camera.
dataset/ETHPy150Open home-assistant/home-assistant/homeassistant/components/camera/rpi_camera.py/setup_platform