[Python] `imouapi` python library API request

Discussão em 'Python' iniciado por Stack, Abril 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a problem with a small python program that uses the imouapi library.

    import asyncio
    import aiohttp
    from imouapi.api import ImouAPIClient
    from imouapi.device import ImouDiscoverService
    from imouapi.device_entity import ImouSwitch

    async def main():
    app_id = "..."
    app_secret = "..."

    async with aiohttp.ClientSession() as session:
    api_client = ImouAPIClient(app_id, app_secret, session)
    discover_service = ImouDiscoverService(api_client)

    discovered_devices = await discover_service.async_discover_devices()

    for device_name, device in discovered_devices.items():
    print(f"\nDevice Name: {device_name}, Device ID: {device.get_device_id()}")

    for sensor in device.get_all_sensors():
    # print(f"- {sensor.get_name()}")

    if isinstance(sensor, ImouSwitch) and sensor.get_name() == "motionDetect":
    print(f"\nFound motion detection switch: {sensor.get_name()}")

    await sensor.async_turn_off()
    print(f"Sensor enabled: {sensor.is_enabled()}")
    print(f"Sensor is on: {sensor.is_on()}")

    asyncio.run(main())


    Briefly, I just purchased 2 IMOU surveillance cameras and I want to create a small app for my phone that can turn on/off motion detection with one click for both cameras.

    The provided code is able to find my cameras and all camera sensors, BUT I don't know why this code doesn't turn motion detection off. (In fact, if I check the public IMOU app, the switches are still on).

    Continue reading...

Compartilhe esta Página