diff --git a/homeassistant/components/esphome/__init__.py b/homeassistant/components/esphome/__init__.py index 6c51de2d8de..97b459ae0cd 100644 --- a/homeassistant/components/esphome/__init__.py +++ b/homeassistant/components/esphome/__init__.py @@ -13,6 +13,7 @@ from aioesphomeapi import ( APIIntEnum, APIVersion, DeviceInfo as EsphomeDeviceInfo, + EntityCategory, EntityInfo, EntityState, HomeassistantServiceCall, @@ -32,6 +33,8 @@ from homeassistant.const import ( CONF_MODE, CONF_PASSWORD, CONF_PORT, + ENTITY_CATEGORY_CONFIG, + ENTITY_CATEGORY_DIAGNOSTIC, EVENT_HOMEASSISTANT_STOP, ) from homeassistant.core import Event, HomeAssistant, ServiceCall, State, callback @@ -640,6 +643,15 @@ class EsphomeEnumMapper(Generic[_EnumT, _ValT]): ICON_SCHEMA = vol.Schema(cv.icon) +ENTITY_CATEGORIES: EsphomeEnumMapper[EntityCategory, str | None] = EsphomeEnumMapper( + { + EntityCategory.NONE: None, + EntityCategory.CONFIG: ENTITY_CATEGORY_CONFIG, + EntityCategory.DIAGNOSTIC: ENTITY_CATEGORY_DIAGNOSTIC, + } +) + + class EsphomeEntity(Entity, Generic[_InfoT, _StateT]): """Define a base esphome entity.""" @@ -781,3 +793,10 @@ class EsphomeEntity(Entity, Generic[_InfoT, _StateT]): def entity_registry_enabled_default(self) -> bool: """Return if the entity should be enabled when first added to the entity registry.""" return not self._static_info.disabled_by_default + + @property + def entity_category(self) -> str | None: + """Return the category of the entity, if any.""" + if not self._static_info.entity_category: + return None + return ENTITY_CATEGORIES.from_esphome(self._static_info.entity_category) diff --git a/homeassistant/components/esphome/manifest.json b/homeassistant/components/esphome/manifest.json index 0bbdc454167..4b54a4d7883 100644 --- a/homeassistant/components/esphome/manifest.json +++ b/homeassistant/components/esphome/manifest.json @@ -3,7 +3,7 @@ "name": "ESPHome", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/esphome", - "requirements": ["aioesphomeapi==10.0.0"], + "requirements": ["aioesphomeapi==10.1.0"], "zeroconf": ["_esphomelib._tcp.local."], "codeowners": ["@OttoWinter", "@jesserockz"], "after_dependencies": ["zeroconf", "tag"], diff --git a/requirements_all.txt b/requirements_all.txt index f03e19f535c..b76b59fac3a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -161,7 +161,7 @@ aioeagle==1.1.0 aioemonitor==1.0.5 # homeassistant.components.esphome -aioesphomeapi==10.0.0 +aioesphomeapi==10.1.0 # homeassistant.components.flo aioflo==0.4.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index b77e9f5a0e9..9a3732274c7 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -109,7 +109,7 @@ aioeagle==1.1.0 aioemonitor==1.0.5 # homeassistant.components.esphome -aioesphomeapi==10.0.0 +aioesphomeapi==10.1.0 # homeassistant.components.flo aioflo==0.4.1