Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #8 from vinodmishra/master
Browse files Browse the repository at this point in the history
Removing unnecessary region config
  • Loading branch information
mattsch authored May 31, 2020
2 parents c5974ba + 74a6084 commit cfc09c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
7 changes: 1 addition & 6 deletions custom_components/badnest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@

from .api import NestAPI
from .const import DOMAIN, CONF_ISSUE_TOKEN, CONF_COOKIE, CONF_USER_ID, \
CONF_ACCESS_TOKEN, CONF_REGION
CONF_ACCESS_TOKEN

CONFIG_SCHEMA = vol.Schema(
{
DOMAIN: vol.All(
{
vol.Required(CONF_USER_ID, default=""): cv.string,
vol.Required(CONF_ACCESS_TOKEN, default=""): cv.string,
vol.Optional(CONF_REGION, default="us"): cv.string,
},
{
vol.Required(CONF_ISSUE_TOKEN, default=""): cv.string,
vol.Required(CONF_COOKIE, default=""): cv.string,
vol.Optional(CONF_REGION, default="us"): cv.string,
}
)
},
Expand All @@ -32,19 +30,16 @@ def setup(hass, config):
access_token = config[DOMAIN].get(CONF_ACCESS_TOKEN)
issue_token = config[DOMAIN].get(CONF_ISSUE_TOKEN)
cookie = config[DOMAIN].get(CONF_COOKIE)
region = config[DOMAIN].get(CONF_REGION)
else:
issue_token = None
cookie = None
region = None

hass.data[DOMAIN] = {
'api': NestAPI(
user_id,
access_token,
issue_token,
cookie,
region,
),
}

Expand Down
11 changes: 6 additions & 5 deletions custom_components/badnest/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def __init__(self,
user_id,
access_token,
issue_token,
cookie,
region):
cookie):
self.device_data = {}
self._wheres = {}
self._user_id = user_id
Expand All @@ -110,7 +109,6 @@ def __init__(self,
self._issue_token = issue_token
self._cookie = cookie
self._czfe_url = None
self._camera_url = f'https://nexusapi-{region}1.camera.home.nest.com'
self.cameras = []
self.thermostats = set()
self.temperature_sensors = set()
Expand Down Expand Up @@ -188,7 +186,8 @@ def _get_cameras(self):
for camera in r.json()["items"]:
cameras.append(camera['uuid'])
self.device_data[camera['uuid']] = {}

self.device_data[camera['uuid']]['camera_url'] = \
camera['nexus_api_nest_domain_host']
return cameras

@Decorators.refresh_login
Expand Down Expand Up @@ -531,8 +530,10 @@ def camera_get_image(self, device_id, now):
if device_id not in self.cameras:
return

camera_url = self.device_data[device_id]['camera_url']

r = self._session.get(
f'{self._camera_url}/get_image?uuid={device_id}' +
f'https://{camera_url}/get_image?uuid={device_id}' +
f'&cachebuster={now}',
)

Expand Down
1 change: 0 additions & 1 deletion custom_components/badnest/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
CONF_COOKIE = 'cookie'
CONF_USER_ID = 'user_id'
CONF_ACCESS_TOKEN = 'access_token'
CONF_REGION = 'region'

0 comments on commit cfc09c4

Please sign in to comment.