TECH7Fox / asterisk-hass-addons

Asterisk add-on for Home Assistant
https://tech7fox.github.io/sip-hass-docs/
MIT License
72 stars 26 forks source link

REQ: Push gateway #103

Closed pergolafabio closed 1 year ago

pergolafabio commented 2 years ago

Guys, would love to see an addition to have a PUSH gateway extreme usefull if we use softphones with this asterisk addon, so it wakes up devices using PUSH

this is a great project: https://github.com/BelledonneCommunications/flexisip

would be great if it could be added or maybe as a saperate addon:

https://github.com/BelledonneCommunications/flexisip

nanosonde commented 2 years ago

But doesn‘t this require to a have special accounts from Apple and Google? flexisip integrates with Apple APN and Google GCM AFAIK.

https://new.linphone.org/news/flexisip-proxy-now-ready-apples-new-push-notification-system

https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/HOWTOs/Push%20Gateway/

pergolafabio commented 2 years ago

Don't think so, you can create those projects on Google actions site...not 100% sure

nanosonde commented 2 years ago

So from what I understand this asterisk project aims at providing intercom at home. With the SIP based doorbell for example.

On the other hand one could use HA companion apps notification to signal an incoming call and then open a webview with the SIP card to establish intercom.

For my smartphone I will probably just use one of the well-know SIP clients like Zoiper or Bria Mobile and use their Push Notification for VoIP stuff together with an additional SIP provider in the internet to forward a call from asterisk to this SIP provider that my smartphone is registered with.

pergolafabio commented 2 years ago

I mainly use it for door intercom The HA-SIp is nice, but i dont use it anymore for now, still havent found a good way to combine the HA-SIP card with softphones, it just doesnt work, i cant call an conference togeteher with softphones...

there are indeed softphones that uses their own push server, thats why would be nice that we have our own push server with the asterisk addon

TECH7Fox commented 2 years ago

So from what I understand this asterisk project aims at providing intercom at home. With the SIP based doorbell for example.

Yes, that is exactly what I'm aiming for. To call between your HA tablets. But the project grew and became more popular than I thought so now I'm also focusing to use it to call your doorbell, even with your phone when your not home. Which is hard because of security, certificates, mobile, codecs etc. So using a softphone app could be easier, or your only option depending on your situation.

On the other hand one could use HA companion apps notification to signal an incoming call and then open a webview with > the SIP card to establish intercom.

Yes, you can also set a extension in the url to call once the card is loaded, so you can just click on the notification to connect to your doorbell (which is parked or in a conference or something).

Anyway, I will look at the flexisip project and try to implement it. But could take a while. (currently working on the integration)

pergolafabio commented 2 years ago

Thnx, no hurry :-)

Would be a great addition though, makes it complete

nanosonde commented 2 years ago

I read a bit further about flexisip push notifications and how it works on iOS and Android. At least for iOS it is not easy and cheap. You must have an Apple Dev Account to be able to get a VoIP services certificate for use with the APNs. Those certificate signed by Apple have to be used by flexisip to be able to use Push Notification on iOS for VoIP applications. Even for normal push notification you need to have a certificate signed by Apple. I am not sure if you get those certificates signed by Apple as a normal Apple Developer with the "individual" plan for 99USD/year. Further details here: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns

https://wiki.linphone.org/xwiki/wiki/public/view/Flexisip/Configuration/Push%20notifications/#HConfiguringforeachmobileplatform

Also I think there is a misunderstanding about flexisip, push notification and softphones on mobile platforms.

Let me cite this: "PushNotification module allows Flexisip to wake a liblinphone-basd application up when a chat message or call invite cannot be delivered because the application is unavailable. This feature has become crucial since mobile OSs got used to making the application to hibernate in order to save power. Today, Flexisip supports native push systems of Android, iOS and Windows Phone ; but can also delegate the work of sending the push request to a tier service using HTTP GET API." (from here)

So flexisip with push notifications onyl works with liblinphone-based apps. It won't work with Zoiper or Bria Mobileor other VoIP apps for example. They have there own server solutions with push notification support.

Do you know any good liblibphone-based apps except the linphone and the linhome app itself? I tried it and I was not satisfied with it. The linhome which claims to be a good solutions for SIP-based doorphones with video does not work stable either. However, they support early media during ringing with video. I tried it.

nanosonde commented 2 years ago

Push notifications is basically a permanent encrypted TCP connection to Apple or Google servers even when the device is sleeping. So your server side has to register with Apple and Google servers to send push notifications in a generic way. However, more important your corresponding app must also be known to Apple/Google APNs.

You cannot wake up a "foreign" app from your server via APNs.

pergolafabio commented 2 years ago

yeah , its a diffcult thing

i wasntr aware that flexisip only worked with linphone/linhome only But i was looking for more then a year for a good softphone client

The biggest problem is indeed early media, it works for most softphones, but PBX are not able to send early media to ring groups... early media only works on 1-1 call... but quite useless then

I have finally found a good app, where you can specify an RTSP stream manually as early media (preview) The code is bases on linphone sources:

https://play.google.com/store/apps/details?id=com.basip.app

i use it, works perfect, they use their own push service, but you can specify another like flexisp

{"network":{"transport":"udp","stun":"stun.l.google.com:19302"},"account":{"number":"XXXX","host":"sip.bas-ip.com","name":"Indoor Station","password":"XXX"},"push_server":"http:\/\/push.bas-ip.com"}

quite easy to change the push server there

nanosonde commented 2 years ago

Interesting, I also tried this app on iOS: https://apps.apple.com/de/app/bas-ip-intercom/id1267232886 I had some problems with the RTSP streaming though. Maybe I will give it another try.

My educated guess concerning the realisation of push notifications within this app is that they just use "local push via websocket" as the HA companion apps do it. See local push: https://companion.home-assistant.io/docs/notifications/notification-local/

The push server seems to use only HTTP and not HTTPS. Have you tried sniffing the traffic?

But again I think that BAS IP push stuff will also only work if you use a SIP account on their server.

pergolafabio commented 2 years ago

Yeah, I use their PBX server now to test... Works perfect, but the option to use another push server is indeed hidden in the app I think, but with that XML, you can override it I think, you can just use that XML to fetch the config, instead of manually inserting the sip configuration...

Not tested yet, but the push url must be there for a reason

felipecrs commented 2 years ago

I would say that anything which goes against using Home Assistant as a client is discouraged for the project.

If HA (web or mobile) does not work as good as other SIP clients, I think we should instead focus in trying to improve it to make it work as good as.

That's my 2-cents.

pergolafabio commented 2 years ago

Hmm, I see it as 3 seperate modules... Asterisk / integeration / client...

I mainly use the first 2 because my hardwares (indoor stations) are customized, I can only run some APK on it .. Only possible with softphones...

As for calling purposes externally, I think softphones is better .. For internal tablets , with android, dedicated for HA Lovelace, then indeed the ha-sip is a good solution