Coder Social home page Coder Social logo

imou cell 2 request about imou_life HOT 37 CLOSED

user2684 avatar user2684 commented on June 4, 2024
imou cell 2 request

from imou_life.

Comments (37)

tango13 avatar tango13 commented on June 4, 2024 1

Have you checked you have imouapi library installed?
In my HA it wasn't automatically installed by the imou life integration, I had to install it manually via the pip command

pip install imouapi

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Interesting, for sure battery powered devices need to be handled differently. This is also related to an issue when a standard the device is offline with requests throwing errors. Will have a look at it, adding to the roadmap. Thanks

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Could you please start sharing Diagnostics (https://github.com/user2684/imou_life#troubleshooting) so I can have a look at available capabilities? I don't have the same model so I need to kind of reverse engineer the behavior :-) Thanks

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024
{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2022.11.4",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "x86_64",
    "timezone": "Europe/Amsterdam",
    "os_name": "Linux",
    "os_version": "5.10.108",
    "supervisor": "2022.11.2",
    "host_os": "Home Assistant OS 7.6",
    "docker_version": "20.10.9",
    "chassis": "vm",
    "run_as_root": true
  },
  "custom_components": {
    "irrigationprogram": {
      "version": "4.0.14",
      "requirements": []
    },
    "apsystems_ecur": {
      "version": "1.0.1",
      "requirements": []
    },
    "omada": {
      "version": "0.2.2",
      "requirements": []
    },
    "imou_life": {
      "version": "1.0.8",
      "requirements": [
        "imouapi==1.0.7"
      ]
    },
    "hacs": {
      "version": "1.28.3",
      "requirements": [
        "aiogithubapi>=22.2.4"
      ]
    },
    "formulaone_api": {
      "version": "0.1.9",
      "requirements": [
        "requests>=2.20"
      ]
    },
    "battery_sim": {
      "version": "1.0",
      "requirements": []
    },
    "cryptoinfo": {
      "version": "0.1.4",
      "requirements": []
    },
    "deepstack_object": {
      "version": "4.6.0",
      "requirements": [
        "pillow",
        "deepstack-python==0.8"
      ]
    },
    "delete": {
      "version": "1.7",
      "requirements": []
    },
    "browser_mod": {
      "version": "2.1.2",
      "requirements": []
    },
    "kef_connector": {
      "version": "0.5.5",
      "requirements": [
        "pykefcontrol==0.5.1"
      ]
    },
    "slide": {
      "version": "1.0",
      "requirements": [
        "goslide-api==0.6.4"
      ]
    },
    "knmi": {
      "version": "1.3.4",
      "requirements": []
    },
    "localtuya": {
      "version": "4.1.1",
      "requirements": []
    },
    "dahua": {
      "version": "0.5.0",
      "requirements": []
    },
    "inkbird": {
      "version": "1.0.1",
      "requirements": [
        "bluepy==1.3.0"
      ]
    }
  },
  "integration_manifest": {
    "domain": "imou_life",
    "name": "Imou Life",
    "documentation": "https://github.com/user2684/imou_life",
    "issue_tracker": "https://github.com/user2684/imou_life/issues",
    "dependencies": [],
    "config_flow": true,
    "codeowners": [
      "@user2684"
    ],
    "requirements": [
      "imouapi==1.0.7"
    ],
    "version": "1.0.8",
    "iot_class": "cloud_polling",
    "is_built_in": false
  },
  "data": {
    "entry": {
      "entry_id": "**REDACTED**",
      "version": 3,
      "domain": "imou_life",
      "title": "Basement",
      "data": {
        "api_url": "https://openapi.easy4ip.com/openapi",
        "device_name": "Basement",
        "app_id": "**REDACTED**",
        "app_secret": "**REDACTED**",
        "device_id": "**REDACTED**"
      },
      "options": {
        "scan_interval": 90,
        "api_timeout": "20",
        "callback_url": ""
      },
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": "7K0A92BRAZE0835",
      "disabled_by": null
    },
    "device_info": {
      "api": {
        "base_url": "https://openapi.easy4ip.com/openapi",
        "timeout": 20,
        "is_connected": true
      },
      "device": {
        "device_id": "**REDACTED**",
        "name": "Basement",
        "catalog": "IPC",
        "given_name": "Basement",
        "model": "IPC-B46L",
        "firmware": "2.800.0000000.11.R.220901",
        "manufacturer": "Imou",
        "online": "no"
      },
      "capabilities": [
        {
          "name": "WLAN",
          "description": "Support access to wireless local area network (WLAN)"
        },
        {
          "name": "DHP2P",
          "description": "Support Dahua P2P Service (DHP2P)"
        },
        {
          "name": "MT",
          "description": "Support streaming media forwarding capability (MT)"
        },
        {
          "name": "HSEncrypt",
          "description": "Support Huashi WeChat Stream Encryption (HSEncrypt)"
        },
        {
          "name": "CloudStorage",
          "description": "Support for cloud storage of China Vision WeChat platform (CloudStorage)"
        },
        {
          "name": "LocalStorage",
          "description": "Support device local storage, such as SD card or hard disk (LocalStorage)"
        },
        {
          "name": "PlaybackByFilename",
          "description": "The device supports playback based on the file name (PlaybackByFilename)"
        },
        {
          "name": "BreathingLight",
          "description": "The device has a breathing light (indicator light) (BreathingLight)"
        },
        {
          "name": "RD",
          "description": "The device has remote debugging capabilities and supports log extraction (RemoteDebug) (RD)"
        },
        {
          "name": "XUpgrade",
          "description": "Cloud Upgrade (XUpgrade)"
        },
        {
          "name": "Auth",
          "description": "Device end loopback RTSP requires authentication (Auth)"
        },
        {
          "name": "ModifyPassword",
          "description": "Support user name password information verification and password modification (ModifyPassword)"
        },
        {
          "name": "LocalStorageEnable",
          "description": "Support device local storage enable switch (LocalStorageEnable)"
        },
        {
          "name": "Siren",
          "description": "Siren (Siren)"
        },
        {
          "name": "WhiteLight",
          "description": "White Light (WhiteLight)"
        },
        {
          "name": "RTSV1",
          "description": "Real-time streaming supports private protocol to pull streaming (RTSV1)"
        },
        {
          "name": "PBSV1",
          "description": "Playback stream supports private protocol to pull stream (PBSV1)"
        },
        {
          "name": "ESV1",
          "description": "Support 0x95 extension header encryption (ESV1)"
        },
        {
          "name": "TimeFormat",
          "description": "Support time format setting (TimeFormat)"
        },
        {
          "name": "Reboot",
          "description": "The device supports restarting (Reboot)"
        },
        {
          "name": "SCCode",
          "description": "The device supports SC security code (SCCode)"
        },
        {
          "name": "DaySummerTime",
          "description": "The device supports daily summer time (DaySummerTime)"
        },
        {
          "name": "WeekSummerTime",
          "description": "The device supports weekly daylight saving time (WeekSummerTime)"
        },
        {
          "name": "TLSEnable",
          "description": "Support TLS transmission (TLSEnable)"
        },
        {
          "name": "TCM",
          "description": "Support Three code megre (TCM)"
        },
        {
          "name": "WLV2",
          "description": "White light, does not support brightness adjustment ability (WLV2)"
        },
        {
          "name": "LinkageSiren",
          "description": "Alarm Linkage Siren (LinkageSiren)"
        },
        {
          "name": "WLV3",
          "description": "WLV3"
        },
        {
          "name": "AUTODSTV2",
          "description": "AUTODSTV2"
        },
        {
          "name": "CLOUDCFG",
          "description": "CLOUDCFG"
        },
        {
          "name": "WST",
          "description": "WST"
        },
        {
          "name": "LFU",
          "description": "LFU"
        },
        {
          "name": "MSGSW",
          "description": "MSGSW"
        },
        {
          "name": "FrameReverse",
          "description": "Support screen flip (FrameReverse)"
        },
        {
          "name": "MDW",
          "description": "motion-detect-window supports motion detection window settings (MDW)"
        },
        {
          "name": "MDS",
          "description": "motion-detect-sensitive supports motion detection sensitivity setting (MDS)"
        },
        {
          "name": "Dormant",
          "description": "Sleepable, with wake-up and sleep states (Dormant)"
        },
        {
          "name": "ElecReport",
          "description": "Support power report (ElecReport)"
        },
        {
          "name": "WifiReport",
          "description": "Support wifi report (WifiReport)"
        },
        {
          "name": "CloseCamera",
          "description": "Support to close the camera (CloseCamera)"
        },
        {
          "name": "NVM",
          "description": "Night Vision Mode (NVM)"
        },
        {
          "name": "SirenVolume",
          "description": "SirenVolume"
        },
        {
          "name": "WORKM",
          "description": "WORKM"
        },
        {
          "name": "SMDH",
          "description": "SMDH"
        },
        {
          "name": "MobileDetect",
          "description": "Mobile Detection (Merged with PIR) (MobileDetect)"
        },
        {
          "name": "SMDHS",
          "description": "SMDHS"
        },
        {
          "name": "CloudPIR",
          "description": "CloudPIR"
        },
        {
          "name": "2560x1440",
          "description": "2560x1440"
        },
        {
          "name": "AECV3",
          "description": "AECV3"
        },
        {
          "name": "WLM",
          "description": "WLM"
        },
        {
          "name": "AudioTalk",
          "description": "Support voice intercom (AudioTalk)"
        },
        {
          "name": "Electric",
          "description": "Device Support Battery Capability (Electric)"
        },
        {
          "name": "WIFI",
          "description": "The device supports WIFI capability (WIFI)"
        },
        {
          "name": "Linkagewhitelight",
          "description": "Alarm white light (Linkagewhitelight)"
        },
        {
          "name": "pushNotifications",
          "description": "Push notifications (pushNotifications)"
        }
      ],
      "switches": [
        {
          "name": "breathingLight",
          "description": "Status indicator (breathingLight)",
          "state": true,
          "is_enabled": true,
          "is_updated": true,
          "attributes": {}
        },
        {
          "name": "localStorageEnable",
          "description": "Local storage (localStorageEnable)",
          "state": null,
          "is_enabled": false,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "whiteLight",
          "description": "White Light (whiteLight)",
          "state": false,
          "is_enabled": true,
          "is_updated": true,
          "attributes": {}
        },
        {
          "name": "linkageWhiteLight",
          "description": "White light armed (linkageWhiteLight)",
          "state": null,
          "is_enabled": false,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "linkageSiren",
          "description": "Siren Armed (linkageSiren)",
          "state": null,
          "is_enabled": false,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "closeCamera",
          "description": "Close camera (closeCamera)",
          "state": false,
          "is_enabled": true,
          "is_updated": true,
          "attributes": {}
        },
        {
          "name": "mobileDetect",
          "description": "Mobile detection (mobileDetect)",
          "state": null,
          "is_enabled": false,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "tlsEnable",
          "description": "Tls enable (tlsEnable)",
          "state": null,
          "is_enabled": false,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "pushNotifications",
          "description": "Push notifications (pushNotifications)",
          "state": true,
          "is_enabled": true,
          "is_updated": true,
          "attributes": {}
        }
      ],
      "sensors": [
        {
          "name": "storageUsed",
          "description": "Storage used (storageUsed)",
          "state": null,
          "is_enabled": true,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "callbackUrl",
          "description": "Callback url (callbackUrl)",
          "state": "**REDACTED**",
          "is_enabled": true,
          "is_updated": true,
          "attributes": {}
        }
      ],
      "binary_sensors": [
        {
          "name": "online",
          "description": "Online (online)",
          "state": false,
          "is_enabled": true,
          "is_updated": true,
          "attributes": {}
        }
      ],
      "selects": [
        {
          "name": "nightVisionMode",
          "description": "Night vision mode (nightVisionMode)",
          "current_option": "Intelligent",
          "available_options": [
            "Intelligent",
            "FullColor",
            "Infrared",
            "Off"
          ],
          "is_enabled": true,
          "is_updated": true,
          "attributes": {}
        }
      ],
      "buttons": [
        {
          "name": "restartDevice",
          "description": "Restart device (restartDevice)",
          "is_enabled": true,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "refreshData",
          "description": "Refresh all data (refreshData)",
          "is_enabled": true,
          "is_updated": false,
          "attributes": {}
        },
        {
          "name": "refreshAlarm",
          "description": "Refresh alarm (refreshAlarm)",
          "is_enabled": true,
          "is_updated": false,
          "attributes": {}
        }
      ],
      "sirens": [
        {
          "name": "siren",
          "description": "Activate siren (siren)",
          "state": false,
          "is_enabled": true,
          "is_updated": false,
          "attributes": {}
        }
      ]
    }
  }
}

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

Could you please start sharing Diagnostics (https://github.com/user2684/imou_life#troubleshooting) so I can have a look at available capabilities? I don't have the same model so I need to kind of reverse engineer the behavior :-) Thanks

see above, not sure this is the format you wanted :)

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Perfect thanks! I see the capability "Dormant" which helps us identifying those models.
But not sure I to wake them up, is not very clear from the API documentation. The only which is closer is https://open.imoulife.com/book/en/http/door/wakeUpDevice.html even if it does not refer to cameras.
I need to put together some scripts asking you to run some tests for me since I do not have this model.
Would you be confortable in running some python code for me? thanks

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

sure.. let me have it. (did support other custom components before, not being developer but i get around on a PI https://community.home-assistant.io/t/apsystems-aps-ecu-r-local-inverters-data-pull/260835)

let me see which API thought was usefull from this list https://open.imoulife.com/book/http/device/manage/query/summary.html
if we cant figure it from docs, i can see if i can trace the imo life app a bit to see how that app is waking the device (it reallly states in app, waking device and then fetches a thumbnail and/or stream)
it might be similar as the lock sample, let's see how this goes

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

Found only a packet with this as content, not exactly sure what it does really:
POST /device/{deviceidentifier}/local-channel
HTTP/1.1
x-pcs-request-id: 3b390326708f8b6c89c697fae9578b47
CSeq: 1366158627
Authorization: WSSE profile="UsernameToken"
X-WSSE: UsernameToken Username="P2PClient", PasswordDigest="secret", Nonce="-1353447782", Created="2022-11-28T21:14:43+01:00"
Content-Type:
Content-Length: 161

1669666483other secret864757875admin

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Where is this coming from? Is it an outgoing request from your camera?
Thanks for your availability to run some tests! Actually rather than sharing python code I think best would be if you are familiar with it of course to configure postman (https://open.imoulife.com/book/http/postman.html) so you can freely call any API, including those I've not implemented yet in our HA library. I'd give a try to https://open.imoulife.com/book/en/http/door/wakeUpDevice.html which may wake up the device

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

Trying Postman and the package, just cant get the intial token API to work. Somehow it's not getting my appid and secret while they are set in the environment i'm using. I see other variables being set, just cant figure it at the moment.
{"result":{"msg":"appId为空。","code":"OP1008"},"id":"42"} meaning appid is empty.
dont get it and feel very stupid now :)

never mind, the URl in the package was wrong. After changing it, it gives me a token. I'll shutup and try next steps

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

frist findings:
wakeupcall response:
{"result":{"msg":"Operation is successful.","code":"0"}}
but doesnt mean anyting as below response on deviceOnline query doesnt change:
{ "result": { "msg": "Operation is successful.", "code": "0", "data": { "channels": [ { "channelId": "0", "onLine": "1" } ], "deviceId": "7K0A92BRAZE0835", "onLine": "4" } }, "id": "25" }

where the onLine = 4 hints at Dormant probably. As when i open the Imou life app and wake the device, the value changes to 1.

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

additionally, the sample API modifyDeviceAlarmStatus DOES make the device go online with value =1.

So confirming the wakeup API is having no function at this device. any ideas whats next?

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Ok, wakeupcall was actually just a guess since made for doorbell devices so makes sense it doesn't work.
Interesting modifyDeviceAlarmStatus does instead wake up the device. Wonder if setDeviceCameraStatus is also waking up the device. If we cannot find a dedicated API to wake the device up, best we can do I guess is find an API call which is low-impact (e.g. getting the status of something rather than setting) and then use it to wake up the device before issuing any other command. Again, just guessing if we cannot find the proper call :-)

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

YEs is does. Tried with:
"params":{ "enableType":"closeCamera", "enable":true,

for which i have really no clue what it means as the description in API docs is not that clear.
Anyway, online =1 after calling the setDeviceCameraStatus.

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Ok great so we now know we can wake up the camera :-) A few questions now:

  • Any idea if closeCamera wakes up the camera when sending value true and put it to sleep back again with value false?
  • Let's assume before acting on any switch we need to wake up the camera. Wonder how long it takes for the camera to pick up the following api call. If you call closeCamera and then another command, does it work or you need to wait a bit before calling another api call?
  • I assume we do want to wake up the camera for direct interaction with the switches but not for refreshing their values every 15 mins otherwise will run out of battery, makes sense?
    Thanks

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

There is no api that results in device going back to sleep. Tried closeCamera, but also closeDormant. Any moment the channel is on status 4 and an API is called, it wakes up. There is no case that forces it to 4. I dont think its really necesary, as soon as interaction goes silent, it auto sleeps in 10 seconds orso.
I saw in the Imou app, the close camera triggers the 'Camera shielding' toggle btw. Now i know what the api is for :). And hence the closeDormant is a better approach to wake up device.
The API response is slow, it waits until device is active. So you dont need to wait for execute next call, but wait for response. The response kind of fluctuates between 3 and 6 seconds, could even be longer i assume. So setting a time out of 10 seconds would make sense.
You last bullet has me thinking a few things. But lets start with the initial behaviour as it is now:

  • the entities become very quickly unavailable currently. there is only active entities when devices is woken up and the poll is triggered.
  • the camera stream is always NA (black in UI).
    So options:
  • stop polling for entities on battery devices, as it will make them unavailable
  • have a config setting for poll with wakeup, to be able to test battery life
  • make call wake up when activating any toggle.
  • think about periodic refreshing the still image. (api setDeviceSnap and use that for HA camera still)
  • make different polling intervals , but didn't think that one through yet.

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Ok understood thanks. So you are saying, let's send closeDormant true to wake up the camera. The API will not return until the camera is up so no need to add additional waiting time (maybe just a few seconds to be sure). And no need to put it to sleep again since it will go in sleep mode by itself after a few seconds. This may be the logic to go through before performing any action with the camera (manual or during a periodic refresh).

Second topic is the availability of the camera. Right now is linked to the "online" status of the camera (e.g. "1" online, offline otherwise). This means I need to add a state ("4" dormant) and to make it available if in this state.

Now, about polling. It can be either taking place e.g. every 6 hours instead of 15 minutes or be disabled entirely. I guess this should be configurable by the user.

Streaming, not sure if streaming is enabled the camera stays up but you cannot test I guess since always unavailable. If this is the case, other thing to understand is how to unbind from a live stream. I mean, there is an api for that but there is no concept of "stream closed" in HA as far as I know to terminate the stream on the other side.

Anything else I'm missing?

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

First point: yes

second yes, with a note to 'device'oneline NOT the channel online

3rd, config would be most helptful

4th, not sure either. in the app, the stream dont stay open either. but not sure if its the app that stops or the device just says time out, going to sleep.
So to me, an updated still image every 30 seoncds orso would do and possibly already drain battery a lot. So a config setting for that seperatly would be nice.
The stream activation might be on webhook for motion detection, as the device should be awake already then, we might try to fetch live image too then. (and have a time limit to that http connection until we know we get disconnected or we need to action disconnect from HA side)

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

First attempt with version 1.0.11, may not necessarily work since I'm working blind without a device with that capability to test :-)
Have a loot at https://community.home-assistant.io/t/imou-life-cloud-integration/462439/128.
Some more implementation details:

  • The device should be now available even when dormant so you can go and interact with it in a dormant state
  • Any action is performed on any sensor or during a regular update, deviceOnline API is called so to refresh the current status, if domant, closeDormant is called and additional 4 seconds are added as waiting time (can be changed through the device options). deviceOnline is called again to check the device is now online before proceeding. All of this is because I cannot keep track of the status of the device since goes to sleep by itself, I need to ensure before sending any command that is online and able to process the command.
  • The above takes place for each sensor so there could be a lot of calls to the deviceOnline API but considering refresh should be pretty rare for these devices could be still acceptable
  • Refresh time for all the sensors is 15 minutes, the default, regardless, so you may want to increase this to hours or a day to avoid consuming the batteries (and the API call limits)
  • Let's see if the logic works first and then we will investigate better the video streaming issue

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

You sir, are even blind folded a million times better dev then I am in full visibility

Even got an camera image

Now i need to keep eye on battery, still image refreshes automatic, think every 10 seconds

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

Screenshot_20221211-184803~2

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Great! Glad to hear that. Keep me posted if you encounter any issue or strange behaviour along the way

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

just spotted it is always reported online in HA. I think i know why, because the update polling wakes the device and there is never a dormant reponse somehow. Need to check if it does go to sleep from postman (later today) for battery usage. I lost about 5% battery overnight (but i have no reference nights to compare with).
I also could not find an API for battery level. Did you see that somewhere?

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

Other question: should motion trigger a webhook or is only other alarms tied to webhooks?

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

The reason why shows up always online can be even simpler: If you e.g. refresh the data every 1 hour, it will always shows the last value, e.g. online. We can probably think of checking if it is online or not more frequently but the way it is designed the integration makes this very difficult to have different timers running.

Regarding the battery, have you tried https://open.imoulife.com/book/en/http/door/getDevicePowerInfo.html? No idea if it would work with your camera but could be worth trying.
How is it going in terms of battery usage generally speaking? Keep in mind that if you enable debug logging (https://github.com/user2684/imou_life#debugging) you should see all the details in terms of when the device is checked to be online, if a wake up call is made or not etc.

Motion (at least in my cameras) triggers an alarm which triggers a webhook.
Closing this as fixed but fell free to keep commenting :-)

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

The dormant state is not really usefull, so lets not pursue this state showing in HA.

yes. devciepower info does return intersting info
{"result":{"msg":"Operation is successful.","code":"0","data":{"electricitys":[{"electric":"89","type":"battery"}]}},"id":"47"}

89 is in deed current battery level%

webhooks was missing an automation declaring the webhook id.. just figured it by reading your documentation again. silly

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Thanks we can then add battery power level as a sensor. Still it needs to be refreshed together with other sensors so the frequency you pick up affects battery life :-)

Great webhook is working. Potentially the webhook could even trigger a data refresh so minimize ipact on the battery.
I will reopen this issue to add this new battery level sensor.
Thanks!

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

cool, battery drain visibility would be reaaly usefull..
with the webhooks enabled, it was drained in one night. I had automation to share me a camera capture and button press. It continously triggered new webhooks, so every second the sensor poll update ran :)
Is there a way i can see the content of the webhooks? I think i want to distinguish few events, and the HA events dont give those (but only give 'state_change' event). Wonder if content of webhooks are more detailed so i can pick the specific events for motion only (or battery state)

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Theoretically the webhook per-se should be server side. When you configure it, it will send the webhook, if not, the communication between the camera and Imou servers should take place anyway, only difference is that you will not receive it. This is because the Imou Life app is notified as well so cannot be dependent on your configuration.
Of course if you have configured the automation provided in the README, yes, then this will trigger a sensor refresh. You can view the content of the webhook by opening the automation, going to traces and reviewing the state changed section, you should see the json which is send over and customize the logic to avoid triggering the sensor refresh there. Let me know if makes sense. Thanks!

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

Got it and now understand the drain better. Even without the sensor refresh, several webhooks come in.

json: deviceType: IPC msgType: online
(twice)
then a
json: msgType: openCamera

and later a
json: deviceType: IPC msgType: sleep desc: status: sleep

So when the automation DOES do a sensor refresh. there is a new webhook and then it never ends.

Can i use the content of the webhook in an automation so i can make it better act on msgType?
then possibly an 'openCamera' could help me fetch a still image to display in HA

It would be awesome if we could make the 'sleep' message to update the entity state to be 'sleeping' as we cant do that by api easily.

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

Oh I see the issue. Sure you can, You can add template condition to your automation to proceed only on specific message types. You should have all the payload available in traces and you can add conditions based on trigger.json. If you need any help with this please let me know. This should be fixed not only for your camera even if of course with battery powered cameras it is way more impacting. I've opened up #45 to keep track of this different problem.
Good idea about to use the sleep message for updating the status otherwise the status will never be updated. Need to figure out the best way to do so since you cannot update the status of an entity from an automation (unless using some custom utilities) so maybe I need to add a service. Will think about it :-)
Many Thanks

from imou_life.

user2684 avatar user2684 commented on June 4, 2024

This should have been fixed now. You should see a "battery" sensor reporting the battery percentage. I've been working blind since I do not have such a camera to test so I hope it will work. I've also updated the automation template in the README file adding a condition to prevent triggering the refresh at every message type. Have a look at it, if it makes sense. Thanks.
Closing it for now, feel free to reopen again

from imou_life.

checkiecheck avatar checkiecheck commented on June 4, 2024

yessss.. got the battery sensor. Will look at automation template too later, didnt have the time yet.
thx for the BATT%, now i can trace battery life and do some charging planning !

from imou_life.

tango13 avatar tango13 commented on June 4, 2024

Trying Postman and the package, just cant get the intial token API to work. Somehow it's not getting my appid and secret while they are set in the environment i'm using. I see other variables being set, just cant figure it at the moment. {"result":{"msg":"appId为空。","code":"OP1008"},"id":"42"} meaning appid is empty. dont get it and feel very stupid now :)

never mind, the URl in the package was wrong. After changing it, it gives me a token. I'll shutup and try next steps

Sorry to revive this old discussion but I'm trying the same postman route for the cell go battery cam and I'm getting your same initial problems with postman.
You say the url in the package was wrong: can I ask you what you changed it into?
Thanks a lot.

from imou_life.

tango13 avatar tango13 commented on June 4, 2024

Ok, I think I figured it out after carefully re-reading :), now I'm getting a token.
Will read the following posts and see whether they apply to my camera too.
Thanks.

from imou_life.

MiAutomations avatar MiAutomations commented on June 4, 2024

Hello

I successfully integrate this camera model Cell Go in the HA using the IMOU LIfe Integration, but i still not able to view the live stream even if i activate the camera over the imou APP

Right now I have the following sensors and entities available over this integration

image
image

is there any way to get the live stream available ?

Thank you

from imou_life.

MiAutomations avatar MiAutomations commented on June 4, 2024

Have you checked you have imouapi library installed? In my HA it wasn't automatically installed by the imou life integration, I had to install it manually via the pip command

pip install imouapi

Thank you for your reply.

I'm not able to run this command, I'm receiving a msg that PIP command is not available ...

Thank you

from imou_life.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.