import requests headers = { "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIzZWUyNTE1MDk0NGU0ZjRjYmJkMGM1MWI5MThmY2EzYiIsImlhdCI6MTc0NjgxMDM3NSwiZXhwIjoyMDYyMTcwMzc1fQ.Le6M7WL63nxtLTxccFacQR5GVUY5C-a_zGtmXT_uaz4" } sensors = [ "sensor.st_00158555_temperature", "sensor.st_00158555_feels_like", "sensor.st_00158555_humidity", "sensor.st_00158555_wind_speed" ] for s in sensors: try: r = requests.get(f"http://14.4.4.20:8123/api/states/{s}", headers=headers, timeout=5) print(s, "->", r.status_code, r.json().get("state"), r.json().get("attributes", {}).get("unit_of_measurement")) except Exception as e: print(s, "Error:", e)