Skip to content

Commit 90ed5a8

Browse files
author
Balazs H
committed
adding proper logging through the HA logging framework
1 parent 5cf0114 commit 90ed5a8

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

custom_components/daikin_residential_altherma/climate.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class DaikinClimate(ClimateEntity):
8484

8585
def __init__(self, device):
8686
"""Initialize the climate device."""
87-
print("DAMIANO Initializing CLIMATE...")
87+
_LOGGER.info("DAMIANO Initializing CLIMATE...")
8888
self._device = device
8989
self._list = {
9090
ATTR_HVAC_MODE: list(HA_HVAC_TO_DAIKIN),
@@ -106,7 +106,7 @@ def __init__(self, device):
106106
if support_preset:
107107
self._supported_preset_modes.append(mode)
108108
self._supported_features |= SUPPORT_PRESET_MODE
109-
print("DAMIANO support_preset_mode {}: {}".format(mode,support_preset))
109+
_LOGGER.info("DAMIANO support_preset_mode {}: {}".format(mode,support_preset))
110110

111111
async def _set(self, settings):
112112
"""Set device settings using API."""

custom_components/daikin_residential_altherma/device.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def getDescription(self):
166166

167167
def getLastUpdated(self):
168168
"""Get the timestamp when data were last updated."""
169-
print("DAMIANO {}: LAST UPDATE DEVICE".format(self))
169+
_LOGGER.info("DAMIANO {}: LAST UPDATE DEVICE".format(self))
170170
return self.desc["lastUpdateReceived"]
171171
# return new Date(self.desc.lastUpdateReceived)
172172

@@ -231,7 +231,7 @@ def get_data(self, managementPoint=None, dataPoint=None, dataPointPath=""):
231231

232232
def get_value(self, managementPoint=None, dataPoint=None, dataPointPath=""):
233233
"""Get the current value of a data object."""
234-
print(" DAMIANO Get the current value of: {}-{}-{}".format(managementPoint,dataPoint,dataPointPath))
234+
_LOGGER.info(" DAMIANO Get the current value of: {}-{}-{}".format(managementPoint,dataPoint,dataPointPath))
235235
data = self.get_data(managementPoint, dataPoint, dataPointPath)
236236
if data is None:
237237
return None
@@ -250,25 +250,25 @@ async def updateData(self):
250250
return
251251
# TODO: Enhance self method to also allow to get some partial data
252252
# like only one managementPoint or such; needs checking how to request
253-
print("DEV UPDATE " + self.name)
253+
_LOGGER.info("DEV UPDATE " + self.name)
254254
desc = await self.api.doBearerRequest("/v1/gateway-devices/" + self.getId())
255255
self.setJsonData(desc)
256-
print("DEVICE: " + self.name)
257-
print(
256+
_LOGGER.info("DEVICE: " + self.name)
257+
_LOGGER.info(
258258
" temp: inner "
259259
+ str(self.get_value("climateControl", "sensoryData", "/roomTemperature"))
260260
+ " outer "
261261
+ str(
262262
self.get_value("climateControl", "sensoryData", "/outdoorTemperature")
263263
)
264264
)
265-
print(
265+
_LOGGER.info(
266266
" current mode: "
267267
+ str(self.get_value("climateControl", "operationMode"))
268268
+ " "
269269
+ str(self.get_value("climateControl", "onOffMode"))
270270
)
271-
print(
271+
_LOGGER.info(
272272
" target temp: "
273273
+ str(
274274
self.get_value(
@@ -278,7 +278,7 @@ async def updateData(self):
278278
)
279279
)
280280
)
281-
print(
281+
_LOGGER.info(
282282
" FAN: mode [{}] speed [{}]\n".format(
283283
self.get_value(
284284
"climateControl",

custom_components/daikin_residential_altherma/sensor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def factory(device: Appliance, monitored_state: str, type, period=""):
264264
}[SENSOR_TYPES[monitored_state][CONF_TYPE]]
265265
return cls(device, monitored_state,type, period)
266266
except Exception as error:
267-
print("error: " + error)
267+
# print("error: " + error)
268268
_LOGGER.error("%s", format(error))
269269
return
270270

@@ -285,7 +285,7 @@ def __init__(self, device: Appliance, monitored_state: str, type, period="") ->
285285
#self._name = f"{device.name} TANK {self._sensor[CONF_NAME]}"
286286
self._name = f"{device.name} {self._sensor[CONF_NAME]}"
287287
self._device_attribute = monitored_state
288-
print(" DAMIANO Initialized sensor: {}".format(self._name))
288+
_LOGGER.info(" DAMIANO Initialized sensor: {}".format(self._name))
289289

290290
@property
291291
def available(self):

custom_components/daikin_residential_altherma/switch.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
3636
for switch in switches:
3737

3838
if device.support_preset_mode(switch):
39-
print("DAMIANO Adding Switch {}".format(switch))
39+
_LOGGER.info("DAMIANO Adding Switch {}".format(switch))
4040
async_add_entities([DaikinSwitch(device, switch)])
4141

4242

@@ -89,15 +89,15 @@ def device_info(self):
8989

9090
async def async_update(self):
9191
"""Retrieve latest state."""
92-
print("DAMIANO {}: ASINC UPDATE SWITCH".format(self))
92+
_LOGGER.info("DAMIANO {}: ASYNC UPDATE SWITCH".format(self))
9393
await self._device.api.async_update()
9494

9595
async def async_turn_on(self, **kwargs):
9696
"""Turn the zone on."""
97-
print("DAMIANO {}: SWITCH TO {}".format(self._switch_id, ATTR_STATE_ON))
97+
_LOGGER.info("DAMIANO {}: SWITCH TO {}".format(self._switch_id, ATTR_STATE_ON))
9898
await self._device.set_preset_mode_status(self._switch_id, ATTR_STATE_ON)
9999

100100
async def async_turn_off(self, **kwargs):
101101
"""Turn the zone off."""
102-
print("DAMIANO {} SWITCH TO: {}".format(self._switch_id, ATTR_STATE_ON))
102+
_LOGGER.info("DAMIANO {} SWITCH TO {}".format(self._switch_id, ATTR_STATE_ON))
103103
await self._device.set_preset_mode_status(self._switch_id, ATTR_STATE_OFF)

readme.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Make sure to restart home Assistant, then go to "Using config flow" chapter.
1414

1515
# Manual Installation
1616

17-
Copy the "daikin_residential_altherma" folder and all of its contents into your Home Assistant's "custom_components" folder. This is often located inside of your "/config" folder. If you are running Hass.io, use SAMBA to copy the folder over. If you are running Home Assistant Supervised, the "custom_components" folder might be located at "/usr/share/hassio/homeassistant". It is possible that your "custom_components" folder does not exist. If that is the case, create the folder in the proper location, and then copy the "daikin_residential_altherma" folder and all of its contents inside the newly created "custom_components" folder.
17+
Copy the "daikin_residential_altherma" folder and all of its contents into your Home Assistant's "custom_components" folder. This is often located inside of your "/config" folder. If you are running Hass.io, use SAMBA to copy the folder over. If you are running Home Assistant Supervised, the "custom_components" folder might be located at "/usr/share/hassio/homeassistant". It is possible that your "custom_components" folder does not exist. If that is the case, create the folder in the proper location, and then copy the "daikin_residential_altherma" folder and all of its contents inside the newly created "custom_components" folder. Then you have to restart Home Assistant for the component to be loaded properly.
1818

1919
# Using config flow
2020

@@ -32,6 +32,24 @@ daikin_residential_altherma:
3232
password: [your_pwd]
3333
```
3434

35+
# Setting the log level
36+
37+
If you'd like to see more granular logs, to investigate the communication or for other debugging purposes, you can set the log level in the Home Assistant config. The following lines can be added to set the overall log level for the component:
38+
39+
```
40+
logger:
41+
logs:
42+
custom_components.daikin_residential_altherma: debug
43+
```
44+
45+
If you only want to change log level on a per module basis, you can do that as well, for example if you only want debug logs for the climate:
46+
47+
```
48+
logger:
49+
logs:
50+
custom_components.daikin_residential_altherma.climate: debug
51+
```
52+
3553
# Thanks to:
3654

3755
This code is based on @Rospogrigio's work that in turn is based on @Apollon77 's work, in finding a way to retrieve the token set, and to send the HTTP commands over the cloud. This integration would not exist without their precious job, my job was to try and debug Rospogrigio's code to adapt at JSON from Altherma 3 controlled by Daikin Residential App.

0 commit comments

Comments
 (0)