imou_life icon indicating copy to clipboard operation
imou_life copied to clipboard

Service "imou_life.ptz_location" doesn't work on Cruiser 2 PTZ camera

Open atiburzi opened this issue 1 year ago • 5 comments

error_log.txt

Version of the custom_component

HA Imou Life Custom Component version: 1.0.15

Version of the hardware (camera)

Device Info: IPC-GS7E-5M0WE (Imou Cruiser 2 camera)

  • Firmware: 2.800.0000000.8.R.230725
  • Hardware: 9H0C9FBPAZ799B5

Describe the bug

"imou_life.ptz_location" service doesn't work while I am successfully able to run the service "imou_life.ptz_move" (running them from developer tools in HA)

Here the service call script that fails (returning message: Unknown error):

service: imou_life.ptz_location
target:
  entity_id: camera.cruiser_2_01_camera
data:
  horizontal: 0
  vertical: 0

The device is NOT shared from an imou account different than the one the device is connected to.

In attachment, the error_log file generated with the diagnostics.

Debug log

Logger: homeassistant.helpers.script.websocket_api_script Source: helpers/script.py:468 First occurred: 09:29:54 (1 occurrences) Last logged: 09:29:54

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/imou_life/camera.py:117 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 01:22:15 (1 occurrences) Last logged: 01:22:15

[139818720309184] Error handling message: Unknown error (unknown_error) Andrea from 95.235.80.97 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 782, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1587, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 426, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 479, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 502, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 831, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 882, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 952, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/imou_life/camera.py", line 117, in async_service_ptz_location
    await self.sensor_instance.async_service_ptz_location(
  File "/usr/local/lib/python3.11/site-packages/imouapi/device_entity.py", line 703, in async_service_ptz_location
    return await self.api_client.async_api_controlLocationPTZ(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/imouapi/api.py", line 520, in async_api_controlLocationPTZ
    return await self._async_call_api(api, payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/imouapi/api.py", line 227, in _async_call_api
    raise APIError(error_message)
imouapi.exceptions.APIError: 40999: Unknown error.

Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:476
First occurred: 01:22:15 (1 occurrences)
Last logged: 01:22:15

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 40999: Unknown error.
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 476, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 713, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 675, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 831, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 882, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 952, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/imou_life/camera.py", line 117, in async_service_ptz_location
    await self.sensor_instance.async_service_ptz_location(
  File "/usr/local/lib/python3.11/site-packages/imouapi/device_entity.py", line 703, in async_service_ptz_location
    return await self.api_client.async_api_controlLocationPTZ(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/imouapi/api.py", line 520, in async_api_controlLocationPTZ
    return await self._async_call_api(api, payload)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/imouapi/api.py", line 227, in _async_call_api
    raise APIError(error_message)
imouapi.exceptions.APIError: 40999: Unknown error.

atiburzi avatar Feb 04 '24 00:02 atiburzi

Hi, thanks for all the detailed information. Looks like an error coming from the Imou API when called, and of course 40999: Unknown error is not very meaningful :-/ I have no way to reproduce it or to test to call the api with different parameters, hence if any other user has experienced the same, please let me know so we can try to understand with there is in common with what you are facing. Thanks!

user2684 avatar Feb 04 '24 09:02 user2684

Hi, fully understand, just to report here another case with a similar Camera: https://community.home-assistant.io/t/imou-life-cloud-integration/462439/191

atiburzi avatar Feb 04 '24 12:02 atiburzi

I have absolutly the same Problem !

tobiradi avatar Apr 20 '24 08:04 tobiradi

Hi.

I get locations working using the HA onvif integration with this service call:

service: onvif.ptz target: entity_id: camera.salon_profile000 data: preset: 2 move_mode: GotoPreset distance: 1 speed: 0.5 continuous_duration: 0.5

Where "2" is the number of a preset created using SmartPPS (it is the preset ID)

Cheerpipe avatar Jul 10 '24 13:07 Cheerpipe

Using the onvif integration as a workaround sounds like a good approach to me

user2684 avatar Jul 13 '24 08:07 user2684

Hello,

I've the same issue with

imouapi.exceptions.APIError: 40999: Unknown error.

That's why i tried Onvif @Cheerpipe Is it still working for you ? On same camera (IPC-GS7E-5M0WE - 2.801.0000000.1.R 2024-08-15), it's don't work for me. Preset is correcly set on SmartPSS (Imou version) and it's works but not with Onvif.ptz.

I've this error message :

Enregistreur: homeassistant.components.onvif
Source: components/onvif/device.py:582
intégration: ONVIF ([documentation](https://www.home-assistant.io/integrations/onvif), [problèmes](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+onvif%22))
S'est produit pour la première fois: 16:00:13 (3 occurrences)
Dernier enregistrement: 16:21:25

Absolute Presets not supported on device 'Camera XXX'

When looking in onvif integration diagnostic, i can see that my IPC-GS7E-5M0WE don't support Absolute Move and preset is empty. Is it the same with your camera or do you using another model or another firmware version ?

"device": {
      "info": {
        "manufacturer": "LC",
        "model": "IPC-GS7E-5M0WE",
        "fw_version": "2.801.0000000.1.R 2024-08-15",
        "serial_number": "F466DACPSF75A2E",
        "mac": "a8:31:62:46:cc:63"
      },
      "capabilities": {
        "snapshot": false,
        "events": true,
        "ptz": true,
        "imaging": true
      },
      "profiles": [
        {
          "index": 0,
          "token": "Profile000",
          "name": "Profile000",
          "video": {
            "encoding": "H264",
            "resolution": {
              "width": 2880,
              "height": 1620
            }
          },
          "ptz": {
            "continuous": true,
            "relative": false,
            "absolute": false,
            "presets": []
          },
          "video_source_token": "VideoSource000"
        },
        {
          "index": 1,
          "token": "Profile001",
          "name": "Profile001",
          "video": {
            "encoding": "H264",
            "resolution": {
              "width": 640,
              "height": 480
            }
          },
          "ptz": {
            "continuous": true,
            "relative": false,
            "absolute": false,
            "presets": []
          },
          "video_source_token": "VideoSource000"
        }
      ],

Using Onvif Device Manager, I can't see preset defined in SmartPSS and when I try to set thru ODM, I've error message saying unavailable option. If I come back to SmartPSS, I'm able to go to a preset previously defined. Do you know why ?

I use Wireless connection, I don't know if this can be important

mguyard avatar Sep 15 '24 14:09 mguyard

Added to https://github.com/user2684/imou_life/wiki/Known-Issues

user2684 avatar Sep 28 '24 09:09 user2684