Skip to content

Commit

Permalink
Fixed heat/cool mode and added some test data
Browse files Browse the repository at this point in the history
  • Loading branch information
sockless-coding committed Oct 3, 2024
1 parent 7963387 commit ff86bb8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
4 changes: 3 additions & 1 deletion custom_components/panasonic_cc/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ def _async_update_attrs(self) -> None:
state = self.coordinator.device.parameters
self._attr_hvac_mode = (HVACMode.OFF
if state.power == constants.Power.Off
else convert_operation_mode_to_hvac_mode(state.mode, state.iautox_mode))
else convert_operation_mode_to_hvac_mode(
state.mode,
state.iautox_mode == constants.IAutoXMode.On))


self._set_temp_range()
Expand Down
2 changes: 1 addition & 1 deletion custom_components/panasonic_cc/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"domain": "panasonic_cc",
"name": "Panasonic Comfort Cloud",
"after_dependencies": ["http"],
"version": "2024.9.3",
"version": "2024.10.0",
"config_flow": true,
"documentation": "https://github.com/sockless-coding/panasonic_cc/",
"dependencies": [],
Expand Down
7 changes: 5 additions & 2 deletions custom_components/panasonic_cc/pcomfortcloud/apiclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
import json


from . import constants
from . import constants, testdata
from . import panasonicsession
from .panasonicdevice import PanasonicDevice, PanasonicDeviceInfo, PanasonicDeviceEnergy


_LOGGER = logging.getLogger(__name__)

_current_time_zone = None
Expand Down Expand Up @@ -101,6 +102,8 @@ def get_devices(self):
self._devices.append(device_info)
else:
self._unknown_devices.append(device_info)

#self._unknown_devices.append(PanasonicDeviceInfo(get_dummy_aquarea_device_json()))
return self._devices

def dump(self, device_id):
Expand Down Expand Up @@ -184,7 +187,7 @@ async def get_aquarea_device(self, device_info: PanasonicDeviceInfo):
cookies=id_cookies,
)
device_id = id_response.cookies.get("selectedDeviceId").value
_LOGGER.debug("Aquarea Device ID fro {} is {}".format(device_info.guid, device_id))
_LOGGER.debug("Aquarea Device ID for {} is {}".format(device_info.guid, device_id))
status_response = await self.execute_aqua_get(
self._get_aquarea_device_info_url(device_id),
"Get Aquarea device info", 200)
Expand Down
14 changes: 12 additions & 2 deletions custom_components/panasonic_cc/pcomfortcloud/panasonicsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def __init__(self, username, password, client: aiohttp.ClientSession, settingsFi
self._authentication = PanasonicAuthentication(client, self._settings, self._app_version)
self._raw = raw
self._request_semaphore = asyncio.Semaphore(1)
self._aqua_cookies = aiohttp.CookieJar()

async def start_session(self):
_LOGGER.debug("Starting Session")
Expand Down Expand Up @@ -155,8 +156,9 @@ async def execute_aqua_get(
cookies: dict = {}):
async with self._request_semaphore:
await self._ensure_valid_token()

old_cookie_jar = self._client.cookie_jar
try:
self._client._cookie_jar = self._aqua_cookies
cookies["accessToken"] = self._settings.access_token
response = await self._client.get(
url,
Expand All @@ -167,6 +169,8 @@ async def execute_aqua_get(
aiohttp.http_exceptions.HttpProcessingError,
aiohttp.web_exceptions.HTTPError) as ex:
raise exceptions.RequestError(ex)
finally:
self._client._cookie_jar = old_cookie_jar

self._print_response_if_raw_is_set(response, function_description)
await check_response(response, function_description, expected_status_code)
Expand All @@ -181,18 +185,24 @@ async def execute_aqua_post(
cookies: dict = {}):
async with self._request_semaphore:
await self._ensure_valid_token()

old_cookie_jar = self._client.cookie_jar
try:
self._client._cookie_jar = self._aqua_cookies
_LOGGER.debug(f"Aqua access token: {self._settings.access_token}")
cookies["accessToken"] = self._settings.access_token

response = await self._client.post(
url,
headers = PanasonicRequestHeader.get_aqua_headers(content_type=content_type),
cookies=cookies
)

except (aiohttp.client_exceptions.ClientError,
aiohttp.http_exceptions.HttpProcessingError,
aiohttp.web_exceptions.HTTPError) as ex:
raise exceptions.RequestError(ex)
finally:
self._client._cookie_jar = old_cookie_jar

self._print_response_if_raw_is_set(response, function_description)
await check_response(response, function_description, expected_status_code)
Expand Down
7 changes: 6 additions & 1 deletion custom_components/panasonic_cc/pcomfortcloud/testdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ def inject_zone_data(json):
"zoneSpill": 0,
"zoneId": 3,
"zoneName": "Zone 3"
})
})
def get_dummy_aquarea_device_json():
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}}

def return_data():
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 comments on commit ff86bb8

Please sign in to comment.