pyblueiris package

Submodules

pyblueiris.blueiris module

Module for communicating with a Blue Iris server.

class pyblueiris.blueiris.BlueIris(aiosession: aiohttp.client.ClientSession, user, password, protocol, host, port='', debug=False, logger=<Logger pyblueiris.blueiris (WARNING)>)[source]

Bases: object

Class which represents a Blue Iris server.

This class uses a provided aiohttp.ClientSession with an internal helper client to talk with a Blue Iris server. Optionally you can provide a logging.Logger for it to use for logs. If none is provided, it will use one under its own namespace.

Parameters:
  • aiosession (aiohttp.ClientSession) – Async Session for handling requests to the Blue Iris server.
  • user (str) – Username used to authenticate to the server.
  • password (str) – Password used to authenticate to the server.
  • protocol (str) – Protocol used to communicate with the server. This should be either http or https.
  • host (str) – The IP address or FQDN of the Blue Iris server.
  • port (str) – The port of the Blue Iris server. This defauls to match protocol – 80 for http and 443 for https.
  • debug (boot) – Should we print extra debug messages? True if yes, False if no; defaults to False.
  • logger (logging.Logger) – The Logger to log messages to. Specify your own if you want to control where the log messages go. By default, uses the namespace __name__ for logging.
admin

Return True if we are authenticated as admin.

attributes

Return a dict of the Blue Iris server properties.

The attributes dictionary has the following structure:

  • name: The name of the Blue Iris server.
  • profiles: A list of profiles on the server.
  • iam_admin: True if our account is an admin.
  • ptz_allowed: True if we are allowed to send PTZ commands.
  • clips_allowed: True if we are allowed to access clips.
  • schedules: A list of schedules on the server.
  • version: The version of Blue Iris on the server.
  • audio_allowed: True if audio is available.
  • dio_available: True if dio is available.
  • stream_timelimit: The streaming timelimit.
  • license: The license used on the server.
  • support: The date support ends.
  • user: The username the server knows us by.
  • longitude: The server’s self-reported longitude.
  • latitude: The server’s self-reported latitude
  • tzone: The timezone offset.
  • streams: Available streams.
  • sounds: List of sounds that can be used.
  • www_sounds: List of sounds that can be used.
base_url

Return the configured base url, including protocol and port.

Examples

cameras

Return list of cameras on Blue Iris.

Returns:A (list) of camera shortcodes on the server.
enable_camera(camera, enabled=True)[source]

Send camconfig command to enable camera.

Parameters:camera (str) – The shortname-code for the camera to enable or disable.
Other Parameters:
 enabled (bool) – True to enable camera, False to disable. (Default: True)
get_camera_details(camera)[source]

Return the camera details for requested camera.

If last update was UPDATE_THRESHOLD seconds ago, it will request updated information for that camera from the Blue Iris server.

Parameters:
  • camera (str) – The shortname-code for the camera to update
  • for. (details) –
is_valid_camera(cam_shortcode)[source]

Return if cam_shortcode is a valid camera known to Blue Iris.

Parameters:cam_shortcode (str) – The shortname-code for the camera to check for validity.
Returns:True if cam_shortcode is a valid camera shortcode, otherwise False.
name

Return the name of the Blue Iris server.

pause_camera(camera, seconds)[source]

Send camconfig command to pause camera for seconds (rounded down to nearest 30 seconds).

Parameters:
  • camera (str) – The shortname-code for the camera to pause.
  • seconds (int) – The number of seconds to pause the camera. (Note: this will get rounded down to nearest 30 seconds).
pause_camera_add1hour(camera)[source]

Send camconfig command to pause camera.

Parameters:camera (str) – The shortname-code for the camera to pause for an additional hour.
pause_camera_add1minute(camera)[source]

Send camconfig command to pause camera.

Parameters:camera (str) – The shortname-code for the camera to pause for an additional minute.
pause_camera_add30seconds(camera)[source]

Send camconfig command to pause camera.

Parameters:camera (str) – The shortname-code for the camera to pause for an additional 30 seconds.
pause_camera_indefinitely(camera)[source]

Send camconfig command to pause camera.

Parameters:camera (str) – The shortname-code for the camera to pause until it is sent an unpause command.
reset_camera(camera)[source]

Send camconfig command to reset camera.

Parameters:camera (str) – The shortname-code for the camera to reset.
send_command(command: str, params=None)[source]

Send command to the Blue Iris server and handle the response.

Parameters:command – Command to send to the server. See the JSON API reference for valid values
Other Parameters:
 params (dict) – Parameters for the command. (Default: None)
Returns:A dict of data or True on success and False on failure (if no data returned from server).
send_ptz_command(camera, command: pyblueiris.const.PTZCommand)[source]

Operate a camera’s PTZ functionality.

Parameters:
  • camera (str) – The shortname-code for the camera to update the list for. By default, it will send “Index” to update the list for all cameras.
  • command – A valid PTZCommand. (Use the pyblueiris.const.PTZCommand Enum)
set_camera_motion(camera, motion_enabled=True)[source]

Send camconfig command to pause camera.

Parameters:camera (str) – The shortname-code for the camera to enable or disable motion-detection on.
Other Parameters:
 motion_enabled (bool) – True to enable motion detection, False to disable. (Default: True)
set_camera_ptzcycle(camera, preset_cycle_enabled=True)[source]

Send camconfig command to enable or disable the preset cycle feature.

Parameters:
  • camera (str) – The shortname-code for the camera to update
  • list for. By default, it will send "Index" to update the (the) –
  • for all cameras. (list) –
Other Parameters:
 

preset_cycle_enabled (bool) – True to enable, False to disable. (Default: True)

set_camera_ptzevent_schedule(camera, ptz_event_schedule_enabled=True)[source]

Send camconfig command to enable or disable the PTZ event schedule.

Parameters:camera (str) – The shortname-code for the camera to update the list for. By default, it will send “Index” to update the list for all cameras.
Other Parameters:
 ptz_event_schedule_enabled (bool) – True to enable, False to disable. (Default: True)
set_camera_schedule(camera, camera_schedule_enabled=True)[source]

Send camconfig command to enable or disable the caerma’s custom schedule.

Parameters:
  • camera (str) – The shortname-code for the camera to update
  • list for. By default, it will send "Index" to update the (the) –
  • for all cameras. (list) –
Other Parameters:
 

camera_schedule_enabled (bool) – True to enable, False to disable. (Default: True)

set_status_profile(profile_index: int)[source]

Set the current profile using the index of the profile.

Parameters:profile_index – Index of the profile to set.
set_status_profile_by_name(profile_name: str)[source]

Set the current profile using the name of the profile.

Parameters:profile_name – Name of the profile to set active on the server.
set_status_signal(signal: pyblueiris.const.Signal)[source]

Set the signal on the Blue Iris.

Parameters:signal – The signal to set on Blue Iris server. (Use the pyblueiris.const.Signal Enum.)
set_sysconfig_archive(archive_enabled: bool)[source]

Enable or disable web archiving.

Parameters:archive_enabled – True to enable web archiving, False to disable
set_sysconfig_schedule(global_schedule_enabled: bool)[source]

Enable or disable the global schedule.

Parameters:global_schedule_enabled – True to enable the global schedule, False to disable
setup_session()[source]

Log into the Blue Iris server and record basic server info.

Set up the session with the Blue Iris server by sending a login command using Client. When the reply is received, we check for an object of data about the server. We know if the data dictionary is not in the reply that the login failed.

Returns:False if the session did not get created successfully. True on success.
trigger_camera_motion(camera)[source]

Send trigger command to specific camera.

Parameters:camera (str) – The shortname-code for the camera to trigger.
unpause_camera(camera)[source]

Send camconfig command to pause camera.

Parameters:camera (str) – The shortname-code for the camera to unpause
update_alertlist(camera='Index')[source]

Update the list of alerts in attributes for specified camera.

If no camera is specified, this includes all cameras.

Parameters:camera (str) – The shortname-code for the camera to update the list for. By default, it will send “Index” to update the list for all cameras.
update_all_information()[source]

Refresh all the information we can get from the Blue Iris server.

update_camlist()[source]

Update the camera config and camera list in attributes.

This function sends the ‘camlist’ command to the server and parses the result. It stores the full result in self.attributes.camconfig and creates a dictionary of the camera shortcode and display names in self.attributes.cameras.

This makes it easier to go through what cameras are available and how to reference them without cycling through a large dict.

update_cliplist(camera='Index')[source]

Update the list of clips in attributes for specified camera.

If no camera is specified, this will includes all cameras.

Parameters:camera (str) – The shortname-code for the camera to update the list for. By default, it will send “Index” to update the list for all cameras.
update_log()[source]

Update the log attribute from the Blue Iris server.

update_status()[source]

Update the status record in attributes.

update_sysconfig()[source]

Update the system configuration status from Blue Iris.

version

Return the version of Blue Iris running on the server.

pyblueiris.camera module

Represent a Camera on a Blue Iris sever.

class pyblueiris.camera.BlueIrisCamera(bi, camera_shortname: str)[source]

Bases: object

Class which represents a Camera on a Blue Iris server.

Parameters:
  • bi (BlueIris) – The Blue Iris server this camera belongs to.
  • camera_shortname (str) – The shortname for this camera.
audio_supported

Return True if the camera has audio support.

Type:bool
color

Return color of camera.

Type:str
detect_motion(enabled=True)[source]

Set this camera to detect motion or not.

Other Parameters:
 enabled (bool) – True to enable motion detection, False to disable. (Default: True)
disable()[source]

Disable this camera.

display_name

Return the camera’s name.

Type:str
enable()[source]

Enable this camera.

fps

Return the FPS of the camera.

Type:int
height

Return the height of the camera image.

Type:int
is_alerting

Return True if the camera is alerting.

Type:bool
is_enabled

Return True if the camera is enabled in Blue Iris.

Type:bool
is_motion

Return True if the camera detects motion.

Type:bool
is_nosignal

Return True if the camera is in ‘no signal’ state.

Type:bool
is_online

Return True if the camera is online.

Type:bool
is_paused

Return True if the camera is paused.

Type:bool
is_recording

Return True if the camera is recording.

Type:bool
is_triggered

Return True if the camera is triggered.

Type:bool
is_yellow

Return True if the camera is yellow in Blue Iris.

Type:bool
last_update_time

Return the EPOCH of when this object last updated its camera information.

Type:long
mjpeg_url

Return the URL to the mjpeg stream for this camera.

Type:str
num_clips

Return the number of clips the camera has recorded.

Type:int
num_norecording

Return the number of ‘no recording’ events.

Type:int
num_nosignal

Return the number of ‘no signal’ events.

Type:int
num_triggers

Return the number of ‘trigger’ events.

Type:int
profile

Return the index of the profile active on the camera.

Type:int
ptz_supported

Return True if the camera has PTZ support.

Type:bool
short_name

Return the camera shortcode for the camera.

Type:str
update_camconfig()[source]

Update this object’s details on the camera it represents.

update_properties(camlist_data: {})[source]

Update this objects properties based on a dictionary of camera data.

The camera data dictionary should come from the camlist command sent to the Blue Iris server.

Parameters:camlist_data (dict) – Property values for this camera.
width

Return the width of the camera image.

Type:int

pyblueiris.client module

Async client helper for the Blue Iris class.

class pyblueiris.client.BlueIrisClient(session: aiohttp.client.ClientSession, endpointurl: str, debug: bool, logger: logging.Logger)[source]

Bases: object

Class which facilitates communication with the BlueIris server.

Parameters:
  • session (aiohttp.ClientSession) – Async ClientSession to use for communication with the Blue Iris server.
  • endpointurl (str) – Full URL used to communicate with the Blue Iris server. This includes the protocol (either “http” or “https”) and the ‘/json’ path. If you use a non-standard port (i.e. something other than 80 for http and 443 for https), it needs to be specified after the host. (E.g http://192.168.1.15:81/json)
  • debug (bool) – True to have more verbose logging, defaults to False.
  • logger (logging.Logger) – Logger to send log messages to.
cmd(command, params=None)[source]

Send a command to the Blue Iris server.

Parameters:command (str) – Command to send to the Blue Iris server.
Other Parameters:
 params (dict) – Parameters for the command. (Default: None)
Returns:The ‘data’ portion of the JSON response. If there was no ‘data’ in the response, return the entire response JSON.
Return type:dict
generate_response(username, password)[source]

Generate the response needed to authenticate to Blue Iris.

When communicating with the Blue Iris JSON API, you must provide a valid response when sending commands. This method updates the stored response used by this client.

This object must have a current username, password and session for this method to work correctly!

Parameters:
  • username (str) – Username used to authenticate.
  • password (str) – Password used to authenitcate.
login(username, password)[source]

Authenticate to the Blue Iris server.

Parameters:
  • username (str) – Username used to authenticate.
  • password (str) – Password used to authenitcate.
Returns:

Returns dictionary of server properties or empty dictionary on failure.

Return type:

dict

pyblueiris.const module

class pyblueiris.const.CAMConfig[source]

Bases: enum.Enum

Enumaration of the possible values used when changing CAMConfig.

PAUSE_ADD_1_HOUR = 3
PAUSE_ADD_1_MIN = 2
PAUSE_ADD_30_SEC = 1
PAUSE_CANCEL = 0
PAUSE_INDEFINITELY = -1
class pyblueiris.const.PTZCommand[source]

Bases: enum.Enum

Enumaration of the possible values for sending PTZ commands.

BRIGHTNESS_0 = 11
BRIGHTNESS_1 = 12
BRIGHTNESS_10 = 21
BRIGHTNESS_11 = 22
BRIGHTNESS_12 = 23
BRIGHTNESS_13 = 24
BRIGHTNESS_14 = 25
BRIGHTNESS_15 = 26
BRIGHTNESS_2 = 13
BRIGHTNESS_3 = 14
BRIGHTNESS_4 = 15
BRIGHTNESS_5 = 16
BRIGHTNESS_6 = 17
BRIGHTNESS_7 = 18
BRIGHTNESS_8 = 19
BRIGHTNESS_9 = 20
CENTER = 4
CONTRAST_0 = 27
CONTRAST_1 = 28
CONTRAST_2 = 29
CONTRAST_3 = 30
CONTRAST_4 = 31
CONTRAST_5 = 32
CONTRAST_6 = 33
HOME = 4
IR_OFF = 35
IR_ON = 34
PAN_LEFT = 0
PAN_RIGHT = 1
POWER_50 = 8
POWER_60 = 9
POWER_OUTDOOR = 10
PRESET_1 = 101
PRESET_10 = 110
PRESET_11 = 111
PRESET_12 = 112
PRESET_13 = 113
PRESET_14 = 114
PRESET_15 = 115
PRESET_16 = 116
PRESET_17 = 117
PRESET_18 = 118
PRESET_19 = 119
PRESET_2 = 102
PRESET_20 = 120
PRESET_3 = 103
PRESET_4 = 104
PRESET_5 = 105
PRESET_6 = 106
PRESET_7 = 107
PRESET_8 = 108
PRESET_9 = 109
TILT_DOWN = 3
TILT_UP = 2
ZOOM_IN = 5
ZOOM_OUT = 6
class pyblueiris.const.Signal[source]

Bases: enum.Enum

Enumaration of the possible values of the stoplight signal property.

GREEN = 1

Green stoplight signal.

RED = 0

Red stoplight signal.

YELLOW = 2

Yellow stoplight signal.

pyblueiris.const.has_value(enum: enum.Enum, value)[source]
Bool:Return True if value is a valid member of enum.

You can check either the string (GREEN, RED..) or the value (0, 1..).

Parameters:
  • enum – The enumeration to check for value in.
  • value – The enum string key or its int value.
Returns:

True if the value is within this enum, False if it isn’t.

Module contents