original_docstring: Set up an Arlo IP Camera.
docstring: Set up an Arlo IP Camera.
docstring_tokens: Set up an Arlo IP Camera .
code: async def async_setup_platform(hass, config, async_add_entities, _discovery_info=None):
      """Set up an Arlo IP Camera."""
      arlo = hass.data[COMPONENT_DATA]
  
      cameras = []
      cameras_with_siren = False
      for camera in arlo.cameras:
          cameras.append(ArloCam(camera, config, arlo, hass))
          if camera.has_capability(SIREN_STATE_KEY):
              cameras_with_siren = True
  
      async_add_entities(cameras)
  
      # Component services
      def service_callback(call):
          """Call aarlo service handler."""
          _LOGGER.info("{} service called".format(call.service))
          if call.service == SERVICE_REQUEST_SNAPSHOT:
              camera_snapshot_service(hass, call)
          if call.service == SERVICE_REQUEST_SNAPSHOT_TO_FILE:
              camera_snapshot_to_file_service(hass, call)
          if call.service == SERVICE_REQUEST_VIDEO_TO_FILE:
              camera_video_to_file_service(hass, call)
          if call.service == SERVICE_STOP_ACTIVITY:
              camera_stop_activity_service(hass, call)
          if call.service == SERVICE_RECORD_START:
              camera_start_recording_service(hass, call)
          if call.service == SERVICE_RECORD_STOP:
              camera_stop_recording_service(hass, call)
  
      async def async_service_callback(call):
          await hass.async_add_executor_job(service_callback, call)
  
      if not hasattr(hass.data[COMPONENT_SERVICES], DOMAIN):
          _LOGGER.info("installing handlers")
          hass.data[COMPONENT_SERVICES][DOMAIN] = "installed"
          hass.services.async_register(
              COMPONENT_DOMAIN,
              SERVICE_REQUEST_SNAPSHOT,
              async_service_callback,
              schema=CAMERA_SERVICE_SCHEMA,
          )
          hass.services.async_register(
              COMPONENT_DOMAIN,
              SERVICE_REQUEST_SNAPSHOT_TO_FILE,
              async_service_callback,
              schema=CAMERA_SERVICE_SNAPSHOT,
          )
          hass.services.async_register(
              COMPONENT_DOMAIN,
              SERVICE_REQUEST_VIDEO_TO_FILE,
              async_service_callback,
              schema=CAMERA_SERVICE_SNAPSHOT,
          )
          hass.services.async_register(
              COMPONENT_DOMAIN,
              SERVICE_STOP_ACTIVITY,
              async_service_callback,
              schema=CAMERA_SERVICE_SCHEMA,
          )
          hass.services.async_register(
              COMPONENT_DOMAIN,
              SERVICE_RECORD_START,
              async_service_callback,
              schema=RECORD_START_SCHEMA,
          )
          hass.services.async_register(
              COMPONENT_DOMAIN,
              SERVICE_RECORD_STOP,
              async_service_callback,
              schema=CAMERA_SERVICE_SCHEMA,
          )
  
      # Deprecated Services.
      if not arlo.cfg.hide_deprecated_services:
          component = hass.data[DOMAIN]
          component.async_register_entity_service(
              OLD_SERVICE_REQUEST_SNAPSHOT,
              CAMERA_SERVICE_SCHEMA,
              aarlo_snapshot_service_handler,
          )
          component.async_register_entity_service(
              OLD_SERVICE_REQUEST_SNAPSHOT_TO_FILE,
              CAMERA_SERVICE_SNAPSHOT,
              aarlo_snapshot_to_file_service_handler,
          )
          component.async_register_entity_service(
              OLD_SERVICE_REQUEST_VIDEO_TO_FILE,
              CAMERA_SERVICE_SNAPSHOT,
              aarlo_video_to_file_service_handler,
          )
          component.async_register_entity_service(
              OLD_SERVICE_STOP_ACTIVITY,
              CAMERA_SERVICE_SCHEMA,
              aarlo_stop_activity_handler,
          )
          if cameras_with_siren:
              component.async_register_entity_service(
                  OLD_SERVICE_SIREN_ON, SIREN_ON_SCHEMA, aarlo_siren_on_service_handler
              )
              component.async_register_entity_service(
                  OLD_SERVICE_SIREN_OFF, SIREN_OFF_SCHEMA, aarlo_siren_off_service_handler
              )
          component.async_register_entity_service(
              OLD_SERVICE_RECORD_START, RECORD_START_SCHEMA, aarlo_start_recording_handler
          )
          component.async_register_entity_service(
              OLD_SERVICE_RECORD_STOP, CAMERA_SERVICE_SCHEMA, aarlo_stop_recording_handler
          )
  
      # Websockets
      hass.components.websocket_api.async_register_command(
          WS_TYPE_VIDEO_URL, websocket_video_url, SCHEMA_WS_VIDEO_URL
      )
      hass.components.websocket_api.async_register_command(
          WS_TYPE_LIBRARY, websocket_library, SCHEMA_WS_LIBRARY
      )
      hass.components.websocket_api.async_register_command(
          WS_TYPE_STREAM_URL, websocket_stream_url, SCHEMA_WS_STREAM_URL
      )
      hass.components.websocket_api.async_register_command(
          WS_TYPE_SNAPSHOT_IMAGE, websocket_snapshot_image, SCHEMA_WS_SNAPSHOT_IMAGE
      )
      hass.components.websocket_api.async_register_command(
          WS_TYPE_REQUEST_SNAPSHOT, websocket_request_snapshot, SCHEMA_WS_REQUEST_SNAPSHOT
      )
      hass.components.websocket_api.async_register_command(
          WS_TYPE_VIDEO_DATA, websocket_video_data, SCHEMA_WS_VIDEO_DATA
      )
      hass.components.websocket_api.async_register_command(
          WS_TYPE_STOP_ACTIVITY, websocket_stop_activity, SCHEMA_WS_STOP_ACTIVITY
      )
      if cameras_with_siren:
          hass.components.websocket_api.async_register_command(
              WS_TYPE_SIREN_ON, websocket_siren_on, SCHEMA_WS_SIREN_ON
          )
          hass.components.websocket_api.async_register_command(
              WS_TYPE_SIREN_OFF, websocket_siren_off, SCHEMA_WS_SIREN_OFF
          )
code_tokens: async def async_setup_platform ( hass , config , async_add_entities , _discovery_info = None ) : arlo = hass . data [ COMPONENT_DATA ] cameras = [ ] cameras_with_siren = False for camera in arlo . cameras : cameras . append ( ArloCam ( camera , config , arlo , hass ) ) if camera . has_capability ( SIREN_STATE_KEY ) : cameras_with_siren = True async_add_entities ( cameras ) def service_callback ( call ) : """Call aarlo service handler.""" _LOGGER . info ( "{} service called" . format ( call . service ) ) if call . service == SERVICE_REQUEST_SNAPSHOT : camera_snapshot_service ( hass , call ) if call . service == SERVICE_REQUEST_SNAPSHOT_TO_FILE : camera_snapshot_to_file_service ( hass , call ) if call . service == SERVICE_REQUEST_VIDEO_TO_FILE : camera_video_to_file_service ( hass , call ) if call . service == SERVICE_STOP_ACTIVITY : camera_stop_activity_service ( hass , call ) if call . service == SERVICE_RECORD_START : camera_start_recording_service ( hass , call ) if call . service == SERVICE_RECORD_STOP : camera_stop_recording_service ( hass , call ) async def async_service_callback ( call ) : await hass . async_add_executor_job ( service_callback , call ) if not hasattr ( hass . data [ COMPONENT_SERVICES ] , DOMAIN ) : _LOGGER . info ( "installing handlers" ) hass . data [ COMPONENT_SERVICES ] [ DOMAIN ] = "installed" hass . services . async_register ( COMPONENT_DOMAIN , SERVICE_REQUEST_SNAPSHOT , async_service_callback , schema = CAMERA_SERVICE_SCHEMA , ) hass . services . async_register ( COMPONENT_DOMAIN , SERVICE_REQUEST_SNAPSHOT_TO_FILE , async_service_callback , schema = CAMERA_SERVICE_SNAPSHOT , ) hass . services . async_register ( COMPONENT_DOMAIN , SERVICE_REQUEST_VIDEO_TO_FILE , async_service_callback , schema = CAMERA_SERVICE_SNAPSHOT , ) hass . services . async_register ( COMPONENT_DOMAIN , SERVICE_STOP_ACTIVITY , async_service_callback , schema = CAMERA_SERVICE_SCHEMA , ) hass . services . async_register ( COMPONENT_DOMAIN , SERVICE_RECORD_START , async_service_callback , schema = RECORD_START_SCHEMA , ) hass . services . async_register ( COMPONENT_DOMAIN , SERVICE_RECORD_STOP , async_service_callback , schema = CAMERA_SERVICE_SCHEMA , ) if not arlo . cfg . hide_deprecated_services : component = hass . data [ DOMAIN ] component . async_register_entity_service ( OLD_SERVICE_REQUEST_SNAPSHOT , CAMERA_SERVICE_SCHEMA , aarlo_snapshot_service_handler , ) component . async_register_entity_service ( OLD_SERVICE_REQUEST_SNAPSHOT_TO_FILE , CAMERA_SERVICE_SNAPSHOT , aarlo_snapshot_to_file_service_handler , ) component . async_register_entity_service ( OLD_SERVICE_REQUEST_VIDEO_TO_FILE , CAMERA_SERVICE_SNAPSHOT , aarlo_video_to_file_service_handler , ) component . async_register_entity_service ( OLD_SERVICE_STOP_ACTIVITY , CAMERA_SERVICE_SCHEMA , aarlo_stop_activity_handler , ) if cameras_with_siren : component . async_register_entity_service ( OLD_SERVICE_SIREN_ON , SIREN_ON_SCHEMA , aarlo_siren_on_service_handler ) component . async_register_entity_service ( OLD_SERVICE_SIREN_OFF , SIREN_OFF_SCHEMA , aarlo_siren_off_service_handler ) component . async_register_entity_service ( OLD_SERVICE_RECORD_START , RECORD_START_SCHEMA , aarlo_start_recording_handler ) component . async_register_entity_service ( OLD_SERVICE_RECORD_STOP , CAMERA_SERVICE_SCHEMA , aarlo_stop_recording_handler ) hass . components . websocket_api . async_register_command ( WS_TYPE_VIDEO_URL , websocket_video_url , SCHEMA_WS_VIDEO_URL ) hass . components . websocket_api . async_register_command ( WS_TYPE_LIBRARY , websocket_library , SCHEMA_WS_LIBRARY ) hass . components . websocket_api . async_register_command ( WS_TYPE_STREAM_URL , websocket_stream_url , SCHEMA_WS_STREAM_URL ) hass . components . websocket_api . async_register_command ( WS_TYPE_SNAPSHOT_IMAGE , websocket_snapshot_image , SCHEMA_WS_SNAPSHOT_IMAGE ) hass . components . websocket_api . async_register_command ( WS_TYPE_REQUEST_SNAPSHOT , websocket_request_snapshot , SCHEMA_WS_REQUEST_SNAPSHOT ) hass . components . websocket_api . async_register_command ( WS_TYPE_VIDEO_DATA , websocket_video_data , SCHEMA_WS_VIDEO_DATA ) hass . components . websocket_api . async_register_command ( WS_TYPE_STOP_ACTIVITY , websocket_stop_activity , SCHEMA_WS_STOP_ACTIVITY ) if cameras_with_siren : hass . components . websocket_api . async_register_command ( WS_TYPE_SIREN_ON , websocket_siren_on , SCHEMA_WS_SIREN_ON ) hass . components . websocket_api . async_register_command ( WS_TYPE_SIREN_OFF , websocket_siren_off , SCHEMA_WS_SIREN_OFF )
short_docstring: Set up an Arlo IP Camera.
short_docstring_tokens: Set up an Arlo IP Camera .
comment: """Set up an Arlo IP Camera."""$SEP$# Component services$SEP$"""Call aarlo service handler."""$SEP$# Deprecated Services.$SEP$# Websockets