mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Add entity categories to esphome (#58495)
This commit is contained in:
parent
e2e19cf4b4
commit
c656bf1646
@ -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)
|
||||
|
@ -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"],
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user