bkbilly / asterisk_call_status

☎️ Connects to Asterisk and reports the status back to Home Assistant.
MIT License
8 stars 3 forks source link

Extension Status #1

Closed conrad66 closed 3 years ago

conrad66 commented 3 years ago

Good afternoon! Is it possible to get Extension Status ?

bkbilly commented 3 years ago

The extensions are already displayed. Could you explain more what you need with an example?

conrad66 commented 3 years ago

For example, I have an extension 111. I would like to get its status and, after switching from the InUse state to the Idle state, perform an action in the home assistant. The status of ensten is described here: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerEvent_ExtensionStatus

bkbilly commented 3 years ago

This is already being done, but in a more complicated way. Everytime an extension status changes, it sends an MQTT event to the broker. The inUse that you mention is the Up, or Ringing and the idle is when it doesn't exist. You can see an example of some events taken from my Asterisk server which are sent to MQTT broker.

 idle
 XXXXXXXXXX->Grandma [voips.modulus.gr (Ring)]
 XXXXXXXXXX->Grandma [voips.modulus.gr (Ring), 541 (Ringing)]
 XXXXXXXXXX->Grandma [voips.modulus.gr (Up), 541 (Up)]
 idle

I am guessing that you may want to have a separate MQTT topic for each extension with it's status?

conrad66 commented 3 years ago

Please forgive me for my google translator.... I want to get the status of the end of the conversation on a certain exten. Perhaps separate MQTT topic for each extension with it's status will solve the problem. But right now I can't get the idle status if another exten is busy. If there is a conversation on another exten, I will not know that the conversation I need is over. p.s. Or I just don't know how to analyze a topic with the help of home assistant, for example, this: Project_2->100 [spa2 (Up), sp1 (Up)], Project_2->2222 [spa2 (Up)] I want to know when Project_2->2222 [spa2 (Up)] will end the conversation. Expect when the exten I need disappears in the topic ?

p.s.s. I made a binary sensor with a regular expression tracking the required exten. Everything works. Thank you for the tips.

- platform: template
  sensors:
    domofon_call_status:
      friendly_name: "Domofon call status"
      value_template: >
        {% set asterisk_status = states('sensor.asterisk_call_status') %}
        {{ asterisk_status is search("5758->dial1 \[beward \(Up\)\]", ignorecase=true) }}
bkbilly commented 3 years ago

Thanks for sharing your implementation, it's very helpful!

I am going to close this issue because it's solved.