Home Assistant Integration - anyone else with two camect devices?

165 views
Skip to first unread message

Kane

unread,
Feb 12, 2021, 7:56:43 AM2/12/21
to Camect User Forum
Just wondering if anyone else has two Camect units, and if the integration is working for both of them?  

I only seem to be getting events come through from the second unit defined in my configuration.yaml.      The other one doesn't seem to fire camect_event (but it does create camera.* entities for the cameras from that device, so it certainly is at least partly working).

If I swap their order in configuration.yaml then the other one throws events, so it looks like the integration is only keeping track of one.

My config is as follows:

camect:
  - host192.168.1.198
    port443
    username!secret camect_admin_username
    password!secret camect_admin_password
    camera_idsf155d4f9a1252a76e26d,a93c7391e4ec632943ec,225f4f3c030bf76068ad,b3b0476f6eeb7c379473,51214789d0ce45bb6719,4aade25bd05d048d38f2
    idCamect 1
  - host192.168.1.146
    port443
    username!secret camect_admin_username
    password!secret camect_admin_password
    camera_ids3b08ceacd1b31973731c,7b9e4bbbb5ec1d7fe472,4ec0d64b798f8fb7bf6f,6f7d7d1eadd4722001c1,081ab689d3ef5a5b92dc
    idCamect 2

I did try the following instead, but that doesn't work at all - gets an error in the logs and nothing loads..

camect camect1:
  - host192.168.1.146
    port443
    username!secret camect_admin_username
    password!secret camect_admin_password
    camera_ids3b08ceacd1b31973731c,7b9e4bbbb5ec1d7fe472,4ec0d64b798f8fb7bf6f,6f7d7d1eadd4722001c1,081ab689d3ef5a5b92dc
    idCamect 2
camect camect2:
  - host192.168.1.198
    port443
    username!secret camect_admin_username
    password!secret camect_admin_password
    camera_idsf155d4f9a1252a76e26d,a93c7391e4ec632943ec,225f4f3c030bf76068ad,b3b0476f6eeb7c379473,51214789d0ce45bb6719,4aade25bd05d048d38f2
    idCamect 1

So as a starting point, it'd be good to know if anyone else has multiple units..

My next step might be to try and get my head around Python - have never done anything in that space so might be a bit of learning curve..

A hack version might be to duplicate the code for the custom component into a second version with a different name (camect2) and use that for the other device....    

Thanks
Kane

Kane

unread,
Feb 12, 2021, 10:09:32 AM2/12/21
to Camect User Forum, Kane
OK, looks like I can answer my own question.    

Found the issue with the code (in __init__.py)  The event listener was being added outside the loop, which means it was only being applied to the last unit.    

If I move add_event_listener call in, this addresses the issue - both camect units are now reporting events.

Now, how do I go about getting the official code (and/or the HACS repository) updated with the corrected code?  


Capture.JPG

pfun...@gmail.com

unread,
Feb 15, 2021, 9:57:16 AM2/15/21
to Camect User Forum, Kane
I think the correct way to ask for the update would be to place it in an "issue" in the Github project: https://github.com/camect/home-assistant-integration/issues
However, the team doesn't seem to pay much attention to it there.

They've mentioned that their priority is the core Camect stuff, and they hope that someone else will work on the Home Assistant integration. FWIW, I'm the HACS integration owner, but I'm not a python developer (just barely understand the basics of the integration), so my intention is simply to be a downstream of the official project by merging changes that occur there. If they make the change in their repo, I'll happily pass it down via the HACS integration. I just want to be careful not to negatively impact users of the HACS integration.

Hope that helps,

CamectChao

unread,
Feb 15, 2021, 2:19:33 PM2/15/21
to Camect User Forum, Kane
Please send a pull request. I'll approve it once I see it.

CamectChao

unread,
Feb 15, 2021, 2:24:59 PM2/15/21
to Camect User Forum, pfun...@gmail.com, Kane
We do watch the github repo... We are happy to review any bug/feature PR.

Kane Bullen

unread,
Feb 16, 2021, 5:11:14 AM2/16/21
to CamectChao, Camect User Forum

Thanks – I’ve put in a pull request.  Very simply change, but fixed the issue for me (probably lucky as this is the first time I’ve ever looked at Python code!)

 

If I start to free up some time, I might see if I can get my head around how Addons work.    Ideally, the integration would expose a sensor for each camera, with states to reflect “No Motion” or “Motion Detected”.   Can then easily write automations based on those states.


Cheers

Kane

 

 

From: CamectChao <ch...@camect.com>
Sent: Tuesday, 16 February 2021 3:20 AM
To: Camect User Forum <fo...@camect.com>
Cc: Kane <ka...@bullen.org>
Subject: Re: Home Assistant Integration - anyone else with two camect devices?

 

Please send a pull request. I'll approve it once I see it.

On Friday, February 12, 2021 at 7:09:32 AM UTC-8 Kane wrote:

OK, looks like I can answer my own question.    

 

Found the issue with the code (in __init__.py)  The event listener was being added outside the loop, which means it was only being applied to the last unit.    

 

If I move add_event_listener call in, this addresses the issue - both camect units are now reporting events.

 

Now, how do I go about getting the official code (and/or the HACS repository) updated with the corrected code?  

 

 

image001.jpg
Reply all
Reply to author
Forward
0 new messages