Skip to content
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

Proof-Of-Concept PR: immediate motion detection on S-CAM #142

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

couriersud
Copy link
Contributor

I am creating this PR to document a possible solution for immediate motion feedback via mqtt on S-CAM devices. Earlier information was provide in issue #113.

The code is far from production quality and contains hard-coded values. The purpose is to document all what I have done to get this working.

@darkxst
Copy link
Contributor

darkxst commented Apr 8, 2023

Hi,
Your shell scripts are fine for a proof of concept, however this is not the correct approach to actually implement this.
All of the MQTT handling is in the custom module mqtt-sonoff, so that is where this inotify handling should go. This program is a C daemon, which you can't integrate it with the busybox inotify daemon. Which means this needs to be done in C.

All of the code for handling motion events is already in there, so would only need to implement the inotify part of it and disconnect the current sql trigger. You would probably need to create a new thread to monitor for inotify events, which can then call the existing callback for motion events.

Do you have any experience with C programming? happy to give some pointers on how it might be implemented if you want to have a crack at?

@couriersud
Copy link
Contributor Author

I started programming some 40 years ago :-) The limiting factor is quality time. I have thought about your proposal. Busybox inotifyd source has all the code needed to plug into mqtt-sonoff. Due to limited time I needed a quick solution to get this going and wanted to document the basic approach.
I'll put the mqtt-sonoff changes on my todo list.

@roleoroleo
Copy link
Owner

roleoroleo commented Apr 11, 2023

I will add the inotify code to mqtt-sonoff daemon.

@roleoroleo
Copy link
Owner

Do you want to try this binary?
To activate inotify mode you need to set MQTT_IPCSYS_DB=2
immagine

mqtt-sonoff.tar.gz

@couriersud
Copy link
Contributor Author

Excellent :-)
Works like a dream.

@roleoroleo
Copy link
Owner

Good.
I will commit the code.

@roleoroleo
Copy link
Owner

Please test the pre-release:
#144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants