Skip to content

Commit 39518fc

Browse files
Added support for horizontal swing modes
1 parent 1ed4e9f commit 39518fc

File tree

6 files changed

+101
-5
lines changed

6 files changed

+101
-5
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,39 @@ This is a custom component to allow control of Panasonic Comfort Cloud devices i
1313
- :coffee:  [Buy me a coffee](https://www.buymeacoffee.com/sockless)
1414

1515

16-
# Features:
16+
## Features:
1717

1818
* Climate component for Panasonic airconditioners and heatpumps
19+
* Horizontal swing mode selection
1920
* Sensors for inside and outside temperature (where available)
2021
* Switch for toggling Nanoe
2122
* Daily energy sensor (optional)
2223
* Current Power sensor (Calculated from energy reading)
2324

2425

25-
# Configuration
26+
## Installation
2627

27-
The Panasonic Comfort Cloud integration can be configured via the Home Assistant integration interface where it will let you enter your Panasonic ID and Password.
28+
### Install using HACS (recomended)
29+
If you do not have HACS installed yet visit https://hacs.xyz for installation instructions.
30+
In HACS go to the Integrations section hit the big + at the bottom right and search for **Panasonic Comfort Cloud**.
31+
32+
### Install manually
33+
Clone or copy this repository and copy the folder 'custom_components/panasonic_cc' into '<homeassistant config>/custom_components/panasonic_cc'
34+
35+
## Configuration
36+
37+
Once installed the Panasonic Comfort Cloud integration can be configured via the Home Assistant integration interface where it will let you enter your Panasonic ID and Password.
2838

2939
![Setup](https://github.com/sockless-coding/panasonic_cc/raw/master/doc/setup_dlg.png)
3040

3141
After inital setup additional options are available
3242

3343
![Setup](https://github.com/sockless-coding/panasonic_cc/raw/master/doc/options_dlg.png)
3444

45+
## Known issues
46+
47+
- Setting the Horizontal swing mode to LefMid will break the component and you have to use Comfort Cloud app to change the mode to sometihng else.
48+
3549
[license-shield]: https://img.shields.io/github/license/sockless-coding/panasonic_cc.svg?style=for-the-badge
3650
[releases-shield]: https://img.shields.io/github/release/sockless-coding/panasonic_cc.svg?style=for-the-badge
3751
[releases]: https://github.com/sockless-coding/panasonic_cc/releases

custom_components/panasonic_cc/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818

1919
from homeassistant.helpers import discovery
2020

21-
from .const import TIMEOUT, CONF_FORCE_OUTSIDE_SENSOR, DEFAULT_FORCE_OUTSIDE_SENSOR, CONF_ENABLE_DAILY_ENERGY_SENSOR, DEFAULT_ENABLE_DAILY_ENERGY_SENSOR
21+
from .const import (
22+
TIMEOUT,
23+
CONF_FORCE_OUTSIDE_SENSOR,
24+
DEFAULT_FORCE_OUTSIDE_SENSOR,
25+
CONF_ENABLE_DAILY_ENERGY_SENSOR,
26+
DEFAULT_ENABLE_DAILY_ENERGY_SENSOR)
2227

2328
from .panasonic import PanasonicApiDevice
2429

@@ -87,6 +92,8 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
8792
hass.async_create_task(
8893
hass.config_entries.async_forward_entry_setup(entry, component)
8994
)
95+
96+
9097
return True
9198

9299

custom_components/panasonic_cc/climate.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66

77
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
88
from homeassistant.components.climate.const import HVAC_MODE_OFF, SUPPORT_PRESET_MODE
9+
from homeassistant.helpers import config_validation as cv, entity_platform, service
910

1011
from homeassistant.const import (
1112
TEMP_CELSIUS, ATTR_TEMPERATURE)
1213

1314
from . import DOMAIN as PANASONIC_DOMAIN, PANASONIC_DEVICES
1415

15-
from .const import SUPPORT_FLAGS, OPERATION_LIST, PRESET_LIST
16+
from .const import (
17+
SUPPORT_FLAGS,
18+
OPERATION_LIST,
19+
PRESET_LIST,
20+
ATTR_SWING_LR_MODE,
21+
ATTR_SWING_LR_MODES,
22+
SERVICE_SET_SWING_LR_MODE)
1623

1724
_LOGGER = logging.getLogger(__name__)
1825

@@ -42,6 +49,16 @@ async def async_setup_entry(hass, entry, async_add_entities):
4249
]
4350
)
4451

52+
platform = entity_platform.current_platform.get()
53+
54+
platform.async_register_entity_service(
55+
SERVICE_SET_SWING_LR_MODE,
56+
{
57+
vol.Required('swing_mode'): cv.string,
58+
},
59+
"async_set_horizontal_swing_mode",
60+
)
61+
4562
class PanasonicClimateDevice(ClimateEntity):
4663

4764
def __init__(self, api):
@@ -133,11 +150,24 @@ async def async_set_swing_mode(self, swing_mode):
133150
"""Set new target temperature."""
134151
await self._api.set_swing_mode(swing_mode)
135152

153+
@property
154+
def swing_lr_mode(self):
155+
return self._api.swing_lr_mode
156+
157+
async def async_set_horizontal_swing_mode(self, swing_mode):
158+
await self._api.set_swing_lr_mode(swing_mode)
159+
160+
136161
@property
137162
def swing_modes(self):
138163
"""Return the list of available swing modes."""
139164
return [f.name for f in self._api.constants.AirSwingUD ]
140165

166+
@property
167+
def swing_lr_modes(self):
168+
"""Return the list of available swing modes."""
169+
return [f.name for f in self._api.constants.AirSwingLR ]
170+
141171
@property
142172
def current_temperature(self):
143173
"""Return the current temperature."""
@@ -190,4 +220,13 @@ def device_info(self):
190220
"""Return a device description for device registry."""
191221
return self._api.device_info
192222

223+
@property
224+
def device_state_attributes(self):
225+
attrs = {}
226+
try:
227+
attrs[ATTR_SWING_LR_MODE] = self.swing_lr_mode
228+
attrs[ATTR_SWING_LR_MODES] = self.swing_lr_modes
229+
except KeyError:
230+
pass
231+
return attrs
193232

custom_components/panasonic_cc/const.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
ATTR_DAILY_ENERGY = "daily_energy"
1414
ATTR_CURRENT_POWER = "current_power"
1515

16+
ATTR_SWING_LR_MODE = "horizontal_swing_mode"
17+
ATTR_SWING_LR_MODES = "horizontal_swing_modes"
18+
1619
ATTR_STATE_ON = "on"
1720
ATTR_STATE_OFF = "off"
1821

22+
SERVICE_SET_SWING_LR_MODE = "set_horizontal_swing_mode"
23+
1924
KEY_DOMAIN = "domain"
2025

2126
TIMEOUT = 60

custom_components/panasonic_cc/panasonic.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ def swing_mode(self):
160160
"""Return the fan setting."""
161161
return self.data['parameters']['airSwingVertical'].name
162162

163+
@property
164+
def swing_lr_mode(self):
165+
return self.data['parameters']['airSwingHorizontal'].name
166+
163167
@property
164168
def hvac_mode(self):
165169
"""Return the current operation."""
@@ -283,6 +287,25 @@ async def set_swing_mode(self, swing_mode):
283287
})
284288
await self.do_update()
285289

290+
async def set_swing_lr_mode(self, swing_mode):
291+
"""Set swing mode."""
292+
_LOGGER.debug("Set %s horizontal swing mode %s", self.name, swing_mode)
293+
if swing_mode == 'Auto':
294+
automode = self.constants.AirSwingAutoMode["AirSwingLR"]
295+
else:
296+
automode = self.constants.AirSwingAutoMode["Disabled"]
297+
298+
_LOGGER.debug("Set %s horizontal swing mode %s", self.name, swing_mode)
299+
300+
await self.hass.async_add_executor_job(
301+
self.set_device,
302+
{
303+
"power": self.constants.Power.On,
304+
"airSwingHorizontal": self.constants.AirSwingLR[swing_mode],
305+
"fanAutoMode": automode
306+
})
307+
await self.do_update()
308+
286309
async def set_nanoe_mode(self, nanoe_mode):
287310
"""Set new nanoe mode."""
288311
_LOGGER.debug("Set %s nanoe mode %s", self.name, nanoe_mode)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set_horizontal_swing_mode:
2+
description: Set the horizontal swing operation for climate device.
3+
fields:
4+
entity_id:
5+
description: Name(s) of entities to change.
6+
example: "climate.nest"
7+
swing_mode:
8+
description: New value of swing mode.

0 commit comments

Comments
 (0)