Telegram bot integration #787
Replies: 3 comments 8 replies
-
Skimmed through the code and it looks great, really cool with the PTZ component!
It would be great if the PTZ component was decoupled from telegram and maybe exposes its functionality to other components.
That is available already through the MQTT component so you could do something similar to that.
Making it a storage tier is hard since the current implementation is based on listening to file system events, so that would have to change to some other approach for that to work. PS: If you want to open a PR with your changes it would be easier for me to give some comments on your code and see if there are better ways to do things. I am impressed you have figured out so much on your own since the developer docs are not great yet! |
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back to me! I have to say I've been having a lot of fun developing. You must have invested a lot of time getting this to where it is. It's really impressive. The choice for the devContainer setup is excellent and the code, though complicated, is a delight to work with. Having the devContainer up and running with all the tools exactly right meant I could just set a breakpoint and start figuring stuff out within a couple hours. This makes up a lot for not having developer docs yet. I'm often tempted by open source software to dive in and hack my desired features into it, only to then be daunted by a week of "what the frick"-filled nights trying to get the development environment and pipeline running, after which I lose interest and have probably been tempted by something else. The only issue I had was with the /config mount point. I'm not sure why it fails for me. When I remove it, the devContainer builds without issue and purs like a kitten. Not having the config in the repo works fine for me. Let me know if I can test something for you there. When I re-enable the mount and rebuild the devContainer I get this error: This is the salient bit from the logs I see when I go into the recovery container:
Remove the mount point, rebuild, and poof I have a working environment again. About issues. There was one more. When I came around to committing my code - I am unfamiliar with VS Code, so I thought I'd try the builtin interface iso the command line - the commit would just hang forever. After a couple of what the fricks I found that it was due to tests failing and that using git from the terminal does work and outputs the test results. Anyway, this might be worth mentioning in the developer documentation. Another thing you could mention, for slower people like me, is that though your tests are strict and they need to pass the pre-commit hook, you don't have to necessarily perform them before you commit to your own branch on your own fork. I had about an hour of going "why are these checks so strict!? I just want to push my code for safe keeping and versioning!" before I thought "hold up, there's probably a way to skip them". That being said, I have kept it enabled on every commit, because it's forcing me to be more thoughtful of my code. The developer docs could also make note of how to mitigate the various checks/tests/linters' oft reported problems or provide links to their documentation for clarification or mitigation. E.g. I'm unfamiliar with the various checkers' reports so knowing you can do
from the dev-docs would be nice. Or what the guidelines are for including stuff in .mypy.ini:
I can't imagine you've setup all these tests just to have them by passed :D Now, as for you answers. Decoupling PTZ from Telegram sounds like a good idea. Having PTZ in the UI would be awesome, but developing for the UI is a bit daunting at this point. I'd rather spend some time familiarizing myself with the python code first. Like, how do I decouple these things and have them consumable from both the UI and a Telegram component in a way that makes sense? Any code I could look at to get an idea? I will have a look at that library of notifiers and see if I can integrate it. For now I've taken out the SMTP notifier. Maybe I'll create an AbstractNotifier and override a couple implementations that make sense. While browsing the code I did already find the I do also get some errors with regard to a clip_init.mp4 file that can't be found by the fragmenter in the segments folder. I'm not sure if that started when I enabled the create_event_clip, but I can imagine it does. I had been looking into that, but at that point it was 07:00 and I was starting to fall asleep. Waiting for a single EVENT_RECORDER_COMPLETE event sounds like it's more efficient going through all the state changes. I will look into that. I'd read in one of the issues or discussions that you'd implement start/stop in MQTT already, so was looking into that too, but was having some difficulty understanding how I should implement it. Specifically how to get an instance of the Camera (?) object that implements the turn_on() and turn_off() methods. I've not looked into this much, yet. If you could point it out it would save me some time. I'll put "backup to cloud" on my list too because I'd really like to have that feature myself. I'll open a PR for this. Just wanted to make sure first you'd be open to accepting it :) One last question. How would I go about getting my devContainer to run with CUDA enabled? Is it as simple as changing the devContainer's base image? |
Beta Was this translation helpful? Give feedback.
-
This is where the fragmenter fails, btw. I tried skipping clip_init.mp4 in here and it "solved" the problem (i.e. made the error go away), but I can't imagine it's a proper fix.
|
Beta Was this translation helpful? Give feedback.
-
Hi,
Last week I bought some security cameras and was not satisfied with the capabilities of the app that came with them, so I decided to look if they used open standards and, yes, they did. I decided to look for a tool with which to connect to them and get their feeds on my PC, so I could do with them exactly what Viseron - which I did not know about - does. I then came across Viseron.
Now I have much better GPU accelerated object detection and I can record to my PC, which is way better.
And then I thought, Viseron does not offer some of the stuff the app does. Like sending notification when objects are detected. Or panning and tilting the camera. And other stuff. So, I decided to build them, and I have to say the experience has been wonderful, so far.
Apart from something weird in the devContainer when first starting it (I don't know why/what's going wrong, something with the config mount), and fighting my way through the many very strict checkers before I could commit (and later realizing, I could just skip them), development has been a breeze. The devContainer with everything ready to go is a wonderful invention.
I digress. The code:
https://github.com/smelis/viseron/tree/ptz-and-notifier
This is a work in progress. There are glaring holes, bugs and design issues. Switching cameras while patrolling? Nope. Notifier? Doesn't work anymore, because I messed it up trying to wrap my head around re-using camera configs. In any case, it's a start and should give an idea of the functionality it will eventually provide.
My ideas for further refactoring, features, fixes:
1. remove smtp notifications (make separate component, maybe, if someone wants it)2. combine telegram notifier and telegram ptz controller in one package "telegram"3. have ONVIF camera definitions extend AbstractCamera class and schema? (??)
4. entirely unsure if my asyncio magic is correct
5. ONVIF camera instance (+separate into class, extends AbstractCamera?) per camera instead of switching between them6. custom Telegram keyboard for P/T/Z controls (and other commands)
7. implement recording on request8. add stop/start camera command9. Limit who can use the bot https://github.com/python-telegram-bot/python-telegram-bot/wiki/Frequently-requested-design-patterns#how-do-i-limit-who-can-use-my-bot
10. Can't test if zoom works
11. patrol only pans, add tilt (swing->Lissajous curves?)12. stop patrolling on object detection
13. object tracking
14. completely unrelated, but since you're working on tiered storage: was going to build a "upload to google drive" component, but should probably be a storage tier?
I have tonnes of questions and am open to suggestions for features or otherwise.
In any case thanks for the code!
Beta Was this translation helpful? Give feedback.
All reactions