Imou Life - cloud integration

CODE IN MY BUTTON:

show_name: true
show_icon: true
type: button
icon: mdi:menu-up-outline
name: UP
tap_action:
  action: call-service
  service: imou_life.ptz_move
  data:
    operation: UP
    duration: 200
  target:
    entity_id: camera.esterna_imou_camera

The error occurs only in the interface, in the SERVICE menu it works correctly.
As an entity, I use the camera created by Imou Life - cloud integration

@Tarusky80 It’s working for me this way

show_name: true
show_icon: true
type: button
name: UP
tap_action:
  action: call-service
  service: imou_life.ptz_move
  data:
    operation: UP
    duration: 1000
  target:
    entity_id: camera.box_auto_camera

First, I copied your code and put into my dashboard, then I modified via UI and now it works
But strangely seems exactly the same except for the duration

I fixed it by creating 4 scripts (UP, DOWN…) and two scripts for favorite positions.

It’s strange that it doesn’t work for me, but the important thing is to reason and find the solution.

1 Like

Hello all, in release 1.0.10 just made available I’ve added support for snapshots and video streaming to the camera entity. I still believe using onvif should be quicker and better since is directly connecting to the camera but since this feature has been requested by many user, here it is :slight_smile:

No need to enable anything after the upgrade, you should just get an image preview under your device page and when clicking on the camera, the video stream should just play. Please note this is done entirely through the Imou API without directly connecting to the camera, like the onvif/rtsp integrations do.

All the services made available in HA for cameras should now be working with this integration as well :slight_smile:

Couple of caveats: a new cameraSd entity is also created but is disabled by default, in case you need to use a low resolution video stream. I’d suggest not enabling both at the same time to avoid too many calls to the underlying API. The image preview is the same on both the two streams since not captured from the video stream but by calling the snapshot service of the API.

3 Likes

Thank you so much!! Working like a charm!! I was having a very hard time with Imou cams via Onvif, your integration makes everything much more easy!!

I got mine working btw, see:

type: picture-glance
entities:
  - entity: camera.camfynn_camera
    tap_action:
      action: call-service
      service: imou_life.ptz_move
      service_data:
        operation: LEFT
        duration: 200
      target:
        entity_id: camera.camfynn_camera
    name: Pan Left
    show_state: false
    icon: mdi:arrow-left
    show_icon: true
  - entity: camera.camfynn_camera
    tap_action:
      action: call-service
      service: imou_life.ptz_move
      service_data:
        operation: UP
        duration: 200
      target:
        entity_id: camera.camfynn_camera
    name: Pan Up
    show_state: false
    icon: mdi:arrow-up
    show_icon: true
  - entity: camera.camfynn_camera
    tap_action:
      action: call-service
      service: imou_life.ptz_move
      service_data:
        operation: RIGHT
        duration: 200
      target:
        entity_id: camera.camfynn_camera
    name: Pan right
    show_state: false
    icon: mdi:arrow-right
    show_icon: true
  - entity: camera.camfynn_camera
    tap_action:
      action: call-service
      service: imou_life.ptz_move
      service_data:
        operation: DOWN
        duration: 200
      target:
        entity_id: camera.camfynn_camera
    name: Pan down
    show_state: false
    icon: mdi:arrow-down
    show_icon: true
camera_image: camera.camfynn
camera_view: live

With version 1.0.11 just released we have an initial support for dormant devices (e.g. battery-powered webcams which needs to be waken up before issuing any command):

  • Added support for dormant devices. You should see no difference if you don’t have such a device. If you have one, no special configuration is required, the integration should be able to identify those devices and waking them up before sending any command
  • Added a status sensor which reports Online, Offline, Dormant status
  • Device is now marked online if either online or dormant
  • Added options for customizing wait time for camera snapshot download and wait time after waking up dormant device

EDIT: version 1.0.12 is the latest version which fixes a minor bug on the dormant device logic

3 Likes

on the cell 2 device, the battery load is significant. Will put it in a corner without motion triggers for a few days, then i have some more idea of how big the drain is just because of the polling.

The image and stream loading has often 404 responses, not a real problem as it recovers from it anyway and starts providing image anyway.

@checking12 thanks for the feedback, I was not expecting to work perfectly at the first try :slight_smile:
Regarding the load, I was thinking, you can also configure it to do the polling somthing like once a month since the information we poll are not that useful for a sleeping device. Whenever you need to inteact with any switch, it will be instead waken up straight away instead. How often have you configured the polling to take place?

I was expecting the 404, it may happen even with non- sleeping device since it takes a white between the snapshot is taken and the image to be available. You could try with the couple of options which are now available to make the wait time a bit longer.
If you need instead me to have a deeper look at the issue, happy to do so, feel free to share debug logs on github :slight_smile:
Thanks

Is it possible to view the camera stream through the cloud but in HA ?
i have an imou camera in a remote location that id like to view

i think that will work anyway as all the api goes trhough cloud

poll was at 3000seconds. Waiting for image load was at 60 seconds. Any other timings you’d suggest?

@mhoogenbosch
Well, using IsSpy I was able to capture a working Onvif call for the Ranger 2C, so no need to use cloud / app / secret and other things…

It is just an HTTP POST XML Soap Call to port 80 : URI = “/onvif/ptz_service”

The full Post in pretty format is :

POST /onvif/ptz_service HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove"
Host: 192.168.0.108
Content-Length: 1513
Accept-Encoding: gzip, deflate

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="0">
      <UsernameToken>
        <Username>admin</Username>
        <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">[Your password in Digest format]=</Password>
        <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">[Your password in Basic format (base 64 of user:password)]</Nonce>
        <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2022-12-28T13:00:46.317Z</Created>
      </UsernameToken>
    </Security>
    <a:Action s:mustUnderstand="1">http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove</a:Action>
    <a:MessageID>urn:uuid:112224f3-eeca-4958-aa3d-43c46e6fb57e</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
    <a:To s:mustUnderstand="1">http://192.168.0.108/onvif/ptz_service</a:To>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl">
      <ProfileToken>Profile001</ProfileToken>
      <Velocity>
        <PanTilt xmlns="http://www.onvif.org/ver10/schema" x="-1" y="0" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace"/>
      </Velocity>
      <Timeout>PT1S</Timeout>
    </ContinuousMove>
  </s:Body>
</s:Envelope>

I tryed with Telnet on port 80 and it works very well, just open command line :

telnet 192.168.0.108 80
Than copy:paste the entire text above, you should received HTTP 200 OK and camera should move according to your x & y value (note It seems you can only use X OR Y not both one should be set to zero in my case.

Obviously you must :
Set your camera IP
Set your Digest & Basic password value
Set either X +/-1 or Y=+/-1
Set the real content-length of the payload in the header (just use VSCode and select the payload text without header it will give you the size to set for the header (on the the bottom bar)
Note: use CRLF for line ending

I managed to remove some useless datas, the minimal requirement seems to be :

POST /onvif/ptz_service HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver20/ptz/wsdl/ContinuousMove"
Host: 192.168.0.108
Content-Length: 1348
Accept-Encoding: gzip, deflate

<?xml version="1.0"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="0">
      <UsernameToken>
        <Username>admin</Username>
        <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">[Your password in Digest format]</Password>
        <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">[Your password in Basic format (base 64 of user:password)]</Nonce>
        <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2022-12-28T13:00:46.317Z</Created>
      </UsernameToken>
    </Security>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <ContinuousMove xmlns="http://www.onvif.org/ver20/ptz/wsdl">
      <ProfileToken>Profile001</ProfileToken>
      <Velocity>
        <PanTilt xmlns="http://www.onvif.org/ver10/schema" x="0" y="+1" space="http://www.onvif.org/ver10/tptz/PanTiltSpaces/VelocityGenericSpace"/>
      </Velocity>
      <Timeout>PT1S</Timeout>
    </ContinuousMove>
  </s:Body>
</s:Envelope>

I guess using CURL it should not be too hard to create a service using this template.

EDIT: Oups, I forgot th packet to make the camera stop moving :

POST /onvif/ptz_service HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8; action="http://www.onvif.org/ver20/ptz/wsdl/Stop"
Host: 192.168.0.108
Content-Length: 1339
Accept-Encoding: gzip, deflate

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" s:mustUnderstand="0">
      <UsernameToken>
        <Username>admin</Username>
        <Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">[Your password in Digest format]</Password>
        <Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">[Your password in Basic format (base 64 of user:password)]</Nonce>
        <Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2000-01-01T01:01:12.791Z</Created>
      </UsernameToken>
    </Security>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Stop xmlns="http://www.onvif.org/ver20/ptz/wsdl">
      <ProfileToken>Profile001</ProfileToken>
      <PanTilt>true</PanTilt>
      <Zoom>true</Zoom>
    </Stop>
  </s:Body>
</s:Envelope>

EDIT/ERRATUM:

I say something wrong… sorry,

You have to choose a random string
Nonce must be the Base64 encodeded random string
Digest password must be : Base64(sha1(randomNumber+created+password));

Exemple:
If you choose random : “AAA”
Your password is : “MyPassword”
Create date is : “2000-01-01T01:01:12.791Z”

Nonce must be set with Base64(“AAA”);
PasswordDigest must be set with Base64(sha1(“AAA2000-01-01T01:01:12.791ZMyPassword”))

I tried plain text password and the Ranger2C does not handle this case, it must be a digest password as explained above. But once it done PTZ works very well and did not require anything from outside the LAN.

@Ron_Azulay just to confirm video stream as well as snapshots for this plugin all comes through the cloud, no direct connection to the camera (since this is already available through onvif/rtsp integrations).

@checking12 I think the 60 seconds timeout for image loading could be fine. Polling every 50 mins could be impacting on the battery (just guessing), I’d try making it every 6, 12 or even 24 hours unless there is vital information you need from the dormant webcam

Ah, stupid question - but I get “Invalid App Id or App Secret provided” when I try my e-mail (and username).

Where do I find the correct App Id and App Secret? Can two-step verification an issue?

1 Like

@user2684 Thank you for this great integration!
I have just a couple of basic questions…
in my environment im also using human detection to trigger alarm/recording/notification
i have an automation that disable motion detection when someone is home (the human detection is automatically disable), when none is home i re-enable motion detection, am i reight that i should re-enable human detect too?
How the motion detection timing is implemented/works? im using callback to get real time detection notification (and it works almost instantly!), but after i leave the room it seems it takes a lot to revert back to no presence, also it seems the revert is not triggered by the callback but happens by timeout (this makes sense, since the no presence is not a trigger on the camera). Since i have a camera on the same room i exit the house and i can arm the security if the camera is “triggered” (there’s a 30 seconds dealy), at the moment im forcing a “refresh” on the camera during the delay so that hopefully it reverts to “no presence” before arming; but im not sure it will always work, any idea?

Also, at the moment if use the camera.snapshot to the camera HD entity, the image is save in SD; im actually solved this by using also the stantard camera integration to save images, video and preloaded stream (in HD) and imou integration to access the sensors, but it would be nice if i could use just one integration for everything

Thank you

@popeating I do something similar here. You need to re-enable both motion detection AND human detection because when you disable motion detection, the Imou service also automatically disable human detection on camera.

Not sure how long the camera takes to arm-back again once a motion is detected, I’ve noticed it could take up to a couple of minutes even if sometimes seems random. There is no way through the api to customize this behavior unfortunately.

Regarding the image resolution, right now I’m using the screenshot capability from the imou backend to get the image, it is not directly taking it from the stream meaning the image is the same regardless of the camera. I’d rather keep this behavior for now rather then interacting directly with the streaming since the latter would require way more resources despite the image would no be at the best quality possible.
Thanks!

Hello All,

I’m putting together a list of cameras/devices for which the integration has been tested and is working correctly to include in the documentation. If you have the integration configured, I’d kindly ask you to add your model (name and IPC-something) in List supported versions · Issue #53 · user2684/imou_life · GitHub, if your camera is not there already.
Many thanks!

Hello with this integration , is possible to locally record in a loop ? Thank you !

No, the clue is in the name “cloud” integration :rofl: