-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a new unifi-protect
node
#48
Conversation
…available - for the host.
I needed to put back: `valueExpression?: undefined` as checking this value later returns valueExpression does not exist.... but it must not be set if hasDuration is true
@Shaquu @crxporter Please review the last commit.: 3bf7a97 The Web socket reconfiguring after a new update ID has been fetched - usually triggered by the 30 minutely re-login that occurs in the access controller. A recovery after a network connection drop. |
All comments have been addressed. This becomes a problem if an update means new config params are added - as they will be Users just need to open up the config node and save to apply a value of 0, 0 sets timeouts to use defaults (90000/15000). Bootstrap is now a type ( Lastly, my PR is based on the Main branch, since switching to dev - the PR brings in changes that were not apart of the dev branch. |
* Add a new `unifi-protect` node (#48) * Update publish to use Node 14 (#50) * Update package.json * Beta 2 (Dev 1) (#53) * Update Deps, Fix Duplicated Cams (hopefully), 2 new events (Boiler plate) * Cleanup + Add Alarm * Small typo * Renew Package lock and small bump to WS type * Keep it pretty! * Address comment #1 * Add Event slit * Add topic (Camera Name) * Small optimisation * Improve protect status (#56) * Add better status logic * Fix status logic * Add custom port for WS * Dev 2 * Update package.json --------- Co-authored-by: Tadeusz Wyrzykowski <shaquu@icloud.com>
@crxporter @Shaquu
Below is what I have built and is ready for review.
self.bootstrapObject
self.protectSharedWS
This has 2 important methods
registerInterest
degisterInterest
unifi-protect
node - that allows controlling and listening for camera eventsself.bootstrapObject
andself.protectSharedWS
are only instantiated if the bootstrap was successfully retrieved.the Protect node will warn the user if a Protect instance was not found.
I issue a
501 - Not Implemented
when the node is trying to obtain the cameras.unifi-protect
will call intoself.accessControllerNode.protectSharedWS?.registerInterest(self.id, I)
self.accessControllerNode.protectSharedWS?.degisterInterest(self.id)
accoridngly, i.e when such node is deployed and removed
Each event type is based on an
EventModel
shapeProfile
Is the object that is designed to match (at least) the incoming payload (it uses
lodash.isMatch
)metadata
Is the settings/behaviour for that event. the HTML file uses the
metadata.id
to subscribe to that event (supports multiple)some models have a
valueExpression
property and this uses JSONata to extract a value from the payload and passes it on to the user (aspayload.value
)- these do not support a duration (hasDuration: false
) as these are more a constant value change as opposed to an on going eventThe combination of
hasDuration: true
with avalueExpression
is marked as invalid in the typescriptLastley, there is
thumbnailSupport : enum
and this states whether or not a snapshot is supported with this event.the
motion detection
event for example, does not seem to produce a snapshot in my early testing.Below is the
thumbnailSupport
enumThere is
snapshotAvailability
in the payloads to identify to the user the readiness of a snapshot, a 2nd pin is used for delayed snapshots - with the associated event idhttps://github.com/marcus-j-davies/node-red-contrib-unifi-os/blob/protect-node/src/EventModels.ts
Some areas may have room for improvements of course, such as creating a new access controller, from within a protect node, it will try and call into the bootstrap before the bootstrap has had a chance to be fetched by the controller (it does this to fetch the cameras using an HTTPAdmin endpoint
they will get a
501 - Not Implemented
because the bootstrap has not yet been received.But other than delaying this request (for new controllers being spawned) - not sure how else it can be achieved, as waiting will add some delay to the cameras being listed.
For already running access controllers - this is not a problem (as the Bootstrap is ready before hand), that is if Protect is running on the target hardware of course else 501