Skip to content

Commit 852a8a6

Browse files
authored
Merge branch 'speleolontra:master' into master
2 parents 5999950 + c273416 commit 852a8a6

File tree

7 files changed

+211
-21
lines changed

7 files changed

+211
-21
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/const.py

+53-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
CONF_UNIT_OF_MEASUREMENT,
1010
DEVICE_CLASS_TEMPERATURE,
1111
DEVICE_CLASS_ENERGY,
12+
DEVICE_CLASS_SIGNAL_STRENGTH,
1213
ENERGY_KILO_WATT_HOUR,
1314
TEMP_CELSIUS,
15+
PERCENTAGE,
16+
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
1417
)
1518

1619
DOMAIN = "daikin_residential_altherma"
@@ -24,7 +27,7 @@
2427

2528
# MANAGEMENT POINTS
2629
MP_CLIMATE = "climateControlMainZone"
27-
MP_GATEWAY = "gateway" # NEW
30+
MP_GATEWAY = "gateway"
2831
MP_DOMESTIC_HWT = "domesticHotWaterTank"
2932
MP_INDOOR_UNIT = "indoorUnitHydro"
3033
MP_OUDOOR_UNIT = "outdoorUnit"
@@ -38,6 +41,11 @@
3841
DP_TEMPERATURE = "temperatureControl"
3942
DP_CONSUMPTION = "consumptionData"
4043
DP_CONTROL_MODE = "controlMode"
44+
DP_WIFI_STRENGTH = "wifiConnectionStrength"
45+
DP_WIFI_SSID = "wifiConnectionSSID"
46+
DP_LOCAL_SSID = "ssid"
47+
DP_MAC_ADDRESS = "macAddress"
48+
DP_SERIAL_NUMBER = "serialNumber"
4149

4250
# DAMIANO HEAT PUMP ALTHERMA
4351

@@ -77,9 +85,11 @@
7785
ATTR_TANK_IS_POWERFUL_MODE_ACTIVE = "isPowerfulModeActive"
7886
ATTR_TANK_ERROR_CODE = "@TankErrorCode"
7987

80-
81-
82-
88+
ATTR_WIFI_STRENGTH = "wifi_strength"
89+
ATTR_WIFI_SSID = "wifi_ssid"
90+
ATTR_LOCAL_SSID = "local_ssid"
91+
ATTR_MAC_ADDRESS = "mac_address"
92+
ATTR_SERIAL_NUMBER = "serial_number"
8393

8494
DAIKIN_CMD_SETS = {
8595
#ATTR_ON_OFF: [MP_CLIMATE, DP_ON_OFF, "onOffMode"],
@@ -118,6 +128,12 @@
118128
ATTR_TANK_IS_IN_WARNING_STATE: [MP_DOMESTIC_HWT, "@TankisInWarningState", ""],
119129
ATTR_TANK_IS_POWERFUL_MODE_ACTIVE: [MP_DOMESTIC_HWT, "isPowerfulModeActive", ""],
120130
ATTR_TANK_ERROR_CODE: [MP_DOMESTIC_HWT, "errorCode", ""],
131+
# Gateway settings
132+
ATTR_WIFI_STRENGTH: [MP_GATEWAY, DP_WIFI_STRENGTH, ""],
133+
ATTR_WIFI_SSID: [MP_GATEWAY, DP_WIFI_SSID, ""],
134+
ATTR_LOCAL_SSID: [MP_GATEWAY, DP_LOCAL_SSID, ""],
135+
ATTR_MAC_ADDRESS: [MP_GATEWAY, DP_MAC_ADDRESS, ""],
136+
ATTR_SERIAL_NUMBER: [MP_GATEWAY, DP_SERIAL_NUMBER, ""],
121137
}
122138

123139
ATTR_STATE_ON = "on"
@@ -134,6 +150,7 @@
134150
SENSOR_TYPE_POWER = "power"
135151
SENSOR_TYPE_ENERGY = "energy"
136152
SENSOR_TYPE_INFO = None
153+
SENSOR_TYPE_GATEWAY_DIAGNOSTIC = "gateway_diagnostic"
137154
SENSOR_PERIOD_DAILY = "d"
138155
SENSOR_PERIOD_WEEKLY = "w"
139156
SENSOR_PERIOD_YEARLY = "m"
@@ -316,6 +333,38 @@
316333
#CONF_DEVICE_CLASS: DEVICE_CLASS_ENERGY,
317334
CONF_UNIT_OF_MEASUREMENT: " ",
318335
},
336+
ATTR_WIFI_STRENGTH: {
337+
CONF_NAME: "WiFi Strength",
338+
CONF_TYPE: SENSOR_TYPE_GATEWAY_DIAGNOSTIC,
339+
CONF_DEVICE_CLASS: DEVICE_CLASS_SIGNAL_STRENGTH,
340+
CONF_UNIT_OF_MEASUREMENT: SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
341+
},
342+
ATTR_WIFI_SSID: {
343+
CONF_NAME: "WiFi SSID",
344+
CONF_TYPE: SENSOR_TYPE_GATEWAY_DIAGNOSTIC,
345+
CONF_ICON: "mdi:access-point-network",
346+
CONF_DEVICE_CLASS: None,
347+
CONF_UNIT_OF_MEASUREMENT: None,
348+
},
349+
ATTR_LOCAL_SSID: {
350+
CONF_NAME: "Internal SSID",
351+
CONF_TYPE: SENSOR_TYPE_GATEWAY_DIAGNOSTIC,
352+
CONF_DEVICE_CLASS: None,
353+
CONF_UNIT_OF_MEASUREMENT: None,
354+
},
355+
ATTR_MAC_ADDRESS: {
356+
CONF_NAME: "Mac Address",
357+
CONF_TYPE: SENSOR_TYPE_GATEWAY_DIAGNOSTIC,
358+
CONF_DEVICE_CLASS: None,
359+
CONF_UNIT_OF_MEASUREMENT: None,
360+
},
361+
ATTR_SERIAL_NUMBER: {
362+
CONF_NAME: "Serial Number",
363+
CONF_TYPE: SENSOR_TYPE_GATEWAY_DIAGNOSTIC,
364+
CONF_ICON: "mdi:numeric",
365+
CONF_DEVICE_CLASS: None,
366+
CONF_UNIT_OF_MEASUREMENT: None,
367+
},
319368
}
320369

321370
CONF_UUID = "uuid"

custom_components/daikin_residential_altherma/daikin_base.py

+55
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
ATTR_TANK_IS_IN_WARNING_STATE,
4343
ATTR_TANK_IS_POWERFUL_MODE_ACTIVE,
4444
ATTR_TANK_ERROR_CODE,
45+
ATTR_WIFI_STRENGTH,
46+
ATTR_WIFI_SSID,
47+
ATTR_LOCAL_SSID,
48+
ATTR_MAC_ADDRESS,
49+
ATTR_SERIAL_NUMBER,
4550
)
4651

4752
from homeassistant.components.climate.const import (
@@ -478,6 +483,56 @@ def error_code(self):
478483
"""Return current error code."""
479484
return self.getValue(ATTR_ERROR_CODE)
480485

486+
@property
487+
def support_wifi_strength(self):
488+
"""Return True if the device supports wifi connection strength."""
489+
return self.getData(ATTR_WIFI_STRENGTH) is not None
490+
491+
@property
492+
def wifi_strength(self):
493+
"""Return current wifi connection strength."""
494+
return self.getValue(ATTR_WIFI_STRENGTH) if self.support_wifi_strength else None
495+
496+
@property
497+
def support_wifi_ssid(self):
498+
"""Return True if the device supports wifi connection ssid."""
499+
return self.getData(ATTR_WIFI_SSID) is not None
500+
501+
@property
502+
def wifi_ssid(self):
503+
"""Return current wifi connection ssid."""
504+
return self.getValue(ATTR_WIFI_SSID) if self.support_wifi_ssid else None
505+
506+
@property
507+
def support_local_ssid(self):
508+
"""Return True if the device supports internal ssid."""
509+
return self.getData(ATTR_LOCAL_SSID) is not None
510+
511+
@property
512+
def local_ssid(self):
513+
"""Return current internal ssid."""
514+
return self.getValue(ATTR_LOCAL_SSID) if self.support_local_ssid else None
515+
516+
@property
517+
def support_mac_address(self):
518+
"""Return True if the device reports its mac address."""
519+
return self.getData(ATTR_MAC_ADDRESS) is not None
520+
521+
@property
522+
def mac_address(self):
523+
"""Return device mac address."""
524+
return self.getValue(ATTR_MAC_ADDRESS) if self.support_mac_address else None
525+
526+
@property
527+
def support_serial_number(self):
528+
"""Return True if the device reports its serial number."""
529+
return self.getData(ATTR_SERIAL_NUMBER) is not None
530+
531+
@property
532+
def serial_number(self):
533+
"""Return device serial number."""
534+
return self.getValue(ATTR_SERIAL_NUMBER) if self.support_serial_number else None
535+
481536
@property # ATTR_TANK_HEATUP_MODE
482537
def support_heatupMode(self):
483538
"""Return True if the device supports heatupMode."""

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

+70-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
STATE_CLASS_TOTAL_INCREASING,
1616
)
1717

18+
from homeassistant.helpers.entity import EntityCategory
19+
1820
from .daikin_base import Appliance
1921

2022
from .const import (
@@ -50,8 +52,14 @@
5052
SENSOR_TYPE_POWER,
5153
SENSOR_TYPE_TEMPERATURE,
5254
SENSOR_TYPE_INFO,
55+
SENSOR_TYPE_GATEWAY_DIAGNOSTIC,
5356
SENSOR_PERIODS,
5457
SENSOR_TYPES,
58+
ATTR_WIFI_STRENGTH,
59+
ATTR_WIFI_SSID,
60+
ATTR_LOCAL_SSID,
61+
ATTR_MAC_ADDRESS,
62+
ATTR_SERIAL_NUMBER,
5563
)
5664

5765
import logging
@@ -184,6 +192,26 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
184192
else:
185193
_LOGGER.info("DAIKIN RESIDENTIAL ALTHERMA: device NOT supports error code")
186194

195+
if device.support_wifi_strength:
196+
_LOGGER.debug("DAIKIN RESIDENTIAL ALTHERMA: supports wifi signal strength")
197+
sensor = DaikinSensor.factory(device, ATTR_WIFI_STRENGTH, "")
198+
sensors.append(sensor)
199+
if device.support_wifi_ssid:
200+
_LOGGER.debug("DAIKIN RESIDENTIAL ALTHERMA: supports wifi ssid")
201+
sensor = DaikinSensor.factory(device, ATTR_WIFI_SSID, "")
202+
sensors.append(sensor)
203+
if device.support_local_ssid:
204+
_LOGGER.debug("DAIKIN RESIDENTIAL ALTHERMA: supports local ssid")
205+
sensor = DaikinSensor.factory(device, ATTR_LOCAL_SSID, "")
206+
sensors.append(sensor)
207+
if device.support_mac_address:
208+
_LOGGER.debug("DAIKIN RESIDENTIAL ALTHERMA: supports mac address")
209+
sensor = DaikinSensor.factory(device, ATTR_MAC_ADDRESS, "")
210+
sensors.append(sensor)
211+
if device.support_serial_number:
212+
_LOGGER.debug("DAIKIN RESIDENTIAL ALTHERMA: supports serial number")
213+
sensor = DaikinSensor.factory(device, ATTR_SERIAL_NUMBER, "")
214+
sensors.append(sensor)
187215

188216
#heatup
189217
if device.support_heatupMode:
@@ -261,10 +289,11 @@ def factory(device: Appliance, monitored_state: str, type, period=""):
261289
SENSOR_TYPE_POWER: DaikinEnergySensor,
262290
SENSOR_TYPE_ENERGY: DaikinEnergySensor,
263291
SENSOR_TYPE_INFO: DaikinInfoSensor,
292+
SENSOR_TYPE_GATEWAY_DIAGNOSTIC: DaikinGatewaySensor,
264293
}[SENSOR_TYPES[monitored_state][CONF_TYPE]]
265294
return cls(device, monitored_state,type, period)
266295
except Exception as error:
267-
print("error: " + error)
296+
# print("error: " + error)
268297
_LOGGER.error("%s", format(error))
269298
return
270299

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

290319
@property
291320
def available(self):
@@ -365,6 +394,11 @@ def entity_category(self):
365394
ATTR_TANK_IS_IN_INSTALLER_STATE,
366395
ATTR_TANK_IS_IN_WARNING_STATE,
367396
ATTR_TANK_ERROR_CODE,
397+
ATTR_WIFI_STRENGTH,
398+
ATTR_WIFI_SSID,
399+
ATTR_LOCAL_SSID,
400+
ATTR_MAC_ADDRESS,
401+
ATTR_SERIAL_NUMBER,
368402
]
369403
try:
370404
if self._device_attribute in configList:
@@ -494,3 +528,37 @@ def state(self):
494528
@property
495529
def state_class(self):
496530
return STATE_CLASS_TOTAL_INCREASING
531+
532+
class DaikinGatewaySensor(DaikinSensor):
533+
"""Representation of a WiFi Sensor."""
534+
535+
# set default category for these entities
536+
_attr_entity_category = EntityCategory.DIAGNOSTIC
537+
538+
@property
539+
def state(self):
540+
"""Return the internal state of the sensor."""
541+
if self._device_attribute == ATTR_WIFI_STRENGTH:
542+
return self._device.wifi_strength
543+
if self._device_attribute == ATTR_WIFI_SSID:
544+
return self._device.wifi_ssid
545+
if self._device_attribute == ATTR_LOCAL_SSID:
546+
return self._device.local_ssid
547+
if self._device_attribute == ATTR_MAC_ADDRESS:
548+
return self._device.mac_address
549+
if self._device_attribute == ATTR_SERIAL_NUMBER:
550+
return self._device.serial_number
551+
return None
552+
553+
@property
554+
def state_class(self):
555+
if self._device_attribute == ATTR_WIFI_STRENGTH:
556+
return STATE_CLASS_MEASUREMENT
557+
else:
558+
return None
559+
560+
@property
561+
def entity_registry_enabled_default(self):
562+
# auto disable these entities when added for the first time
563+
# except the wifi signal
564+
return self._device_attribute == ATTR_WIFI_STRENGTH

0 commit comments

Comments
 (0)