Conditional gate opener


(Gian) #1

Hello All,
I would like to use a Raspberry, connected to an USB relay, to let a specific group of users open the gate with a phone call to a dedicated number.
Basically, FreePBX should always reject the call (so callers do not incur in costs), and activate the relay only if CallerID is listed in a phone directory.
Maybe this has already been done before? I Googled, but didn’t find.
Thanks for your advice,
-Gian


#2

Is the Raspberry also your FreePBX?


(Gian) #3

yes, it would be setup for this service only.


#4

I suggest you need an AMI client, perhaps look into something like

(there are others) and the raspberry culture is replete with mqtt example. I touched on it here

and here

(not for the faint of heart though :wink: )


(Gian) #5

thanks, Dicko, I will check it.

What I was thinking was something like, a tail command waiting for an inbound call, assign CID number to a variable, and lookup for it in a database table. If found, trigger the relay.


#6

Unfortunately the DID is first apparent in “from-trunk,6” but you then need to consume the log lines until you get to the CallerID, then you can do what you want, AGI is a little more coherent and hooks well into a mqtt pub event (your door lock should be watching the mqtt sub events).
Mysql asteriskcdrdb/cdr table is very coherent and a trigger on write will do that for you, but it is exceedingly hard to have mysql run a system command, you can export into a file in /var/lib/mysql and have an incron job watch it, but that gets a little byzantine. Or conversely and a little simpler have your incron job just watch for a CLOSE_WRITE on /var/lib/mysql/asteriskcddb/cdr.ibd and ‘poll’ for the last src/dst event that makes sense.

Good Luck though :wink:


#7

If the pi is the freepbx box then it could be only a few lines of dialplan in extensions_custom.conf , either as an extension or context.

IF there is no other need for the phonebook module, use it to manage the allowed CID list.

Google for diaplan execif (for conditional execution), dialplan db_exists (to check the database for CID), dialplan system (to run an external script to activate the relay…


(Gian) #8

yes, Jerrm,
I was thinking of a way to blacklist ALL, but some numbers.
Thank you very much for your help.
Regards,
-Gian


(Lorne Gaetz) #9

There’s a whitelist project described here: Of Robocalls and Whitelists

Once you’ve qualified the caller, send them to a Custom Destination with some dialplan that opens the door.


(system) closed #10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.