Logi Circle camera with HASS

I noticed that Logi have just announced their new Logi Circle 2 camera

Has anyone achieved success in getting the original Logi Circle camera to work within Home Assistant?

thanks

Would love to see this too. Still deciding whether or not to get one when it comes out. HA support would be awesome!

Also interested in buying a wired circle 2. Arlo and nest cams are supported in HASS. Circle should have a web interface. Could be possible?

I know this thread is probably dead however I did some research. What you can do is find the node your camera is on. (Your cameras can all be on different nodes)

Then you need to have a valid prod_session cookie. You get this by logging in and Logi will set this cookie.

Use this cookie in the header and call the API

https:// NODE ID .video.logi.com/api/accessories/CAMERA ID/image

This returns a still image that you can use for your automation. Hopefully this helps someone in the future.

2 Likes

Here is the reverse engineering of their auth flow

POST https://video.logi.com/api/accounts/authorization HTTP/1.1

{“email”:“EMAIL ADDRESS”,“password”:“PASSWORD”}

This will return the set cookie of prod session.

Set-Cookie: prod_session=SESSION COOKIE; Path=/; Domain=video.logi.com; Expires=DATE;

From there you have all the data you need to call the above mentioned API.

1 Like

https://video.logi.com/api/accessories

returns a JSON struct of your cameras and names of your cameras as well as the Node IDs.

1 Like

This is fantastic, I’ll have to try this as soon as I get Homebridge working properly again! Thanks for the info!!

Great work @Joseph_Giambo!

Still unsure how to add the stream to homeassistant though.

Following on from Joseph’s research… find below some PHP code that can be used to retrieve a still image from the first camera on an account.

Hopefully it may help someone write a plugin.

At the moment, I’m using the ‘generic IP camera’ plugin that points to this php page so that I can simply see a snapshot in homeassistant.

To use, set a path to store the cookies, email address and password and it should just work. Tested on Mac OS. Not the best code in the world but does only try and authenticate if the stored cookie has expired. Lots of improvements can be made.

Good luck.

<?php $cookie_path = '/tmp/cookies.tmp'; $email = '[email protected]'; $password = 'password'; if (!is_cookie_valid()){ web_request('https://video.logi.com/api/accounts/authorization',json_encode(array("email"=>$email,"password"=>$password))); } $res = web_request('https://video.logi.com/api/accessories'); if ($res){ $accs = json_decode($res,true); $nodeid = $accs[0]['nodeId']; $accid = $accs[0]['accessoryId']; $imgurl = 'https://'.$nodeid.'/api/accessories/'.$accid.'/image'; $res = web_request($imgurl); if ($res){ header('Content-Type:image/jpeg'); print $res; } }else{ die('Error retrieving accessories data'); } function web_request($url,$post_data=""){ global $cookie_path; $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0'); if (!$post_data==""){ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: '.strlen($post_data))); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_path); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_path); return curl_exec($ch); } function is_cookie_valid(){ global $cookie_path; if (file_exists($cookie_path)){ $lines = file($cookie_path); foreach($lines as $line) { if (substr_count($line,"\t")==6){ $tokens = explode("\t", $line); $tokens = array_map('trim', $tokens); if ($tokens[4]>time()){ return true; } } } } return false; } ?>
1 Like

@RISO how does it work with generic ip?

  • platform: generic
    name: Aquarium
    still_image_url: php /config/camera_aquarium.php

does not work :frowning:

can someone help?

Sorry Fux, never got it working myself (hassio).

Still hoping for a custom component. Fingers crossed.

Check this out - custom component impl . Hope you’ll enjoy it ).

3 Likes

It’s working! Really useful in my doorbell notification.

Thank you @sergeymaysak

Sorry to bother you, but how did you get it to work? When I test with the camera.snapshot, I get an older picture, not what is happening in front of the camera as I trigger the snapshot.

my observations shown that snapshort is updated once in a minute or so ( so dont expect much…

ohhh wow… Thank you :slight_smile:

@sergeymaysak This looks promising:

Todo
private mode switch
WebRTC streaming for live view
services to download activities and day brief

I won’t :frowning: I was under the impression that the camera.snapshot triggered an actual snapshot from the camera, not grabbing the last one saved. This seems to be the same for my Canary Flex camera as well.

Sidenote: anyone knows of a camera (for outside usage) that takes a snapshot when triggered?

Oh man, the timing. Just a few days ago I started working on the same thing as @sergeymaysak. I’m attacking it from the other end, working on getting a clean Python API built for Logi Circle, and then plan to integrate to HASS to keep the HASS code as simple as possible (as in, a PR to Home Assistant to add official Logi Circle support).

My project’s here: https://github.com/evanjd/python-logi-circle

@sergeymaysak What are your ambitions? Maybe we should collaborate? I don’t want to step on your toes if you had similar plans.