Post

Blink lights when your IP phone rings

I have an IP phone on my desk connected to a FreePBX server. It is permanently set to silent mode. I keep it that way because 90% of the time I work with headphones. It’s also in a place where I can not easily see it.

So how do I know when the phone is ringing? Easy. The lights flash in a different color from the ambient light, in this case Navy Blue.

And how did I set this up? Also easy.

On the FreePBX server, all incoming calls are redirected to a Ring Group containing two extensions:

  • My desk phone - extension 200
  • “Fake” extension - extension ****5678


FreePBX Ring Group


The ****5678 extension is created in the extensions_custom.conf file.

[from-internal-custom]
exten => ****5678,1,TrySystem(/home/asterisk/hass.sh > /dev/null 2>&1 &)
same => n,Congestion


It calls the /home/asterisk/hass.sh shell script.

1
2
3
#!/bin/bash

curl -X POST -H "x-ha-access: HASS_PASSWORD" -H "Content-Type: application/json" http://HASS_SERVER_ADDRESS:8123/api/services/script/incoming_call


Which triggers the incoming_call script in Home Assistant.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# FreePBX Incoming Call
incoming_call:
  sequence:
    - service: light.lifx_effect_pulse
      data:
        entity_id: light.lamp_lights
        color_name: navy
        brightness: 191
        period: 1
        cycles: 2
    - delay:
        seconds: 4
    - service: light.lifx_effect_pulse
      data:
        entity_id: light.lamp_lights
        color_name: navy
        brightness: 191
        period: 1
        cycles: 2
    - delay:
        seconds: 4
    - service: light.lifx_effect_pulse
      data:
        entity_id: light.lamp_lights
        color_name: navy
        brightness: 191
        period: 1
        cycles: 2


When a call is received, the phone “rings” silently and the lights blink in navy blue three times separated by delays of 4 seconds.

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.