Skip to content

Commit

Permalink
support getting HVAC status through RemoteACRecordsRequest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhorne committed Feb 24, 2016
1 parent a59f03b commit 1d36dc9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
16 changes: 15 additions & 1 deletion pycarwings2/pycarwings2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
NCI : Canada
NMA : Australia
NML : Japan
Information about Nissan on the web (e.g. http://nissannews.com/en-US/nissan/usa/pages/executive-bios)
suggests others (this page suggests NMEX for Mexico, NLAC for Latin America) but
these have not been confirmed.
Expand Down Expand Up @@ -328,6 +328,20 @@ def get_latest_battery_status(self):

return None

def get_latest_hvac_status(self):
response = self.session._request("RemoteACRecordsRequest.php", {
"RegionCode": self.session.region_code,
"lg": self.session.language,
"DCMID": self.session.dcm_id,
"VIN": self.vin,
"tz": self.session.tz,
"TimeFrom": self.bound_time
})
if response["message"] == "success":
return CarwingsLatestClimateControlStatusResponse(response)

return None

# target_month format: "YYYYMM" e.g. "201602"
def get_electric_rate_simulation(self, target_month):
response = self.session._request("PriceSimulatorDetailInfoRequest.php", {
Expand Down
15 changes: 13 additions & 2 deletions pycarwings2/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,19 @@ def __init__(self, status):
"OperationDateAndTime":""
}
"""
class CarwingsClimateControlStatusResponse(CarwingsResponse):
pass
class CarwingsLatestClimateControlStatusResponse(CarwingsResponse):
def __init__(self, status):
CarwingsResponse.__init__(self, status["RemoteACRecords"])
racr = status["RemoteACRecords"]

self._set_cruising_ranges(racr, on_key="CruisingRangeAcOn", off_key="CruisingRangeAcOff")

# seems to be running only if both of these contain "START"
self.is_hvac_running = (
racr["OperationResult"] and
racr["OperationResult"].startswith("START") and
racr["RemoteACOperation"] == "START"
)

"""
{
Expand Down

0 comments on commit 1d36dc9

Please sign in to comment.