|
12 | 12 | import voluptuous as vol |
13 | 13 | from homeassistant.core import HomeAssistant |
14 | 14 | from homeassistant.config_entries import ConfigEntry |
15 | | -from homeassistant.const import CONF_NAME |
| 15 | +from homeassistant.const import CONF_NAME, EntityCategory |
16 | 16 | from homeassistant.helpers.entity import Entity |
17 | 17 | from homeassistant.helpers.entity_platform import AddEntitiesCallback |
18 | 18 |
|
@@ -63,8 +63,8 @@ def _do_setup_platform(hass: HomeAssistant, config, async_add_entities : AddEnti |
63 | 63 | except BaseException as ex: |
64 | 64 | _LOGGER.error(f'Config error {ex} {sensor}') |
65 | 65 | raise |
66 | | - hass_sensors.append(SolarmanStatus(inverter_name, inverter, "status_lastUpdate", inverter_sn)) |
67 | | - hass_sensors.append(SolarmanStatus(inverter_name, inverter, "status_connection", inverter_sn)) |
| 66 | + hass_sensors.append(SolarmanStatusDiag(inverter_name, inverter, "status_lastUpdate", inverter_sn)) |
| 67 | + hass_sensors.append(SolarmanStatusDiag(inverter_name, inverter, "status_connection", inverter_sn)) |
68 | 68 |
|
69 | 69 | _LOGGER.debug(f'sensor.py:_do_setup_platform: async_add_entities') |
70 | 70 | _LOGGER.debug(hass_sensors) |
@@ -160,6 +160,14 @@ def state(self): |
160 | 160 | def update(self): |
161 | 161 | self.p_state = getattr(self.inverter, self._field_name, None) |
162 | 162 |
|
| 163 | +############################################################################################################# |
| 164 | +# This is the the same of SolarmanStatus, but it has EntityCategory setup to Diagnostic. |
| 165 | +############################################################################################################# |
| 166 | + |
| 167 | +class SolarmanStatusDiag(SolarmanStatus): |
| 168 | + def __init__(self, inverter_name, inverter, field_name, sn): |
| 169 | + super().__init__(inverter_name, inverter, field_name, sn) |
| 170 | + self._attr_entity_category = EntityCategory.DIAGNOSTIC |
163 | 171 |
|
164 | 172 | ############################################################################################################# |
165 | 173 | # Entity displaying a text field read from the inverter |
|
0 commit comments