neilenns / node-deepstackai-trigger Goto Github PK
View Code? Open in Web Editor NEWDetects motion using Deepstack AI and calls registered triggers based on trigger rules.
License: MIT License
Detects motion using Deepstack AI and calls registered triggers based on trigger rules.
License: MIT License
It's kind of annoying to see connection refused errors when doing development against this, since webRequest tries to make an actual HTTP call.
This isn't a problem for MQTT because a little MQTT server is running as part of the development docker stack.
Is there a tiny Docker container that exists with a super tiny web server on it that could be used? Is there a way to easily mock the call out to avoid the connection refused error in logs?
It's apparently a thing.
Lint all the things.
Italics is too hard to read. Dumb change. Change them all back.
README.md is way too long. Move content over to the wiki in preparation for also explaining how to set up Blue Iris.
There are quite a few places in the code where try/catch blocks with let
variables just outside the try statement can be replaced with the cleaner .catch()
method for handling errors.
There's nothing in the readme about having to set TZ in the docker-compose.yml file. This is actually super important since without it all of the time checking around images doesn't work.
Oh good grief ๐คฆโโ๏ธ
All of the schema and sample files need to have their $id and $ref properties updated to point to this repo.
If MQTT is enabled but the configuration wasn't changed from the sample then the container will fail to come up because MQTT can't get connected.
This is a bad first user experience. MQTT should be opt-in.
Simple change to comment out one line in the docker-compose.yml file after #18 is fixed.
How on earth did this ever run? It looks like it's validating for MQTTManager, not MQTTHandler in the trigger file. Why did this ever work???
Stupid mistake when I switched from try/catch to .catch(). This should return silently not throw an exception.
This defaults to 0 in the schema but that violates the exclusiveMinimum requirement (if you specify a cooldown time it has to be non-zero.
Only include extensions required for code hygiene. There's a bunch that don't strictly have to be there:
Double-check and make sure there aren't other ones that should be included too
So the receiver knows which image was used and could use the image for other purposes.
src/
must roll the version number and update CHANGELOG.mdAdd a CONTRIBUTIONS.md file with:
It's suuuuuuuper noisy without a separate cooldown timer for Telegram timers. Easy enough to add the value to the schema and plumb it through. The fun part will be managing it in TelegramManager
.
It will likely require a map, key is the trigger name, value is the last trigger date. Then it's the same logic as in TriggerManager.
All the trigger handlers should support the enabled
property. It's dumb that there's now three separate classes that have enabled
and all have the same default value behaviour in the constructor.
Generics to the rescue I think. Make a base class. Use generics to handle the partial object creation.
Originally the thinking was to only include extensions in the devcontainer that are required to enforce style/lint rules.
After installing this from scratch a few times it's really annoying that it doesn't also auto-install Git Pull Requests & Issues.
Right now if someone puts "Dog" in as the label it won't match any of the returned values from DeepStack AI. Simple fix to guard against this: convert all labels from the incoming JSON into lowercase before adding them to the trigger.
Array.map() to the rescue again!
The trigger.config and mqtt.config properties will show documentation as you type if edited in VS Code but people shouldn't have to run VS Code just to find out what the various settings are.
Add some tables to the readme that outline all the properties.
I'm not sure this will work for mqtts:// at the moment. I think at a minimum there needs to be the ability to set rejectUnauthorized: false
in the mqtt settings file and then pass that into the options object on connect.
The logging messages were designed to be easily formatted in the VSCode output window. There's a way to do this using language service features, I think via a package.json extension, but I can't for the life of me find the page that described it.
Dig into this to figure out how to highlight lines in the output window.
This will probably require modifying the loggers to include info, warn, and error (which should be simple since they are all contained in the Log.ts file for this very reason).
https://www.npmjs.com/package/telegram-bot-api
This shouldn't be too bad, it'll follow the exact same pattern as MQTT. I've personally never used Telegram though so I have no idea how to test this or how to have it work cleanly in the dev container.
No need for it to be instantiated as a class, it's no different than the other MqttManger or TelegramManager
The project's been designed from the start to work in Remote - Dev Containers and, in theory, Visual Studio Codespaces.
Currently this is blocked by several Codespaces issues as the base image is node:alpine
.
In theory once those two issues are resolved by Microsoft this should Just Work as a Codespace. Try it out and see. If it doesn't work open bugs here (if it's an issue in the project) or against Microsoft (more likely reason ๐).
Easy enough.
This reminds me it's in the wrong folder. The file should move to handlers/webRequest.
Right now if you just clone the repo and run docker-compose up
you have to use local IP addresses, rather than domain names, to access machines on the local network (e.g. a BlueIris server, MQTT server, etc.)
It would be nice to figure out how to enable this, and:
Docker Desktop for Windows and Mac both default to Google DNS resolution. Maybe that's all that's necessary to change?
npm version
fails with errors because VSCode by default runs as root in devcontainer.json
.
Too risky/confusing to have this with different contributors. Tags should only be created manually, after something's merged to master.
Now that the repo is public a public Docker image can be created and linked to the sample docker-compose.yml.
It didn't get updated when the change went in to include basename and fileName.
Right now no client ID is specified in the MQTT connection request so it's auto-generated by the underlying library.
It'd be better to set it to "node-deepstackai-trigger".
The DeepStack API returns a bounding box for the detected object. If the object is one that's supposed to trigger (based on class), there should be an optional secondary check on whether the rectangle intersects at all with a list of defined exclusion zones in the trigger's configuration.
This will enable blocking out parts of an image that are prone to false positives.
In CHANGELOG.md, the latest version specified is 1.1.3.
However, according to package.json and package-lock.json, the current version is 1.1.2.
When I run 'npm version patch', it creates the version 1.1.3. Just wanted to clarify if the current version needs to be 1.1.3 as I am creating a pull request for an updated version.
fsevents causes issues when doing webpack in the docker container because it's an optional component in chokidar (only needed on Mac). I couldn't find any better way to resolve the issue than this.
Is this really the right way to do it?
Docker Desktop doesn't show timestamps in the log so it's hard to tell what's going on. Add a timestamp in short date/time format to the front of all log messages.
Should be a simple change in Log.ts.
On a fresh pull from git the containers don't have any of the npm packages installed so F5 fails.
Easy fix: add npm install
to postCreateCommand in devcontainer.json:
That's the whole point to this project. There should be a specific readme on how to get this set up with Blue Iris, including how to configure a single camera. Reference The Hook Up for the walkthrough on how to configure the cameras.
Module not found: Error: Can't resolve 'utf-8-validate' in '/home/node/app/node_modules/ws/lib'
Whyyyyy?
The JSON schema is nice but still requires you to know ahead of time what each of the items are to type.
It'd be nice to have a VS Code snippet that people could add to user snippets that would auto-insert a trigger blob and tab through to all the different values.
Info on how to write snippets for VS Code is here: https://code.visualstudio.com/docs/editor/userdefinedsnippets
Commenting out the mqtt secret in docker-compose.yml should be sufficient to disable MQTT. I swear I fixed this bug before but it looks like the code changes didn't get checked in.
The problem is in how handlers/mqttManager/MqttManager.ts throws an exception when fsPromise.readFile() fails. The reality is this shouldn't be an exception, it should just log and return null. Then farther up the chain can check for null and just return quietly.
This is the offending exception that should log and return null instead: https://github.com/danecreekphotography/node-deepstackai-trigger/blob/e5234b1c7a917ab060135456664085477a6edef5/src/handlers/mqttManager/MqttManager.ts#L90
This needs to check for a null response and return quietly: https://github.com/danecreekphotography/node-deepstackai-trigger/blob/e5234b1c7a917ab060135456664085477a6edef5/src/handlers/mqttManager/MqttManager.ts#L25
Sometimes files are in italics, sometimes they're in code block format. Pick one.
It constantly conflicts with eslint and prettier. Not worth the hassle.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.