Dialplan
exten => 123,1,Answer()
same => n,AGI(/var/lib/asterisk/agi-bin/roomdata.py)
same => n,NoOp(TEMP: ${TEMP}) ; Log the value of TEMP for debugging purposes
same => n,Playback(current-temp1)
same => n,SayAlpha(${TEMP})
same => n,Hangup()
#!/usr/bin/python3
#import agi
import MySQLdb
import sys
from asterisk.agi import AGI
#import MySQLdb
agi = AGI()
mysql = MySQLdb.connect(host=“localhost”,user=“asterisk”,passwd=“YouNeedAReallyGoodPasswordHereToo”,db=“asterisk”)
db = mysql.cursor()
db.execute(“”“SELECT temperature FROM temperature ORDER BY id DESC LIMIT 1"”")
new_temp= db.fetchone()
db.close
new_temperature = int(new_temp[0])
agi.set_variable(“TEMP”,new_temperature)
– <PJSIP/SOFTPHONE_B-00000018>AGI Script /var/lib/asterisk/agi-bin/roomdata.py completed, returning 0
– Executing [123@sets:3] NoOp(“PJSIP/SOFTPHONE_B-00000018”, "TEMP: ") in new stack
– Executing [123@sets:4] Playback(“PJSIP/SOFTPHONE_B-00000018”, “current-temp1”) in new stack
– <PJSIP/SOFTPHONE_B-00000018> Playing ‘current-temp1.slin’ (language ‘en’)
– Executing [123@sets:5] SayAlpha(“PJSIP/SOFTPHONE_B-00000018”, “”) in new stack
– Executing [123@sets:6] Hangup(“PJSIP/SOFTPHONE_B-00000018”, “”) in new stack
== Spawn extension (sets, 123, 6) exited non-zero on ‘PJSIP/SOFTPHONE_B-00000018’
so im able to get the temperature data from the esp32 and in the database, however im trying to use the agi to repeat the data to the call. My playback message gets cut off when the extension is dial then it just hangs up. Im not sure what is wrong, any help here?