bug fixes
This commit is contained in:
49
custom_components/fpl/fplEntity.py
Normal file
49
custom_components/fpl/fplEntity.py
Normal file
@@ -0,0 +1,49 @@
|
||||
"""BlueprintEntity class"""
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN, VERSION, ATTRIBUTION
|
||||
|
||||
|
||||
class FplEntity(CoordinatorEntity):
|
||||
def __init__(self, coordinator, config_entry, account, sensorName):
|
||||
super().__init__(coordinator)
|
||||
self.config_entry = config_entry
|
||||
self.account = account
|
||||
self.sensorName = sensorName
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the ID of this device."""
|
||||
id = "{}{}{}".format(
|
||||
DOMAIN, self.account, self.sensorName.lower().replace(" ", "")
|
||||
)
|
||||
return id
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return f"{DOMAIN.upper()} {self.account} {self.sensorName}"
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self.account)},
|
||||
"name": f"Account {self.account}",
|
||||
"model": VERSION,
|
||||
"manufacturer": "Florida Power & Light",
|
||||
}
|
||||
|
||||
def defineAttributes(self):
|
||||
return {}
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
attributes = {
|
||||
"attribution": ATTRIBUTION,
|
||||
"integration": "FPL",
|
||||
}
|
||||
attributes.update(self.defineAttributes())
|
||||
return attributes
|
||||
|
||||
def getData(self, field):
|
||||
return self.coordinator.data.get(self.account).get(field)
|
||||
Reference in New Issue
Block a user