No one has ever described me as a JavaScript expert. I’m quite happy about that. Herein we’ll document the Functions API, which is accessed by you with JavaScript, but which is implemented in Swift. For the sake of providing an unambiguous reference for each aspect of this API, all of the types will be described in Swift. If JavaScript had wanted unambiguous documentation, it would have provided anything resembling a meaningful type system.
Note: This page is all about the Functions API. You may want to start with a high-level overview of Functions, which you can find here.
func streamieMain(_ buttonName: String, _ buttonValue: String)
Function execution begins with the streamieMain() function. Passed to this function is the name of the button the user pressed, and the value of that button. This is all set by you in the Function configuration.
vContext
is a global variable that provides important context to the execution of your Function and it provides access to all of the other data configured in your Function.
func log(_ message: String) -> Void
vContext.log(“Something important!);
The log() function writes a message to the console. You can see the console when running the Function manually: when you use the “Run Test” button or any of the buttons you’ve defined on the Function, the console window will appear automatically.
func alert(_ message: String) -> Void
vContext.log(“This is a message to be shown to the user.”);
The alert() function will use a UIAlertController instance to display a message to the user. This is only true in some contexts, such as when the user manually triggers the Function. If the Function is triggered by a motion event, or by a remote control event, the alerts are not displayed to the user.
func paramValue(_ key: String) -> Any?
const cameraId = vContext.paramValue(“cameraId”);
if (typeof cameraId === ‘string’ && cameraId !== null) {
// …
}
The paramValue() function provides contextual information related to the execution of the Function. For instance, if the Function was triggered by a Camera Action, the ID of the camera (“cameraId”) is set as one of the param values on the context object so that your Function can understand why it was triggered.
listOfCameraIds() -> [String]
listOfCameras() -> [Camera]
listOfServers() -> [Server]
listOfMembers() -> [Member]
listOfFunctionsAndButtons() -> [FunctionAndButton]
cameraWithName(_ name: String) -> Camera?
cameraWithIdentifier(_ cameraId: String) -> Camera?
memberWithName(_ name: String) -> Member?
func createFetchRequest(_ url: String, _ method: String) -> StreamieFetchRequest
func fetch(_ callback: JSValue) -> Void
The fetch() function calls the callback with the StreamieFetchResponse when the request is complete.
const url = ...;
const request = StreamieFetchRequest.createFetchRequest(url, “GET”);
request.fetch((response) -> {
// …
}));
var code: Int { get }
var body: Data? { get }
var identifier: String { get }
var name: String { get }
var addr: String? { get }
var port: Int { get }
var username: String? { get }
var password: String? { get }
func getRtspUrl(_ callback: JSValue)
var identifier: String { get }
var name: String { get }
func write(_ data: StreamieFetchResponse, _ path: String, _ file: String, _ callback: JSValue)
var identifier: String { get }
var name: String { get }
func control(_ command: String, _ option1: String?, _ option2: String?, _ option3: String?, _ callback: JSValue)
func runFunction(_ lambdaAndButton: FunctionAndButton, _ option3: String?, _ callback: JSValue)
var lambdaId: String { get }
var buttonId: String { get }
Created: 3 months ago
Updated: 3 months ago
Author: Curtis Jones
Streamie provides a best-in-class user experience on your iPhone, iPad, Apple TV and Apple Silicon Mac, with an intuitive user interface that makes it simple to discover, stream, record, monitor and share your HomeKit, Google Nest, Ubiquiti UniFi Protect and ONVIF-compatible IP and RTSP cameras. Streamie keeps you informed with motion event notifications and it works with most cameras using its advanced audio and video codec support. You can watch your cameras from anywhere, record 24/7 to your private NAS, remotely manage multiple locations, device permissions and seamlessly synchronize settings across your devices; configure Hubitat smart home automations, live stream to YouTube and rely on the in-app technical support system when you need help -- and you can also reach us by phone. Download Streamie today for all of your CCTV needs.