ha-plugins icon indicating copy to clipboard operation
ha-plugins copied to clipboard

settle time, from automation

Open catohagen opened this issue 1 year ago • 3 comments

Hi

I added an wake-up alarm feature to my inhouse analog phone system. So each line or room can call into home assistant and set a time, when this time is reached, a service call is made and it calls the room over and over until you pick up..

But when you pick up this call....there is this delay of maybe 2 seconds before you hear the TTS... I have tried with or without "settle_time" and it seems to make no difference set to 0, or 1 or 10....gives same delay

here is the service call :

data:
  addon: 8cd50eef_ha-sip-next
  input:
    command: dial
    number: sip:[email protected]:5060
    ring_timeout: 15
    settle_time: 0
    menu:
      language: en-GB
      message: >
        {% set hours = states('input_datetime.set_alarm_time_port01')[0:-6] %}
        {% set mins = states('input_datetime.set_alarm_time_port01')[3:5] %}

        { hours }}:{{ mins }} This is an automated alarm. Dial 1 to disable this service. 
      choices:
        "1":
          message: |
            Stopping service
          action:
            domain: automation
            service: turn_off
            entity_id: automation.sip_port01_handset_alarm
          post_action: hangup
    webhook_to_call:
      call_established: sip_call_established
      call_disconnected: sip_call_disconnected
action: hassio.addon_stdin

is this a bug, or am I misunderstanding the settle_time variable ?

catohagen avatar Aug 21 '24 08:08 catohagen

trying with an mp3 file, incase the TTS cause the delay

data:
  addon: 8cd50eef_ha-sip-next
  input:
    command: dial
    number: sip:[email protected]:5060
    ring_timeout: 15
    answer_after: 0
    settle_time: 0
    menu:
      audio_file: /config/www/sip_call_forward.mp3
      choices:
        "1":
          message: Stopping service
          action:
            domain: automation
            service: turn_off
            entity_id: automation.sip_port01_handset_alarm
          post_action: hangup
    webhook_to_call:
      call_disconnected: sip_call_disconnected
action: hassio.addon_stdin

catohagen avatar Aug 21 '24 08:08 catohagen

logfile after this call :

 default_choice:
|       id: null
|       message: Unknown option
|       audio_file: null
|       language: en
|       action: null
|       choices_are_pin: false
|       choices: null
|       default_choice: null
|       timeout_choice: null
|       post_action:
|         action: return
|         level: 1
|       timeout: 300.0
|       parent_menu: *id001
|       cache_audio: false
|       wait_for_audio_to_finish: false
|     timeout_choice:
|       id: null
|       message: null
|       audio_file: null
|       language: en
|       action: null
|       choices_are_pin: false
|       choices: null
|       default_choice: null
|       timeout_choice: null
|       post_action:
|         action: hangup
|       timeout: 300.0
|       parent_menu: *id001
|       cache_audio: false
|       wait_for_audio_to_finish: false
|     timeout: 300.0
|     post_action:
|       action: hangup
|     parent_menu: *id002
|     cache_audio: false
|     wait_for_audio_to_finish: false
| default_choice:
|   id: null
|   message: Unknown option
|   audio_file: null
|   language: en
|   action: null
|   choices_are_pin: false
|   choices: null
|   default_choice: null
|   timeout_choice: null
|   post_action:
|     action: return
|     level: 1
|   timeout: 300.0
|   parent_menu: *id002
|   cache_audio: false
|   wait_for_audio_to_finish: false
| timeout_choice:
|   id: null
|   message: null
|   audio_file: null
|   language: en
|   action: null
|   choices_are_pin: false
|   choices: null
|   default_choice: null
|   timeout_choice: null
|   post_action:
|     action: hangup
|   timeout: 300.0
|   parent_menu: *id002
|   cache_audio: false
|   wait_for_audio_to_finish: false
| timeout: 300.0
| post_action:
|   action: noop
| parent_menu: null
| cache_audio: false
| wait_for_audio_to_finish: false
| 
| 10:49:10.386042 [1] Registering call with id sip:[email protected]:5060
| 10:49:10.386087 [ ] Add to state: sip:[email protected]:5060
| 10:49:10.395399 [1] Calling
| 10:49:10.452841 [1] Early
| 10:49:17.617864 [1] Call connecting...
| 10:49:17.618756 [1] onCallMediaState call info state 4
| 10:49:17.618883 [1] Connected media 1
| 10:49:17.622464 [1] Call connected
| 10:49:17.697343 [1] onCallMediaState call info state 5
| 10:49:17.697520 [1] Connected media 1
| 10:49:19.630897 [1] Call is established.
| 10:49:19.631121 [ ] Calling webhook sip_call_webhook_id with data {'event': 'call_established', 'caller': 'sip:[email protected]:5060', 'parsed_caller': 'port_01', 'sip_account': 1}
| 10:49:19.655686 [ ] Webhook response 200 b''
| 10:49:19.655985 [1] Playing audio file: /config/www/sip_call_forward.mp3
| 10:49:20.141191 [1] No action supplied
| 10:49:24.100608 [1] Call disconnected
| 10:49:24.100864 [1] Calling additional webhook sip_call_disconnected for event call_disconnected
| 10:49:24.100896 [ ] Calling webhook sip_call_disconnected with data {'event': 'call_disconnected', 'caller': 'sip:[email protected]:5060', 'parsed_caller': 'port_01', 'sip_account': 1}
| 10:49:24.120453 [ ] Webhook response 200 b''
| 10:49:24.120613 [ ] Calling webhook sip_call_webhook_id with data {'event': 'call_disconnected', 'caller': 'sip:[email protected]:5060', 'parsed_caller': 'port_01', 'sip_account': 1}
| 10:49:24.150016 [ ] Webhook response 200 b''
| 10:49:24.155133 [ ] Remove from state: sip:[email protected]:5060

I see the 2 second delay here :

| 10:49:17.697520 [1] Connected media 1 | 10:49:19.630897 [1] Call is established.

catohagen avatar Aug 21 '24 08:08 catohagen

The delay is caused by pjsip (the sip libary used internally), and not by ha-sip. I don't know why this is happening.

arnonym avatar Aug 22 '24 12:08 arnonym