Skip to content

Commit 26036d5

Browse files
Merge pull request #498 from virtualdj/feat-diagnostic-category
Move status entities to Diagnostic category
2 parents 355fb17 + 23d2dcf commit 26036d5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ Once the component is running, it will add the following entities to Home Assist
150150
151151
# Status Entities
152152
153-
Apart from the inverter-parameters, it will also add status entities to view the status of the solarman component.
153+
Apart from the inverter-parameters, it will also add status entities to view the status of the solarman component (in the **Diagnostic** category).
154154
![Component-status](./component_status.png)
155155
156156
# Energy Dashboard

custom_components/solarman/sensor.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import voluptuous as vol
1313
from homeassistant.core import HomeAssistant
1414
from homeassistant.config_entries import ConfigEntry
15-
from homeassistant.const import CONF_NAME
15+
from homeassistant.const import CONF_NAME, EntityCategory
1616
from homeassistant.helpers.entity import Entity
1717
from homeassistant.helpers.entity_platform import AddEntitiesCallback
1818

@@ -63,8 +63,8 @@ def _do_setup_platform(hass: HomeAssistant, config, async_add_entities : AddEnti
6363
except BaseException as ex:
6464
_LOGGER.error(f'Config error {ex} {sensor}')
6565
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))
6868

6969
_LOGGER.debug(f'sensor.py:_do_setup_platform: async_add_entities')
7070
_LOGGER.debug(hass_sensors)
@@ -160,6 +160,14 @@ def state(self):
160160
def update(self):
161161
self.p_state = getattr(self.inverter, self._field_name, None)
162162

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
163171

164172
#############################################################################################################
165173
# Entity displaying a text field read from the inverter

0 commit comments

Comments
 (0)