Skip to content

Commit 7c84fd4

Browse files
author
speleolontra
committed
Added Entity Category 'config' and 'diagnostic'
1 parent 2212758 commit 7c84fd4

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,24 @@ daikin_puredata.json
77
groups.yaml
88
home-assistant_v2.db
99
home-assistant.log
10+
home-assistant_v2.db-shm
11+
home-assistant_v2.db-wal
12+
home-assistant.log.1
13+
home-assistant.log.fault
1014
reset.cmd
1115
scenes.yaml
1216
scripts.yaml
1317
secrets.yaml
1418
tokenset.json
1519
.storage/**
1620
blueprints/**
21+
custom_components/dhcp/**
1722
custom_components/hacs/**
1823
custom_components/sonoff/**
1924
custom_components/start_time/**
2025
custom_components/xiaomi_gateway3/**
2126
custom_components/yandex_station/**
2227
deps/**
2328
custom_components/daikin_residential_altherma/.vscode/**
29+
custom_components/daikin_residential_altherma/__pycache__/**
30+

custom_components/daikin_residential_altherma/sensor.py

+46-7
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,53 @@ def device_info(self):
324324
"""Return a device description for device registry."""
325325
return self._device.device_info()
326326

327-
'''
328327
@property
329-
def state(self):
330-
"""Return the internal state of the sensor."""
331-
if self._device_attribute == ATTR_CONTROL_MODE:
332-
return self._device.control_mode
333-
return None
334-
'''
328+
def entity_category(self):
329+
"""
330+
Return the entity_category the sensor.
331+
CONFIG:Set to config for an entity which allows changing the configuration
332+
of a device, for example a switch entity making it possible to turn the
333+
background illumination of a switch on and off.
334+
335+
DIAGNOSTIC: Set to diagnostic for an entity exposing some configuration
336+
parameter or diagnostics of a device but does not allow changing it,
337+
338+
SYSTEM: Set to system for an entity which is not useful for the user
339+
to interact with. """
340+
341+
configList = [
342+
ATTR_SETPOINT_MODE,
343+
ATTR_TANK_SETPOINT_MODE,
344+
ATTR_CONTROL_MODE,
345+
ATTR_TANK_HEATUP_MODE,
346+
ATTR_TANK_IS_HOLIDAY_MODE_ACTIVE,
347+
ATTR_TANK_IS_POWERFUL_MODE_ACTIVE
348+
]
349+
diagnosticList =[
350+
ATTR_IS_IN_EMERGENCY_STATE,
351+
ATTR_IS_IN_ERROR_STATE,
352+
ATTR_IS_IN_INSTALLER_STATE,
353+
ATTR_IS_IN_WARNING_STATE,
354+
ATTR_ERROR_CODE,
355+
ATTR_TANK_IS_IN_EMERGENCY_STATE,
356+
ATTR_TANK_IS_IN_ERROR_STATE,
357+
ATTR_TANK_IS_IN_INSTALLER_STATE,
358+
ATTR_TANK_IS_IN_WARNING_STATE,
359+
ATTR_TANK_ERROR_CODE,
360+
]
361+
try:
362+
if self._device_attribute in configList:
363+
self._entity_category = "config"
364+
return self._entity_category
365+
elif self._device_attribute in diagnosticList:
366+
self._entity_category = "diagnostic"
367+
return self._entity_category
368+
else:
369+
return None
370+
except Exception as e:
371+
_LOGGER.info("entity_category not supported by this Home Assistant. /n \
372+
Try to update")
373+
return None
335374

336375
async def async_update(self):
337376
"""Retrieve latest state."""

0 commit comments

Comments
 (0)