Im totaly new to FreePBX and since im trying to solve my problem i have allready read a few post about that but non of them really helped me out and that is why I decided to write a new post. Please if this has been answered somewhere else already, feel free to delete the post an please link me to the solution.
So my goal is to open my doors with two RaspberryPiās, where one acts as a internal unit where the FreePBX is installed (acts as Host and Client at the same time) and the other one as outdoor unit where Linphone client is installed and registered to the internal Host. The whole Process of registration and calling is finished, meaning Im able to press the button on the outside unit and make a call to the indoor unit.
My problem begins here.
What would be the best solution to open the door. I have a Python Script on the outdoor unit that opens the door so I was thinking to use the System() application function with ssh command on the indoor unit during the call with the DTMF option. But I have no idea where to start how to configure that. There are also Feature Codes and Dynamic Features but I have no clue how does all these work.
Can anyone help please? Your help would be appreciated.
The best way would be to open the door after entering a sequence of numbers. I guess the most complex part would be done on the door phone side. From the point of view of the Asterisk side, you are just sending digits during the call. On the door phone you would need to be waiting for digits and when the right sequence is entered, the opener should be triggered.
In fact there is an example on the FreePBX wiki. Have you taken a look there?
There are very tried and true solutions designed for this purpose. Why are you trying to build your own solution? What are you going to do to let people in when something isnāt working?
IoTā¦very interesting. I newer tough about itā¦but certainly Ill give it a try, perhaps a hint on how do I make Asterisk publish to topic? And then again wouldnāt it be easier and faster if I could just make custom dial plan and use the system() function to send a ssh command to the other RPi? I just donāt know how to accomplish thatā¦
How do I accomplish the TrySystem(ā¦) thing? I mean how does it work? can I start it with DTMF or do i need an extension for it or macro or anything, do I use some custom feature code and when how do I do all that? the point is I want to make it happen during the call, so if I talk to someone and afterwards want to open the door I want to press a number on a keypad and start an action of door opener, I mean I could eventually forward a phone call to an extension thatās has that TrySystem(ssh command) option build in but then again no clue where to start in this directionā¦
You could of course use ssh instead but that is a very round-about way of going from a human pressing a dtmf button to powering a door latch somewhere else on the internet (use ssl if you go that route, mqtt is really quite secure if done properly) , . Use an open access mqtt broker and you can let the cleaning lady in while your at the pub. And it cost you 2x$5 for the pi zeros and another 5 for the relay, add in a few hours of R&D and you ālearned to fish a bitā.
Then learn how to do it with thge AGI library straight to mqtt and there is no messing with the dialplan
or ssh or bash or routing or . . . needed as you can intercept the DTMF in there as needed.
I have tryed the mqtt part without a problem, it works fine. But Im stuck at the Dynamic_Features, I have done the following:
in globals_custom.conf added following:
DYNAMIC_FEATURES = open
in features_applicationmap_custom.conf added following:
open=>*3,caller,Macro,open
in features_featuremap_custom.conf added following:
open=*3
and in the extensions_custom.conf
[macro-open]
exten => s,1,TrySystem(/usr/bin/mosquitto_pub -h test.mosquitto.org -t doorlock -m opensesame)
so the /usr/bin/mosquitto_pub -h test.mosquitto.org -t doorlock -m opensesame works when I run it from cli, but during the conversation if I press *3 I just see on the following output:
Check your usage in current asterisk of the difference between caller,peer,callee. You probably dont want the ācallerā to unilaterally let herself in
that link helped me: https://wiki.asterisk.org/wiki/display/AST/Custom+Dynamic+Features but frankly I have already saw that one before but was to scared to alter the feature.conf and extension.conf and extension.conf files because of early media in the past, and a lot, lot, lot of other stuffā¦and because of the warning on the top āDO NOT ALTERāā¦and so onā¦
The fun Part:
config as above with these two new things that came along:
in the features.con file under applicationmap:
[applicationmap]
include features_applicationmap_additional.conf
include features_applicationmap_custom.conf
open => *3,callee,TrySystem(/usr/bin/mosquitto_pub -h ātest.mosquitto.orgā -t āopendoorā -m āopensesameā)
the callee option is not working, meaning both can open door with *3, but Ill check that laterā¦
in the extension.conf file added at the end of the file:
Set(__DYNAMIC_FEATURES=open)
So next Goal is to create mqtt-python-gpio connectionfor door to open , and after that forward my calls from Asterisk to the internet, so meaning I can answer to the door even from outsideā¦and the rest of the would be the same, only the mqtt broker would be in that case on the insideā¦so I cut down some security issues.
So my next question is how I do it? What is the best practice when it comes to that? I know i can get a free sip account make a trunk and then Im publicly available but if I want to make it free off charge for me I would need a second sip account and register that one on my phone and then these two speak free of chargeā¦but if I want the third oneā¦and so onā¦so what would be alternatives to that?
youāve altered FreePBX module files, which will probably trigger dashboard warnings of altered files, but more importantly will be overwritten when you update the core module. The only supported way to adding features is what you were doing first, as described in this post: