Skip to content

Commit 5555a52

Browse files
committed
Some cleanup of #82
* custom_components/daikin_onecta/climate.py:
1 parent 1c34163 commit 5555a52

File tree

1 file changed

+34
-35
lines changed

1 file changed

+34
-35
lines changed

custom_components/daikin_onecta/climate.py

+34-35
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _handle_coordinator_update(self) -> None:
153153
async def _set(self, settings):
154154
raise NotImplementedError
155155

156-
def climateControl(self):
156+
def climate_control(self):
157157
cc = None
158158
supported_management_point_types = {"climateControl"}
159159
if self._device.daikin_data["managementPoints"] is not None:
@@ -163,13 +163,13 @@ def climateControl(self):
163163
cc = management_point
164164
return cc
165165

166-
def operationMode(self):
167-
cc = self.climateControl()
166+
def operation_mode(self):
167+
cc = self.climate_control()
168168
return cc.get("operationMode")
169169

170170
def setpoint(self):
171171
setpoint = None
172-
cc = self.climateControl()
172+
cc = self.climate_control()
173173
# Check if we have a temperatureControl
174174
temperatureControl = cc.get("temperatureControl")
175175
if temperatureControl is not None:
@@ -236,7 +236,7 @@ def translation_key(self) -> str:
236236

237237
@property
238238
def embedded_id(self):
239-
cc = self.climateControl()
239+
cc = self.climate_control()
240240
return cc["embeddedId"]
241241

242242
@property
@@ -249,7 +249,7 @@ def get_supported_features(self):
249249
if hasattr(ClimateEntityFeature, "TURN_OFF"):
250250
supported_features = ClimateEntityFeature.TURN_OFF | ClimateEntityFeature.TURN_ON
251251
setpointdict = self.setpoint()
252-
cc = self.climateControl()
252+
cc = self.climate_control()
253253
if setpointdict is not None and setpointdict["settable"] is True:
254254
supported_features |= ClimateEntityFeature.TARGET_TEMPERATURE
255255
if len(self.get_preset_modes()) > 1:
@@ -269,7 +269,7 @@ def get_supported_features(self):
269269
@property
270270
def name(self):
271271
device_name = self._device.name
272-
cc = self.climateControl()
272+
cc = self.climate_control()
273273
namepoint = cc.get("name")
274274
if namepoint is not None:
275275
device_name = namepoint["value"]
@@ -280,8 +280,7 @@ def name(self):
280280
@property
281281
def unique_id(self):
282282
"""Return a unique ID."""
283-
devID = self._device.getId()
284-
return f"{devID}_{self._setpoint}"
283+
return f"{self._device.getId()}_{self._setpoint}"
285284

286285
def get_current_temperature(self):
287286
currentTemp = None
@@ -302,30 +301,30 @@ def get_current_temperature(self):
302301
return currentTemp
303302

304303
def get_max_temp(self):
305-
maxTemp = None
304+
max_temp = None
306305
setpointdict = self.setpoint()
307306
if setpointdict is not None:
308-
maxTemp = setpointdict["maxValue"]
307+
max_temp = setpointdict["maxValue"]
309308
_LOGGER.info(
310309
"Device '%s': %s max temperature '%s'",
311310
self._device.name,
312311
self._setpoint,
313-
maxTemp,
312+
max_temp,
314313
)
315-
return maxTemp
314+
return max_temp
316315

317316
def get_min_temp(self):
318-
minValue = None
317+
min_temp = None
319318
setpointdict = self.setpoint()
320319
if setpointdict is not None:
321-
minValue = setpointdict["minValue"]
320+
min_temp = setpointdict["minValue"]
322321
_LOGGER.info(
323322
"Device '%s': %s min temperature '%s'",
324323
self._device.name,
325324
self._setpoint,
326-
minValue,
325+
min_temp,
327326
)
328-
return minValue
327+
return min_temp
329328

330329
def get_target_temperature(self):
331330
value = None
@@ -341,25 +340,25 @@ def get_target_temperature(self):
341340
return value
342341

343342
def get_target_temperature_step(self):
344-
stepValue = None
343+
step_value = None
345344
setpointdict = self.setpoint()
346345
if setpointdict is not None:
347-
stepValue = setpointdict["stepValue"]
346+
step_value = setpointdict["stepValue"]
348347
_LOGGER.info(
349348
"Device '%s': %s target temperature step '%s'",
350349
self._device.name,
351350
self._setpoint,
352-
stepValue,
351+
step_value,
353352
)
354-
return stepValue
353+
return step_value
355354

356355
async def async_set_temperature(self, **kwargs):
357356
# """Set new target temperature."""
358357
if ATTR_HVAC_MODE in kwargs:
359358
await self.async_set_hvac_mode(kwargs[ATTR_HVAC_MODE])
360359

361360
if ATTR_TEMPERATURE in kwargs:
362-
operationmode = self.operationMode()
361+
operationmode = self.operation_mode()
363362
omv = operationmode["value"]
364363
value = kwargs[ATTR_TEMPERATURE]
365364
res = await self._device.set_path(
@@ -379,16 +378,16 @@ async def async_set_temperature(self, **kwargs):
379378
def get_hvac_mode(self):
380379
"""Return current HVAC mode."""
381380
mode = HVACMode.OFF
382-
operationmode = self.operationMode()
383-
cc = self.climateControl()
381+
operationmode = self.operation_mode()
382+
cc = self.climate_control()
384383
if cc["onOffMode"]["value"] != "off":
385384
mode = operationmode["value"]
386385
return DAIKIN_HVAC_TO_HA.get(mode, HVACMode.HEAT_COOL)
387386

388387
def get_hvac_modes(self):
389388
"""Return the list of available HVAC modes."""
390389
modes = [HVACMode.OFF]
391-
operationmode = self.operationMode()
390+
operationmode = self.operation_mode()
392391
if operationmode is not None:
393392
for mode in operationmode["values"]:
394393
ha_mode = DAIKIN_HVAC_TO_HA[mode]
@@ -416,7 +415,7 @@ async def async_set_hvac_mode(self, hvac_mode):
416415
onOffMode = "on"
417416
operationMode = HA_HVAC_TO_DAIKIN[hvac_mode]
418417

419-
cc = self.climateControl()
418+
cc = self.climate_control()
420419

421420
# Only set the on/off to Daikin when we need to change it
422421
if onOffMode is not None:
@@ -473,7 +472,7 @@ async def async_set_hvac_mode(self, hvac_mode):
473472

474473
def get_fan_mode(self):
475474
fan_mode = None
476-
cc = self.climateControl()
475+
cc = self.climate_control()
477476
# Check if we have a fanControl
478477
fanControl = cc.get("fanControl")
479478
if fanControl is not None:
@@ -494,7 +493,7 @@ def get_fan_mode(self):
494493
def get_fan_modes(self):
495494
fan_modes = []
496495
fanspeed = None
497-
cc = self.climateControl()
496+
cc = self.climate_control()
498497
# Check if we have a fanControl
499498
fanControl = cc.get("fanControl")
500499
if fanControl is not None:
@@ -527,7 +526,7 @@ async def async_set_fan_mode(self, fan_mode):
527526
)
528527

529528
res = False
530-
cc = self.climateControl()
529+
cc = self.climate_control()
531530
operationmode = cc["operationMode"]["value"]
532531
if fan_mode in HA_FAN_TO_DAIKIN.keys():
533532
res = await self._device.set_path(
@@ -588,7 +587,7 @@ async def async_set_fan_mode(self, fan_mode):
588587

589588
def get_swing_mode(self):
590589
swingMode = None
591-
cc = self.climateControl()
590+
cc = self.climate_control()
592591
fanControl = cc.get("fanControl")
593592
h = SWING_OFF
594593
v = SWING_OFF
@@ -632,7 +631,7 @@ def get_swing_mode(self):
632631

633632
def get_swing_modes(self):
634633
swingModes = []
635-
cc = self.climateControl()
634+
cc = self.climate_control()
636635
fanControl = cc.get("fanControl")
637636
if fanControl is not None:
638637
swingModes = [SWING_OFF]
@@ -669,7 +668,7 @@ async def async_set_swing_mode(self, swing_mode):
669668
swing_mode,
670669
)
671670
res = True
672-
cc = self.climateControl()
671+
cc = self.climate_control()
673672
fanControl = cc.get("fanControl")
674673
operationmode = cc["operationMode"]["value"]
675674
if fanControl is not None:
@@ -736,7 +735,7 @@ async def async_set_swing_mode(self, swing_mode):
736735
return res
737736

738737
def get_preset_mode(self):
739-
cc = self.climateControl()
738+
cc = self.climate_control()
740739
current_preset_mode = PRESET_NONE
741740
for mode in self.preset_modes:
742741
daikin_mode = HA_PRESET_TO_DAIKIN[mode]
@@ -781,7 +780,7 @@ async def async_set_preset_mode(self, preset_mode):
781780

782781
def get_preset_modes(self):
783782
supported_preset_modes = [PRESET_NONE]
784-
cc = self.climateControl()
783+
cc = self.climate_control()
785784
# self._current_preset_mode = PRESET_NONE
786785
for mode in PRESET_MODES:
787786
daikin_mode = HA_PRESET_TO_DAIKIN[mode]
@@ -799,7 +798,7 @@ def get_preset_modes(self):
799798

800799
async def async_turn_on(self):
801800
"""Turn device CLIMATE on."""
802-
cc = self.climateControl()
801+
cc = self.climate_control()
803802
result = await self._device.set_path(self._device.getId(), self.embedded_id, "onOffMode", "", "on")
804803
if result is False:
805804
_LOGGER.warning("Device '%s' problem setting onOffMode to on", self._device.name)

0 commit comments

Comments
 (0)