Skip to content

Commit

Permalink
Convert entity class from str to enum #1316
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Apr 4, 2024
1 parent 23e0055 commit 534128c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/xiaomi_gateway3/hass/entity_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ def setup_entity_description(entity: Entity, conv: BaseConv) -> bool:
for k, v in desc.items():
if k == "lazy" or v is None:
continue
if k == "category":
if k == "category" and type(v) is str:
v = EntityCategory(v)
elif k == "class" and type(v) is str:
if domain_class := DOMAIN_CLASSES.get(conv.domain):
v = domain_class(v)
setattr(entity, ENTITY_KEYS.get(k) or k, v)

# sensor with unit_of_measurement and without state_class will be MEASUREMENT
Expand Down

0 comments on commit 534128c

Please sign in to comment.