Skip to content

Commit 521eb76

Browse files
authored
Merge pull request #16 from rospogrigio/droscy-improvements
Some improvements
2 parents c6add20 + dcdc9bf commit 521eb76

File tree

6 files changed

+30
-3
lines changed

6 files changed

+30
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*~
22
.tox
3+
tools/daikin_data*.json
4+
tools/tokenset.json
35

46
# Byte-compiled / optimized / DLL files
57
__pycache__/

custom_components/daikin_residential/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
9696

9797
async def async_unload_entry(hass, config_entry):
9898
"""Unload a config entry."""
99+
_LOGGER.debug("Unloading integration...")
99100
await asyncio.wait(
100101
[
101102
hass.config_entries.async_forward_entry_unload(config_entry, component)
102103
for component in COMPONENT_TYPES
103104
]
104105
)
105-
hass.data[DOMAIN].pop(config_entry.entry_id)
106+
hass.data[DOMAIN].clear()
106107
if not hass.data[DOMAIN]:
107108
hass.data.pop(DOMAIN)
108109
return True

custom_components/daikin_residential/climate.py

+11
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ async def _set(self, settings):
141141
if values:
142142
await self._device.set(values)
143143

144+
@property
145+
def available(self):
146+
"""Return the availability of the underlying device."""
147+
return self._device.available
148+
144149
@property
145150
def supported_features(self):
146151
"""Return the list of supported features."""
@@ -180,6 +185,12 @@ def target_temperature_step(self):
180185

181186
async def async_set_temperature(self, **kwargs):
182187
"""Set new target temperature."""
188+
# The service climate.set_temperature can set the hvac_mode too, see
189+
# https://www.home-assistant.io/integrations/climate/#service-climateset_temperature
190+
# se we first set the hvac_mode, if provided, then the temperature.
191+
if ATTR_HVAC_MODE in kwargs:
192+
await self.async_set_hvac_mode(kwargs[ATTR_HVAC_MODE])
193+
183194
await self._device.async_set_temperature(kwargs[ATTR_TEMPERATURE])
184195

185196
@property

custom_components/daikin_residential/device.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, jsonData, apiInstance):
2424
self.setJsonData(jsonData)
2525
self.name = self.get_value("climateControl", "name")
2626
# self.ip_address = device.device_ip
27-
self._available = True
27+
2828
_LOGGER.info(
2929
"Initialized Daikin Residential Device '%s' (id %s)",
3030
self.name,
@@ -34,7 +34,10 @@ def __init__(self, jsonData, apiInstance):
3434
@property
3535
def available(self) -> bool:
3636
"""Return True if entity is available."""
37-
return self._available
37+
try:
38+
return self.desc["isCloudConnectionUp"]["value"]
39+
except Exception:
40+
return False
3841

3942
def device_info(self):
4043
"""Return a device description for device registry."""

custom_components/daikin_residential/sensor.py

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ def __init__(self, device: Appliance, monitored_state: str, period="") -> None:
7979
self._name = f"{device.name} {self._sensor[CONF_NAME]}"
8080
self._device_attribute = monitored_state
8181

82+
@property
83+
def available(self):
84+
"""Return the availability of the underlying device."""
85+
return self._device.available
86+
8287
@property
8388
def unique_id(self):
8489
"""Return a unique ID."""

custom_components/daikin_residential/switch.py

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def __init__(self, device: Appliance, switch_id: str):
3939
self._switch_id = switch_id
4040
self._name = f"{device.name} {switch_id}"
4141

42+
@property
43+
def available(self):
44+
"""Return the availability of the underlying device."""
45+
return self._device.available
46+
4247
@property
4348
def unique_id(self):
4449
"""Return a unique ID."""

0 commit comments

Comments
 (0)