Skip to content

Commit

Permalink
Added support for
Browse files Browse the repository at this point in the history
* Special Auto Up/Down swing mode (5)
* Basic hvac action
  • Loading branch information
sockless-coding committed Jul 19, 2022
1 parent 7f0deb4 commit 7479f3b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
28 changes: 26 additions & 2 deletions custom_components/panasonic_cc/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import voluptuous as vol
from typing import Any, Dict, Optional, List

from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity, HVACAction, HVACMode
from homeassistant.components.climate.const import HVAC_MODE_OFF, SUPPORT_PRESET_MODE
from homeassistant.helpers import config_validation as cv, entity_platform, service

Expand Down Expand Up @@ -65,6 +65,7 @@ def __init__(self, api):
"""Initialize the climate device."""

self._api = api
self._attr_hvac_action = HVACAction.IDLE

@property
def unique_id(self):
Expand Down Expand Up @@ -127,6 +128,28 @@ async def async_set_hvac_mode(self, hvac_mode):
else:
await self._api.set_hvac_mode(hvac_mode)

@property
def hvac_action(self):
if not self._api.is_on:
HVACAction.OFF
hvac_mode = self.hvac_mode
if (
(hvac_mode == HVACMode.HEAT or hvac_mode == HVACMode.HEAT_COOL)
and self._api.target_temperature > self._api.inside_temperature
):
return HVACAction.HEATING
elif (
(hvac_mode == HVACMode.COOL or hvac_mode == HVACMode.HEAT_COOL)
and self._api.target_temperature < self._api.inside_temperature
):
return HVACAction.COOLING
elif hvac_mode == HVACMode.DRY:
return HVACAction.DRYING
elif hvac_mode == HVACMode.FAN_ONLY:
return HVACAction.FAN

return HVACAction.IDLE

@property
def fan_mode(self):
"""Return the fan setting."""
Expand Down Expand Up @@ -161,7 +184,8 @@ async def async_set_horizontal_swing_mode(self, swing_mode):
@property
def swing_modes(self):
"""Return the list of available swing modes."""
return [f.name for f in self._api.constants.AirSwingUD ]
supported = lambda x: x != self._api.constants.AirSwingUD.All or (self._api.features is not None and self._api.features['upDownAllSwing'])
return [f.name for f in filter(supported, self._api.constants.AirSwingUD) ]

@property
def swing_lr_modes(self):
Expand Down
5 changes: 5 additions & 0 deletions custom_components/panasonic_cc/panasonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(self, hass: HomeAssistantType, api, device, force_outside_sensor, e
self._nanoe_mode = None
self._daily_energy = None

self.features = None



@Throttle(MIN_TIME_BETWEEN_UPDATES)
Expand Down Expand Up @@ -85,6 +87,9 @@ async def do_update(self):
_LOGGER.debug("Received no data for device {id}".format(**self.device))
return
try:
if self.features is None:
self.features = data['features']

plst = data['parameters']
self._is_on = bool( plst['power'].value )
if plst['temperatureInside'] != 126:
Expand Down
1 change: 1 addition & 0 deletions custom_components/panasonic_cc/pcomfortcloud/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AirSwingUD(Enum):
Mid = 2
DownMid = 4
Down = 1
All = 5

class AirSwingLR(Enum):
Auto = -1
Expand Down
23 changes: 22 additions & 1 deletion custom_components/panasonic_cc/pcomfortcloud/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ def get_device(self, id):
_json = json.loads(response.text)
return {
'id': id,
'parameters': self._read_parameters(_json['parameters'])
'parameters': self._read_parameters(_json['parameters']),
'features': self._read_features(_json)
}

return None
Expand Down Expand Up @@ -480,4 +481,24 @@ def _read_parameters(self, parameters = {}):
elif parameters['fanAutoMode'] == constants.AirSwingAutoMode.AirSwingUD.value:
value['airSwingVertical'] = constants.AirSwingUD.Auto

return value

def _read_features(self, data = {}):
value = {
'leftRightSwing': 'airSwingLR' in data and data['airSwingLR'],
'nanoe': 'nanoe' in data and data['nanoe'],
'autoMode': 'autoMode' in data and data['autoMode'],
'upDownAllSwing': 'autoSwingUD' in data and data['autoSwingUD'],
'ecoNavi': 'ecoNavi' in data and data['ecoNavi'],
'iAutoX': 'iAutoX' in data and data['iAutoX'],
'quietMode': 'quietMode' in data and data['quietMode'],
'powerfulMode': 'powerfulMode' in data and data['powerfulMode'],
'fanMode': 'fanMode' in data and data['fanMode'],
'coolMode': 'coolMode' in data and data['coolMode'],
'dryMode': 'dryMode' in data and data['dryMode'],
'nanoeStandAlone': 'nanoeStandAlone' in data and data['nanoeStandAlone'],
'heatMode': 'heatMode' in data and data['heatMode']
}


return value

0 comments on commit 7479f3b

Please sign in to comment.