IVS Module

From IVS Wiki
Revision as of 17:40, 8 February 2022 by IVSWikiBlue (talk | contribs) (Created page with "=VALT Class= ==Class Specifications== ===Usage=== Creates a class that is one instance of a connection to a VALT server. The below functions are all defined as part of the val...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

VALT Class

Class Specifications

Usage

Creates a class that is one instance of a connection to a VALT server. The below functions are all defined as part of the valt class and can be called.

Initiation

Upon initiation, the class will attempt to authenticate to the specified VALT server using the provided credentials. If authentication fails upon initiation or upon any further actions, the class will wait 30 seconds and then attempt to reauthenticate. Upon success, the class with reauthenticate every 24 hours.

Variables

Variable Type Value
username string Stores the username used to authenticate to VALT.
password string Stores the password used to authenticate to VALT.
baseurl String Stores the basic url to connect to valt. The url is composed of the valt server address. For example http://ivstest1.ad.ipivs.com/api/v3/
success_reauth_time int The number of seconds to wait before reauthenticating to VALT after a successful authentication. Default is 28800.
failure_reauth_time int The number of seconds to wait before reauthenticating to VALT after a failed authentication attempt. Default is 30.
accesstoken string Stores the current access token retrieved during the last successful authentication. This will be set to 0 upon a failed authentication attempt or an error during any other function.
lastauthtime time Stores the last epoch time when authentication was attempted.

Parameters

valt(server,username,password)
Parameter Type Value Required
server String IP address or DNS name of the Valt application server. Yes
username String Valt Username. Yes
password String Valt Password. Yes

Example

valttest = ivs.valt("ivstest1.ad.ipivs.com","admin","admin")

auth

Usage

Connects to the Valt server. This function is executed automatically during initializaton.

Parameters

auth()

This function does not accept any parameters.

Example

valt.auth()

isrecording

Usage

Checks the state of a room and returns True if it is recording, or False if it is not. Returns 2 if an error is encountered.

Parameters

isrecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

if valt.isrecording(4):

getrecordingid

Usage

If the room is currently recording, it returns the ID of the active recording. You should check if the room is recording using the isrecording function prior to getting the recording ID.

Parameters

getrecordingid(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

current_recording = valt.getrecording(4)

startrecording

Usage

Starts a new recording in the specified room.

Parameters

startrecording(room,name,author)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes
name String The name that will be associated with the recording in Valt. Yes
author int The user id under which the recording should be started. If not specified, the recording will be started under the authenticated user. Must be specified as author= when calling the function. See the example below. No

Example

valt.startrecording(4,"My Recording",author=12)

stoprecording

Usage

Stops the current recording in the specified room.

Parameters

stoprecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.stoprecording(4)

pauserecording

Usage

Pauses the current recording in the specified room.

Parameters

pauserecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.pauserecording(4)

resumerecording

Usage

Unpauses the current recording in the specified room.

Parameters

resumerecording(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

valt.resumerecording(4)

WARNING

As of the writing of this article, pausing and unpausing the recording will reset the duration timer for the recording. This may cause issues with inserting markers.

addmarker

Usage

Adds a marker to the recording in progress in the specified room.

Parameters

addmarker(room,markername,color,markertime)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes
markername String Name for the marker in the Valt application. Yes
color String Color for the marker, valid values are white, gray, red, yellow, purple, cyan, blue, green, and orange. If not specified, will default to red. No
markertime int Time index to insert the marker. If not specified will use the current time index. When specifying a marker time, you must also specified a color. No

Example

valt.addmarker(4,"My Marker","green",137)

getrecordingtime

Usage

Returns the current time value of the recording in the specified room. Primarily used by the add marker function to specify the time for the marker.

Parameters

getrecordingtime(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

current_recording_time = valt.getrecordingtime(4)

ispaused

Usage

Checks the state of a room and returns True if it is paused, or False if it is not.

Parameters

ispaused(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

if valt.ispaused(4):

islocked

Usage

Checks the state of a room and returns True if it is locked and False if it is not.

Parameters

islocked(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

if valt.islocked(4):

getcameras

Usage

Returns a nested list, containing details for the cameras in the specified room. Primarily used with the AXIS module to enable/disable privacy mode on cameras.

Parameters

getcameras(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

cameras = valt.getcameras(4)

getrooms

Usage

Returns a list of rooms if successful. Each list item is actually a dictionary containing information about that room.

Parameters

getcameras()

This function does not accept any parameters.

Example

rooms = valt.getrooms()

getschedule

Usage

Returns a nested list of all upcoming schedules for the specified room. The returned list contains the start and end time for each schedule.

Parameters

getschedule(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

schedules = valt.getschedule(4)

getroomname

Usage

Returns the name of the room in VALT.

Parameters

getroomname(room)
Parameter Type Value Required
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database. Yes

Example

roomname = valt.getroomname(4)

getusername

Usage

Returns the name of the user in VALT.

Parameters

getusername(user)
Parameter Type Value Required
user Integer The user number of the user in the Valt application. This must be the actual user ID number, not the user name. This can be obtained from the database. Yes

Example

username = valt.getusername(4)

getroomstatus

Usage

Returns a value indicating the current status of the room. This should be used instead of islocked, ispaused, or isrecording as it also includes better error handling.

Room Status Return Value
ERROR 0
Available 1
Recording 2
Paused 3
Locked 4

Parameters

getroomstatus(https,server,accesstoken,room)
Parameter Type Value
https Boolean True if the server uses HTTPS, otherwise False.
server String IP address or DNS name of the Valt application server.
accesstoken String The authentication token returned by the function valtauth.
room Integer The room number of the room in the Valt application. This must be the actual room ID number, not the room name. This can be obtained from the database.

Example

roomstatus = valt.getroomstatus(True,'valt.example.com','3e2c3e461736ce73830ed8d6d9d5dae6',4)

creategroup

Usage

Connects to the VALT server and creates a user group with the specified rights, templates, retention period, and video access.

Parameters

creategroup(https,server,accesstoken,groupname,infoid,markerid)
Parameter Type Value Required
https Boolean True if the server uses HTTPS, otherwise False. Yes
server String IP address or DNS name of the VALT application server. Yes
accesstoken String The authentication token returned by the function valtauth. Yes
Group name String The name that will be given the to group in VALT. Yes
infoid Int The id number of the information template that will be assigned to the group as the default. Yes
markerid Int The id number of the marker template that will be assigned to the group as the default. Yes
rights List (of strings) All the rights that should be granted to the new group in VALT. No
max_record_duration Int The maximum record duration in minutes. No
rooms List (of ints) Room ids the new group should be granted access to in VALT. No
video_access_users List (of ints) User ids the new group should be granted video access to in VALT. No
video_access_groups List (of ints) Group ids the new group should be granted video access to in VALT. No
retention_type String Retention Type (Valid Values: infinitely, until, days, hours, minutes) No
retention_until String Date formatted as MM-DD-YYYY No
retention_for Int Value in hours, minutes, or days (as specified by retention_type) the video will retained for. No

Example

valt.creategroup(https,server,auth,splitline[0],30,71,rights=rightslist,max_record_duration=180,video_access_users=[14,15,17],video_access_groups=[2,6],retention_type="days",retention_for=365)

Other Functions

log

Usage

Used to to write log entries to a standard central log. This function is used by the valt class. This function writes a time stamp in YYYY-MM-DD HH:MM:SS format before each log entry.

Parameters

log(message,logpath)
Parameter Type Value Required
message string String to be written to the log. Yes
logpath string Local path to the log file. If not specified it will default to ivs.log in the same directory as the executed python program. No

Example

ivs.log("Room 127 Unlocked")

factorydefault

Usage

This function is specific to the use of IVS accessories. The factory default function restores all config files to a template and re-enables the web service. It then reboots the device. This function is currently only supported on the IVS Keypad and IVS Card Reader.

Example

ivs.factorydefault