33from homeassistant .components import persistent_notification
44from homeassistant .helpers .device_registry import DeviceInfo
55from homeassistant .helpers .update_coordinator import CoordinatorEntity
6+ from homeassistant .util import slugify
67
78from ..const import _LOGGER , DOMAIN
89from ..modules .device import Device
@@ -23,11 +24,12 @@ def __init__(self, name, device: Device, option=None) -> None:
2324 self ._attr_device_id = f"{ device .type } _{ device .mac } "
2425 self ._attr_unique_id = f"{ self ._attr_device_id } -{ name } "
2526 mac = device .mac [- 4 :] if device .mac else device .id
26- self .entity_id = f"{ DOMAIN } .{ device .type .lower ()} _{ mac } _{ name } "
27+ object_id = f"{ device .type } _{ mac } _{ name } "
28+ self .entity_id = f"{ DOMAIN } .{ slugify (object_id )} "
2729 self ._attr_icon = self ._option .get ("icon" )
2830 self ._attr_device_class = self ._option .get ("class" )
29- self ._attr_unit_of_measurement = self ._option .get ("unit" )
30- self ._attr_state_class = option .get ("state_class" )
31+ self ._attr_native_unit_of_measurement = self ._option .get ("unit" )
32+ self ._attr_state_class = self . _option .get ("state_class" )
3133 self ._attr_device_info = DeviceInfo (
3234 identifiers = {(DOMAIN , self ._attr_device_id )},
3335 name = device .name ,
@@ -68,7 +70,7 @@ async def async_request_api(self, api, params=None, method="GET", **kwargs) -> d
6870 throw = kwargs .pop ("throw" , None )
6971 rdt = await self .account .request (api , params , method , ** kwargs )
7072 if throw :
71- persistent_notification .create (
73+ persistent_notification .async_create (
7274 self .hass ,
7375 f"{ rdt } " ,
7476 f"Request: { api } " ,
0 commit comments