forked from Limych/ha-average
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentity.py
38 lines (31 loc) · 1.11 KB
/
entity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""BlueprintEntity class."""
from homeassistant.const import ATTR_ATTRIBUTION, ATTR_ID
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import ATTR_INTEGRATION, ATTRIBUTION, DOMAIN, NAME, VERSION
class IntegrationBlueprintEntity(CoordinatorEntity):
"""Blueprint entity."""
def __init__(self, coordinator, config_entry):
"""Class initialization."""
super().__init__(coordinator)
self.config_entry = config_entry
@property
def unique_id(self):
"""Return a unique ID to use for this entity."""
return self.config_entry.entry_id
@property
def device_info(self):
"""Return the device info."""
return {
"identifiers": {(DOMAIN, self.unique_id)},
"name": NAME,
"model": VERSION,
"manufacturer": NAME,
}
@property
def device_state_attributes(self):
"""Return the state attributes."""
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_ID: str(self.coordinator.data.get("id")),
ATTR_INTEGRATION: DOMAIN,
}