Time and Temp

Discussion in 'General' started by PSBITGuy, Aug 18, 2009.

  1. PSBITGuy

    Joined:
    Aug 18, 2009
    Messages:
    12
    Likes Received:
    0
    Just wanted to put this here, so that I could find it later. If you have any suggestions on this, please comment.
    All this does is add a current temperature to your time module. (*60)

    Modify /etc/extensions_override_freepbx.conf and add the following lines:

    Code:
    [app-speakingclock]
    ; Modified 8/17/09 to add temperature jj
    include => app-speakingclock-custom
    exten => *60,1,Answer
    exten => *60,n,Wait(1)
    exten => *60,n,Set(NumLoops=0)
    exten => *60,n(start),Set(FutureTime=$[${EPOCH} + 11])
    exten => *60,n,Playback(at-tone-time-exactly)
    exten => *60,n,GotoIf($["${TIMEFORMAT}" = "kM"]?hr24format)
    exten => *60,n,SayUnixTime(${FutureTime},,IM 'and' S 'seconds' p)
    exten => *60,n,Goto(waitloop)
    exten => *60,n(hr24format),SayUnixTime(${FutureTime},,kM 'and' S 'seconds')
    exten => *60,n(waitloop),Set(TimeLeft=$[${FutureTime} - ${EPOCH}])
    exten => *60,n,GotoIf($[${TimeLeft}  *60,n,Wait(1)
    exten => *60,n,Goto(waitloop)
    exten => *60,n(playbeep),Playback(beep)
    exten => *60,n,Wait(1)
    exten => *60,n,Set(PATH_TO_FILE=/tmp/temp.txt)
    exten => *60,n,Set(FILE_STATUS=${STAT(e,${PATH_TO_FILE})})
    exten => *60,n,GotoIf($["${FILE_STATUS}" = "" | "${FILE_STATUS}" = "0"]?no_file,1)
    exten => *60,n,Set(MAX_FILE_CHARACTERS=256)
    exten => *60,n,ReadFile(TEMPERATURE=${PATH_TO_FILE},${MAX_FILE_CHARACTERS})
    exten => *60,n,GotoIf($[${ISNULL(${TEMPERATURE})}]?no_file,1)   
    exten => *60,n,Playback(the&temperature&is-currently)
    exten => *60,n,SayNumber(${TEMPERATURE})
    exten => *60,n,Playback(degrees)-+
    exten => *60,n,Wait(1)
    exten => *60,n,Playback(goodbye)
    exten => *60,n,Hangup
    
    exten => no_file,1,Verbose(2,File does not exist)
    exten => no_file,n,Playback(silence/1)
    exten => no_file,n,Playback(goodbye)
    exten => no_file,n,Hangup
    
    ; end of [app-speakingclock]
    
    create a file called temperature.pl and put it in /usr/sbin/ and setup cron to run it every 15 minutes or so.
    I use webmin to setup cron jobs.
    Modify this file to point to your zip code.

    Code:
    ;temperature.pl
    curl -s 'http://www.google.com/ig/api?weather=47429' | awk -F'temp_f data="' '{ print $2 }' | awk -F'"/> /tmp/temp.txt
    
    
    This will create a file called temp.txt with the current temperature and put it in /tmp
    copy the file 'the.gsm' to /var/lib/asterisk/sounds and chown it to asterisk with 0664 rights
    You will have to change something in elastix (so that the apply settings will come up) and apply settings for this to take effect. http://forum.elastix.org/old_files/the.zip
     
  2. gamba47

    Joined:
    May 28, 2009
    Messages:
    595
    Likes Received:
    0
    Looks pretty good!

    Thanks for share it!

    gamba47
     
  3. Patiniotakis

    Joined:
    Jul 26, 2012
    Messages:
    24
    Likes Received:
    0
    Is this possible with Elastix 2.3?
     
  4. PSBITGuy

    Joined:
    Aug 18, 2009
    Messages:
    12
    Likes Received:
    0
    I haven't tested this on 2.3, but I don't see why not.
     
  5. Patiniotakis

    Joined:
    Jul 26, 2012
    Messages:
    24
    Likes Received:
    0
    For example, I cannot find the file /etc/extensions_override_freepbx.conf.
     
  6. PSBITGuy

    Joined:
    Aug 18, 2009
    Messages:
    12
    Likes Received:
    0
    probably changed in one of the newer versions.
    Maybe try extensions-override-freepbx.
    I can't confirm this, not using 2.3.
     
  7. jgutierrez

    Joined:
    Feb 28, 2008
    Messages:
    5,737
    Likes Received:
    0
    /etc/asterisk/extensions_override_elastix.conf
     

Share This Page