Skip to content

Commit

Permalink
Fix camera get image
Browse files Browse the repository at this point in the history
  • Loading branch information
greengiant committed Jun 29, 2020
1 parent 75bac0b commit c9c9777
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions custom_components/badnest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
_LOGGER = logging.getLogger(__name__)
_LOGGER.setLevel(logging.DEBUG)

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
_LOGGER.addHandler(handler)
# handler = logging.StreamHandler(sys.stdout)
# handler.setLevel(logging.DEBUG)
# formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
# handler.setFormatter(formatter)
# _LOGGER.addHandler(handler)


class NestAPI:
Expand Down Expand Up @@ -593,11 +593,18 @@ def camera_turn_on(self, device_id):
def camera_get_image(self, device_id, now):
if device_id not in self.cameras:
_LOGGER.error(f"Failed to get camera Image, Invalid Device ID: {device_id}")
return
return False
headers = {
"User-Agent": USER_AGENT,
"X-Requested-With": "XmlHttpRequest",
"Referer": "https://home.nest.com/",
"cookie": f"user_token={self._access_token}",
}
url = f"{self._camera_url}/get_image?uuid={device_id}&cachebuster={now}"
r = self._call_nest_api(
method="get", url=url, data=data, headers=headers, is_json=False
)
if not r:
_LOGGER.error("Failed Getting Camera Image")
return
return False
return r

0 comments on commit c9c9777

Please sign in to comment.