Skip to content

Commit ff86bb8

Browse files
Fixed heat/cool mode and added some test data
1 parent 7963387 commit ff86bb8

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

custom_components/panasonic_cc/climate.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ def _async_update_attrs(self) -> None:
164164
state = self.coordinator.device.parameters
165165
self._attr_hvac_mode = (HVACMode.OFF
166166
if state.power == constants.Power.Off
167-
else convert_operation_mode_to_hvac_mode(state.mode, state.iautox_mode))
167+
else convert_operation_mode_to_hvac_mode(
168+
state.mode,
169+
state.iautox_mode == constants.IAutoXMode.On))
168170

169171

170172
self._set_temp_range()

custom_components/panasonic_cc/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"domain": "panasonic_cc",
33
"name": "Panasonic Comfort Cloud",
44
"after_dependencies": ["http"],
5-
"version": "2024.9.3",
5+
"version": "2024.10.0",
66
"config_flow": true,
77
"documentation": "https://github.com/sockless-coding/panasonic_cc/",
88
"dependencies": [],

custom_components/panasonic_cc/pcomfortcloud/apiclient.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
import json
1111

1212

13-
from . import constants
13+
from . import constants, testdata
1414
from . import panasonicsession
1515
from .panasonicdevice import PanasonicDevice, PanasonicDeviceInfo, PanasonicDeviceEnergy
1616

17+
1718
_LOGGER = logging.getLogger(__name__)
1819

1920
_current_time_zone = None
@@ -101,6 +102,8 @@ def get_devices(self):
101102
self._devices.append(device_info)
102103
else:
103104
self._unknown_devices.append(device_info)
105+
106+
#self._unknown_devices.append(PanasonicDeviceInfo(get_dummy_aquarea_device_json()))
104107
return self._devices
105108

106109
def dump(self, device_id):
@@ -184,7 +187,7 @@ async def get_aquarea_device(self, device_info: PanasonicDeviceInfo):
184187
cookies=id_cookies,
185188
)
186189
device_id = id_response.cookies.get("selectedDeviceId").value
187-
_LOGGER.debug("Aquarea Device ID fro {} is {}".format(device_info.guid, device_id))
190+
_LOGGER.debug("Aquarea Device ID for {} is {}".format(device_info.guid, device_id))
188191
status_response = await self.execute_aqua_get(
189192
self._get_aquarea_device_info_url(device_id),
190193
"Get Aquarea device info", 200)

custom_components/panasonic_cc/pcomfortcloud/panasonicsession.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def __init__(self, username, password, client: aiohttp.ClientSession, settingsFi
4242
self._authentication = PanasonicAuthentication(client, self._settings, self._app_version)
4343
self._raw = raw
4444
self._request_semaphore = asyncio.Semaphore(1)
45+
self._aqua_cookies = aiohttp.CookieJar()
4546

4647
async def start_session(self):
4748
_LOGGER.debug("Starting Session")
@@ -155,8 +156,9 @@ async def execute_aqua_get(
155156
cookies: dict = {}):
156157
async with self._request_semaphore:
157158
await self._ensure_valid_token()
158-
159+
old_cookie_jar = self._client.cookie_jar
159160
try:
161+
self._client._cookie_jar = self._aqua_cookies
160162
cookies["accessToken"] = self._settings.access_token
161163
response = await self._client.get(
162164
url,
@@ -167,6 +169,8 @@ async def execute_aqua_get(
167169
aiohttp.http_exceptions.HttpProcessingError,
168170
aiohttp.web_exceptions.HTTPError) as ex:
169171
raise exceptions.RequestError(ex)
172+
finally:
173+
self._client._cookie_jar = old_cookie_jar
170174

171175
self._print_response_if_raw_is_set(response, function_description)
172176
await check_response(response, function_description, expected_status_code)
@@ -181,18 +185,24 @@ async def execute_aqua_post(
181185
cookies: dict = {}):
182186
async with self._request_semaphore:
183187
await self._ensure_valid_token()
184-
188+
old_cookie_jar = self._client.cookie_jar
185189
try:
190+
self._client._cookie_jar = self._aqua_cookies
191+
_LOGGER.debug(f"Aqua access token: {self._settings.access_token}")
186192
cookies["accessToken"] = self._settings.access_token
193+
187194
response = await self._client.post(
188195
url,
189196
headers = PanasonicRequestHeader.get_aqua_headers(content_type=content_type),
190197
cookies=cookies
191198
)
199+
192200
except (aiohttp.client_exceptions.ClientError,
193201
aiohttp.http_exceptions.HttpProcessingError,
194202
aiohttp.web_exceptions.HTTPError) as ex:
195203
raise exceptions.RequestError(ex)
204+
finally:
205+
self._client._cookie_jar = old_cookie_jar
196206

197207
self._print_response_if_raw_is_set(response, function_description)
198208
await check_response(response, function_description, expected_status_code)

custom_components/panasonic_cc/pcomfortcloud/testdata.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@ def inject_zone_data(json):
2525
"zoneSpill": 0,
2626
"zoneId": 3,
2727
"zoneName": "Zone 3"
28-
})
28+
})
29+
def get_dummy_aquarea_device_json():
30+
return {"deviceGuid": "000007340331", "deviceType": "2", "deviceName": "Demo", "connectionStatus": 0, "operationMode": 1, "zoneStatus": [{"zoneId": 1, "operationStatus": 0, "temperature": 0}, {"zoneId": 2}], "tankStatus": {"operationStatus": 1, "temperature": 50}}
31+
32+
def return_data():
33+
return {"timestamp":1727898629466,"permission":3,"summerHouse":2,"iAutoX":False,"nanoe":False,"nanoeStandAlone":False,"autoMode":True,"heatMode":True,"fanMode":True,"dryMode":True,"coolMode":True,"ecoNavi":False,"powerfulMode":True,"quietMode":True,"airSwingLR":True,"autoSwingUD":False,"ecoFunction":0,"temperatureUnit":0,"modeAvlList":{"autoMode":1},"nanoeList":{"visualizationShow":0},"clothesDrying":False,"insideCleaning":False,"fireplace":False,"pairedFlg":False,"parameters":{"ecoFunctionData":0,"insideCleaning":0,"fireplace":0,"lastSettingMode":0,"operate":1,"operationMode":0,"temperatureSet":22.5,"fanSpeed":0,"fanAutoMode":0,"airSwingLR":2,"airSwingUD":2,"ecoMode":2,"ecoNavi":0,"nanoe":0,"iAuto":0,"airDirection":1,"insideTemperature":21,"outTemperature":5,"airQuality":0}}

0 commit comments

Comments
 (0)