Skip to content

Commit 7fdf43e

Browse files
authored
Merge pull request #1 from dan-r/dev
Fixed failures with ICE Qashqai
2 parents 02ed86a + 7ecabaf commit 7fdf43e

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This is an unofficial integration. I have no affiliation with Nissan besides own
88

99
Tested with the following vehicles:
1010
* Nissan Leaf Tekna (2022) - UK
11+
* Nissan Qashqai (2021) - EU
1112

1213
If you find any bugs or would like to request a feature, please open an issue.
1314

@@ -36,22 +37,22 @@ Following the model of leaf2mqtt, this integration can be set to use a different
3637
This integration exposes the following entities. Please note that entities will only be shown if the functionality is supported by your car.
3738

3839
* Binary Sensors
39-
* Car Connected - On when the car is plugged in (EV Only)
40-
* Car Charging - On when the car is plugged in and drawing power (EV Only)
40+
* Car Plugged In (EV Only)
41+
* Car Charging (EV Only)
4142
* Sensors
4243
* Battery Level
4344
* Charge Time
4445
* Internal Temperature
4546
* External Temperature
46-
* Range
47+
* Range (EV Only)
4748
* Odometer
4849
* Daily Distance
4950
* Daily Trips
50-
* Daily Efficiency
51+
* Daily Efficiency (EV Only)
5152
* Monthly Distance
5253
* Monthly Trips
53-
* Monthly Efficiency
54+
* Monthly Efficiency (EV Only)
5455
* Climate
5556
* Device Tracker
5657
* Buttons
57-
* Update Data - Force an update
58+
* Update Data

custom_components/nissan_connect/climate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async def async_setup_entry(hass, config, async_add_entities):
2323
coordinator = hass.data[DOMAIN][DATA_COORDINATOR]
2424

2525
for vehicle in data:
26-
if Feature.TEMPERATURE in data[vehicle].features or Feature.INTERIOR_TEMP_SETTINGS in data[vehicle].features:
26+
if Feature.INTERIOR_TEMP_SETTINGS in data[vehicle].features:
2727
async_add_entities([KamereonClimate(coordinator, data[vehicle], hass)], update_before_add=True)
2828

2929

custom_components/nissan_connect/kamereon.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -621,15 +621,16 @@ def __init__(self, region):
621621
# ugly hack
622622
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
623623

624-
def login(self):
625-
"""Login with cached credentials."""
626-
return self.login(self._username, self._password)
627-
628-
def login(self, username, password):
629-
# Cache credentials
630-
self._username = username
631-
self._password = password
632-
624+
def login(self, username=None, password=None):
625+
if username is not None and password is not None:
626+
# Cache credentials
627+
self._username = username
628+
self._password = password
629+
else:
630+
# Use cached credentials
631+
username = self._username
632+
password = self._password
633+
633634
# Reset session
634635
self.session = requests.session()
635636

@@ -751,10 +752,16 @@ def session(self):
751752
def __init__(self, data, user_id):
752753
self.user_id = user_id
753754
self.vin = data['vin'].upper()
754-
self.features = [
755-
Feature(str(u['id']))
756-
for u in data.get('services', [])
757-
if u['activationState'] == "ACTIVATED"]
755+
self.features = []
756+
757+
# Try to parse every feature, but dont fail if we dont recognise one
758+
for u in data.get('services', []):
759+
if u['activationState'] == "ACTIVATED":
760+
try:
761+
self.features.append(Feature(str(u['id'])))
762+
except ValueError:
763+
pass
764+
758765
self.can_generation = data.get('canGeneration')
759766
self.color = data.get('color')
760767
self.energy = data.get('energy')
@@ -1094,6 +1101,9 @@ def unlock(self, srp: str, group: LockableDoorGroup=None):
10941101
return self.lock_unlock(srp, 'unlock', group)
10951102

10961103
def fetch_hvac_status(self):
1104+
if Feature.INTERIOR_TEMP_SETTINGS not in self.features and Feature.TEMPERATURE not in self.features:
1105+
return
1106+
10971107
resp = self._get(
10981108
'{}v1/cars/{}/hvac-status'.format(self.session.settings['car_adapter_base_url'], self.vin),
10991109
headers={'Content-Type': 'application/vnd.api+json'}

0 commit comments

Comments
 (0)