@@ -324,14 +324,53 @@ def device_info(self):
324
324
"""Return a device description for device registry."""
325
325
return self ._device .device_info ()
326
326
327
- '''
328
327
@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
335
374
336
375
async def async_update (self ):
337
376
"""Retrieve latest state."""
0 commit comments