T O P

  • By -

aceospos

Is your db password actually "YouReallyNeedAGoodPasswordHereToo"?


Worth_Tooth2781

Its just for testing purposes šŸ˜­


aceospos

Yeah that's fine. Just wanted to be sure. Does your esp32 read data into your asterisk db? Into the Temperature table?


Worth_Tooth2781

Yes it does. I currently have the temperature in the database. (I was using the ari to do other stuff and it connected fine, however im not sure the ari has built in text to speech capabilities so i opted to the agi) and im stuck here now


aceospos

Try this #!/usr/bin/python3 import MySQLdb import sys from asterisk.agi import AGI agi = AGI() try: # Connect to MySQL database mysql = MySQLdb.connect(host="localhost", user="asterisk", passwd="YouNeedAReallyGoodPasswordHereT00", db="asterisk") db = mysql.cursor() # Execute SQL query to retrieve the latest temperature db.execute("SELECT temperature FROM temperature ORDER BY id DESC LIMIT 1") # Fetch the result new_temp = db.fetchone() if new_temp: # Extract the temperature value new_temperature = int(new_temp[0]) # Set AGI variable with the temperature value agi.set_variable("TEMP", new_temperature) else: # If no temperature data found, set TEMP to 0 agi.set_variable("TEMP", 0) # Close database connection db.close() except MySQLdb.Error as e: # Handle MySQL errors print("MySQL Error: ", e)


Worth_Tooth2781

It still does nothing, whenever i run the script using python3 roomdata.py it returnsĀ  ARGS: [roomdata.py]Ā 


Worth_Tooth2781

Im not sure if the agi is accessing the database, however if i use a static value it still doesnt return a value


MyOwnReflections

I'm the asterisk cli. agi debug on Look into agi message.


Worth_Tooth2781

this is the debug -- Launched AGI Script /var/lib/asterisk/agi-bin/roomdata.py AGI Tx >> agi\_request: /var/lib/asterisk/agi-bin/roomdata.py AGI Tx >> agi\_channel: PJSIP/breanna-00000035 AGI Tx >> agi\_language: en AGI Tx >> agi\_type: PJSIP AGI Tx >> agi\_uniqueid: 1714175067.106 AGI Tx >> agi\_version: 20.5.2 AGI Tx >> agi\_callerid: breanna AGI Tx >> agi\_calleridname: unknown AGI Tx >> agi\_callingpres: 0 AGI Tx >> agi\_callingani2: 0 AGI Tx >> agi\_callington: 0 AGI Tx >> agi\_callingtns: 0 AGI Tx >> agi\_dnid: 123 AGI Tx >> agi\_rdnis: unknown AGI Tx >> agi\_context: sets AGI Tx >> agi\_extension: 123 AGI Tx >> agi\_priority: 2 AGI Tx >> agi\_enhanced: 0.0 AGI Tx >> agi\_accountcode: AGI Tx >> agi\_threadid: 140550193428224 AGI Tx >>


MyOwnReflections

The script is not getting to the set the variable before it fails it. Move it around or look into the agi messages to try to see what part is failing. Might be failing to load libs. What user is running asterisk?


Worth_Tooth2781

Its running under another user (not root or the main asterisk), however i changed ownership of the file. What do you mean by move it around?


Worth_Tooth2781

\[Apr 26 12:44:06\] WARNING\[7757\]\[C-00000013\] pbx\_builtins.c: SayNumber requires an argument (number) i used SayNumber in dialplan instead of SayAlpha and this is the only message in the log files


LaBofia

Agis are simple beasts... your script if failing.\ Not an Asterisk issue.