• ×
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
  • ×
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
Guidelines
We are proud to announce new Poly Studio Series video bars and remote room control with Poly Connect. Read more about the solutions!
HP Recommended
G7500 with Studio E70 and TC8 Kit
import requests

# Poly G7500 details
G7500_IP = "192.168.0.9"  # Change to your device IP
USERNAME = "admin"         # Change to your username
PASSWORD = "123"           # Change to your password

# API Endpoints
LOGIN_URL = f"https://{G7500_IP}/rest/session"
SIP_STATUS_URL = f"https://{G7500_IP}/rest/system/sipservers"
REBOOT_URL = f"https://{G7500_IP}/rest/system/reboot"

# Session for maintaining cookies
session = requests.Session()

# Disable SSL warnings
requests.packages.urllib3.disable_warnings()

# Function to login and create session
def login():
    payload = {"user": USERNAME, "password": PASSWORD}
    response = session.post(LOGIN_URL, json=payload, verify=False)
    if response.status_code == 200 and response.json().get("success"):
        print(" Login successful. Session established.")
        return True
    else:
        print(f" Login failed. HTTP {response.status_code}, Response: {response.text}")
        return False

# Function to check SIP registration status
def check_sip_status():
    response = session.get(SIP_STATUS_URL, verify=False)
    if response.status_code == 200:
        data = response.json()
        if isinstance(data, list) and data:
            sip_status = data[0].get("state", "UNKNOWN")  # Extract "state" from first SIP server
            print(f" SIP Registration Status: {sip_status}")
            return sip_status
        else:
            print(" No valid SIP server data found. Defaulting to UNKNOWN.")
            return "UNKNOWN"
    else:
        print(f" Failed to fetch SIP status. HTTP {response.status_code}, Response: {response.text}")
        return "UNKNOWN"

# Function to reboot the device (fixed API request)
def reboot_device():
    payload = {"action": "reboot"}  # Correct JSON body
    response = session.post(REBOOT_URL, json=payload, verify=False)

    if response.status_code == 200:
        print("Reboot command sent successfully.")
    elif response.status_code == 500:
        print(" Server error occurred while rebooting.")
    else:
        print(f" Failed to reboot. HTTP {response.status_code}, Response: {response.text}")

# Main script execution
if login():
    sip_status = check_sip_status()
    if sip_status in ["OFF", "UNKNOWN"]:  # Reboot only if SIP is OFF or UNKNOWN
        print("SIP is OFF or UNKNOWN. Rebooting the device...")
        reboot_device()
    else:
        print("SIP is UP. No action needed.")
1 REPLY 1
HP Recommended

Hi @Chandan_Thakur, Welcome to Poly HP Support Community.  
 
Thank you for your post.

 

Regards,

Salman

† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the <a href="https://www8.hp.com/us/en/terms-of-use.html" class="udrlinesmall">Terms of Use</a> and <a href="/t5/custom/page/page-id/hp.rulespage" class="udrlinesmall"> Rules of Participation</a>.