You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use the library to capture images
I am using the methods that are in the imouapi.device_entity but I have an error, I don´t know what is the problem,
What I Did
from imouapi.api import ImouAPIClient
from imouapi.device import ImouDiscoverService
from imouapi.device import ImouDevice
from imouapi.device_entity import ImouCamera
import asyncio
async def capture_image(api_client, device_id, image_path):
device_name = "Cell Go-D270"
sensor_type = "cameraSD" # Replace with actual sensor type
profile = "default" # Optional, can be left blank if not needed
camera = ImouCamera(api_client, device_id, device_name, sensor_type, profile)
# Now you can use camera.async_get_image() to capture an image
image_data = await camera.async_get_image()
if image_data is not None:
with open(image_path, 'wb') as f:
f.write(image_data)
print(f"Image saved to {image_path}")
else:
print("Failed to capture image")
if __name__ == "__main__":
# Replace with your actual credentials
app_id = "lc43ad91ef78744135"
app_secret = "xxxxxxxxxxxxxxxxxxxxxx"
device_id = "9L0C1ADPDP5D270"
session = "GENTEC CAMERA"
# Replace with the desired image path
image_path = "captured_image.jpg"
api_client = ImouAPIClient(app_id, app_secret,session)
discover_service = ImouDiscoverService(api_client)
asyncio.run(capture_image(api_client, device_id, image_path))
I got the next error
ConnectionFailed: 'str' object has no attribute 'request'
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 190, in _async_call_api
response = await self._session.request("POST", url, json=body, timeout=self._timeout)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'request'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 155, in _async_call_api
await self.async_connect()
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 117, in async_connect
data = await self._async_call_api("accessToken", {}, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 192, in _async_call_api
raise ConnectionFailed(f"{exception}") from exception
imouapi.exceptions.ConnectionFailed: 'str' object has no attribute 'request'
ConnectionFailed: 'str' object has no attribute 'request'
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 190, in _async_call_api
response = await self._session.request("POST", url, json=body, timeout=self._timeout)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'request'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 155, in _async_call_api
await self.async_connect()
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 117, in async_connect
data = await self._async_call_api("accessToken", {}, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 192, in _async_call_api
raise ConnectionFailed(f"{exception}") from exception
imouapi.exceptions.ConnectionFailed: 'str' object has no attribute 'request'
Too many unsuccesful connection attempts
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\capture_image.py", line 46, in
asyncio.run(capture_image(api_client, device_id, image_path))
File "C:\Users\JQU\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\JQU\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\capture_image.py", line 25, in capture_image
image_data = await camera.async_get_image()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\device_entity.py", line 582, in async_get_image
data = await self.api_client.async_api_setDeviceSnapEnhanced(self._device_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 553, in async_api_setDeviceSnapEnhanced
return await self._async_call_api(api, payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 160, in _async_call_api
raise NotConnected()
imouapi.exceptions.NotConnected
The text was updated successfully, but these errors were encountered:
Description
I want to use the library to capture images
I am using the methods that are in the imouapi.device_entity but I have an error, I don´t know what is the problem,
What I Did
I got the next error
ConnectionFailed: 'str' object has no attribute 'request'
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 190, in _async_call_api
response = await self._session.request("POST", url, json=body, timeout=self._timeout)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'request'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 155, in _async_call_api
await self.async_connect()
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 117, in async_connect
data = await self._async_call_api("accessToken", {}, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 192, in _async_call_api
raise ConnectionFailed(f"{exception}") from exception
imouapi.exceptions.ConnectionFailed: 'str' object has no attribute 'request'
ConnectionFailed: 'str' object has no attribute 'request'
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 190, in _async_call_api
response = await self._session.request("POST", url, json=body, timeout=self._timeout)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'request'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 155, in _async_call_api
await self.async_connect()
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 117, in async_connect
data = await self._async_call_api("accessToken", {}, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 192, in _async_call_api
raise ConnectionFailed(f"{exception}") from exception
imouapi.exceptions.ConnectionFailed: 'str' object has no attribute 'request'
Too many unsuccesful connection attempts
Traceback (most recent call last):
File "C:\Users\JQU\Downloads\imouapi-master\capture_image.py", line 46, in
asyncio.run(capture_image(api_client, device_id, image_path))
File "C:\Users\JQU\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\JQU\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\capture_image.py", line 25, in capture_image
image_data = await camera.async_get_image()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\device_entity.py", line 582, in async_get_image
data = await self.api_client.async_api_setDeviceSnapEnhanced(self._device_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 553, in async_api_setDeviceSnapEnhanced
return await self._async_call_api(api, payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JQU\Downloads\imouapi-master\imouapi\api.py", line 160, in _async_call_api
raise NotConnected()
imouapi.exceptions.NotConnected
The text was updated successfully, but these errors were encountered: