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

Commit 5dd0a91

Browse files
authored
Merge pull request #10 from mattsch/bugfix/login
Make the error message a little clearer when login is needed
2 parents 018df94 + fec2ed1 commit 5dd0a91

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

custom_components/badnest/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from homeassistant.helpers import config_validation as cv
44

55
from .api import NestAPI
6-
from .const import DOMAIN, CONF_ISSUE_TOKEN, CONF_COOKIE, CONF_USER_ID, \
7-
CONF_ACCESS_TOKEN
6+
from .const import DOMAIN, CONF_ISSUE_TOKEN, CONF_COOKIE
87

98
CONFIG_SCHEMA = vol.Schema(
109
{

custom_components/badnest/api.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(self,
111111
self.thermostats = set()
112112
self.temperature_sensors = set()
113113
self.protects = set()
114+
114115
self.login()
115116
self._get_devices()
116117
self.update()
@@ -151,7 +152,13 @@ def login(self):
151152
except RequestException as e:
152153
_LOGGER.error(e)
153154

154-
access_token = r.json()['access_token']
155+
try:
156+
access_token = r.json()['access_token']
157+
except KeyError:
158+
_LOGGER.error(f"{r.json()['error']}: {r.json()['detail']}")
159+
_LOGGER.error("Invalid cookie or issue_token. Please see:")
160+
_LOGGER.error("https://github.com/mattsch/badnest#configuration")
161+
raise
155162

156163
headers = {
157164
'User-Agent': USER_AGENT,

custom_components/badnest/const.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
DOMAIN = 'badnest'
22
CONF_ISSUE_TOKEN = 'issue_token'
33
CONF_COOKIE = 'cookie'
4-
CONF_USER_ID = 'user_id'
5-
CONF_ACCESS_TOKEN = 'access_token'

info.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ will never be as reliable as the original API
3535
```yaml
3636
badnest:
3737
issue_token: "https://accounts.google.com/o/oauth2/iframerpc....."
38-
cookie: "OCAK=......"
38+
cookie: "......"
3939

4040
climate:
4141
- platform: badnest

0 commit comments

Comments
 (0)