Camera unifi_video.camera

exception unifi_video.camera.CameraModelError(message=None)[source]

Bases: exceptions.ValueError

Unsupported camera model

class unifi_video.camera.UnifiVideoCamera(api, data=None)[source]

Bases: unifi_video.single.UnifiVideoSingle

Represents a single camera connected to a UniFi Video server (UnifiVideoAPI).

Variables:
  • name (str or NoneType) – Camera name
  • model (str or NoneType) – Camera model
  • platform (str or NoneType) – Firmware platform
  • overlay_text (str) – Custom text overlayd over the image
  • mac_addr (str) – Camera MAC address
  • utc_h_offset (int or NoneType) – UTC offset in hours
  • state (str) – Camera state
  • managed (bool) – Whether camera is managed by the UniFi Video instance
  • provisioned (bool) – Whether camera is provisioned
  • managed_by_others (bool) – Whether camera is managed by some other UniFi Video instance
  • disconnect_reason (str) – Reason for most recent disconnect
  • connected (bool) – Whether camera is connected (ie, not disconnected or in process of rebooting or being upgraded)
  • last_recording_id (str) – MongoDB ObjectID of latest recording
  • last_recording_start_time (int) – Unix timestamp (in ms): start time of latest recording
  • last_seen (int) –

    Unix timestamp (in ms). Meaning depends on the value of UnifiVideoCamera.state:

    • CONNECTED: timestamp for when the camera came online
    • DISCONNECTED: timestamp for when the camera went offline
  • last_seen_ndt (datetime or NoneType) – UnifiVideoCamera.last_seen as naive datetime object
  • _id (str) – Camera ID (MongoDB ObjectID as hex string)
  • _data (dict) – Complete camera JSON from UniFi Video server
  • _isp_actionables (list) – List of supported image settings

Warning

Attributes having to do with camera state reflect the state as it was during object instantiation.

Warning

UnifiVideoCamera.last_seen changes were observed on UniFi Video v3.10.13. No attempt has been made to verify UnifiVideoCamera.last_seen acts the same way across all supported UniFi Video versions.

brightness(val=None)

Control image brightness

Parameters:value (int or NoneType) – New brightness value (min: 0, max: 100)
Returns:True or False, depending on whether new value value was successfully registered. Current brightness value when called without input value.
Return type:bool or int
contrast(val=None)

Control image contrast

Parameters:value (int or NoneType) – New contrast value (min: 0, max: 100)
Returns:True or False, depending on whether new value value was successfully registered. Current contrast value when called without input value.
Return type:bool or int
denoise(val=None)

Control image denoise

Parameters:value (int or NoneType) – New denoise value (min: 0, max: 100)
Returns:True or False, depending on whether new value value was successfully registered. Current denoise value when called without input value.
Return type:bool or int
dynamic_range(val=None)[source]

Control image WDR (dynamic range). Input should be either None or an int between 0 and 3.

Parameters:wdr (int or None) – New WDR value
Returns:If value provided: True or False, depending on whether new value was registered. If no value provided: current WDR value.
Return type:bool or int
get_recording_settings(all=False)[source]

Get camera’s recording settings

Parameters:all (bool) – Whether to show all available settings. The default is to only show the settings that are controllable by calling set_recording_settings().
hue(val=None)

Control image hue

Parameters:value (int or NoneType) – New hue value (min: 0, max: 100)
Returns:True or False, depending on whether new value value was successfully registered. Current hue value when called without input value.
Return type:bool or int
ir_leds(led_state=None)[source]

Control IR leds.

Parameters:led_state (str or None) – New led state (auto, on, or off).
Returns:True or False depending on successful value change. Current led state if called with no args.
Return type:bool or str
onscreen_text(text=None)[source]

Set or get on-screen text.

Parameters:text (str or None) – New on-screen text
Returns:True for successful value change, Fail for failed attempt, current str value if called without text.
Return type:bool or str
onscreen_timestamp(enabled=None)[source]

Set or get on-screen timestamp state.

Parameters:enabled (bool or None) – New state
Returns:True for successful state change, Fail for failed attempt. Either of the two for current state (when called without the enabled arg)
Return type:bool
onscreen_watermark(enabled=None)[source]

Enable or disable on-screen watermark. Call without args to get current setting.

Parameters:enabled (bool or None) – Enable or disable
Returns:True for successful change, Fail for failed attempt. One or the other for calls without args.
Return type:bool
recording_between(start_time, end_time, filename=None)[source]

Download a recording of the camera’s footage from an arbitrary timespan, between start_time and end_time.

Parameters:
  • start_time (datetime or str or int) – Recording start time. (See dt_resolvable_to_ms().)
  • end_time (datetime or str or int) – Recording end time. (See dt_resolvable_to_ms().)
  • filename (str, optional) – Filename to save the recording to (a ZIP file). Will use whatever the server provides if left out.

Tip

Widen the time span by a few seconds at each end. UniFi Video often falls a little short of the exact start and end times.

saturation(val=None)

Control image saturation

Parameters:value (int or NoneType) – New saturation value (min: 0, max: 100)
Returns:True or False, depending on whether new value value was successfully registered. Current saturation value when called without input value.
Return type:bool or int
set_recording_settings(recording_mode=None, pre_padding_secs=None, post_padding_secs=None)[source]

Set recording mode and pre/post padding.

Possible recording modes:
  • disable: don’t record
  • fulltime: record at all times
  • motion: record when motion detected
Parameters:
  • recording_mode (str) – See above
  • pre_padding_secs (int) – Number of seconds to include pre-motion footage of
  • post_padding_secs (int) – Number of seconds to include post-motion footage of
sharpness(val=None)

Control image sharpness

Parameters:value (int or NoneType) – New sharpness value (min: 0, max: 100)
Returns:True or False, depending on whether new value value was successfully registered. Current sharpness value when called without input value.
Return type:bool or int
snapshot(filename=None, width=0)[source]

Take and download snapshot.

Parameters:
  • filename (str or None) – Filename to save the snapshot to
  • width (int) – Image width in pixels
update(save=False)[source]

Update settings from remote UniFi Video server (self._api). Call with True to write local settings to remote before updating.

Parameters:save (bool) – Whether to push settings to the camera