- updated devices to utilize serial or mac address

This commit is contained in:
Jack Simbach 2021-08-21 22:17:54 -04:00
parent e07a1043a1
commit ff72fa2bc9
2 changed files with 14 additions and 6 deletions

View File

@ -60,6 +60,16 @@ class ApplianceApi:
def serial_number(self) -> str: def serial_number(self) -> str:
return self.appliance.get_erd_value(ErdCode.SERIAL_NUMBER) return self.appliance.get_erd_value(ErdCode.SERIAL_NUMBER)
@property
def mac_addr(self) -> str:
return self.appliance.mac_addr
@property
def serial_or_mac(self) -> str:
if self.serial_number and not self.serial_number.isspace():
return self.serial_number
return self.mac_addr
@property @property
def model_number(self) -> str: def model_number(self) -> str:
return self.appliance.get_erd_value(ErdCode.MODEL_NUMBER) return self.appliance.get_erd_value(ErdCode.MODEL_NUMBER)
@ -78,14 +88,14 @@ class ApplianceApi:
appliance_type = "Appliance" appliance_type = "Appliance"
else: else:
appliance_type = appliance_type.name.replace("_", " ").title() appliance_type = appliance_type.name.replace("_", " ").title()
return f"GE {appliance_type} {self.serial_number}" return f"GE {appliance_type} {self.serial_or_mac}"
@property @property
def device_info(self) -> Dict: def device_info(self) -> Dict:
"""Device info dictionary.""" """Device info dictionary."""
return { return {
"identifiers": {(DOMAIN, self.serial_number)}, "identifiers": {(DOMAIN, self.serial_or_mac)},
"name": self.name, "name": self.name,
"manufacturer": "GE", "manufacturer": "GE",
"model": self.model_number, "model": self.model_number,

View File

@ -38,13 +38,11 @@ class GeEntity:
@property @property
def mac_addr(self) -> str: def mac_addr(self) -> str:
return self.api.appliance.mac_addr return self.api.mac_addr
@property @property
def serial_or_mac(self) -> str: def serial_or_mac(self) -> str:
if self.serial_number and not self.serial_number.isspace(): return self.api.serial_or_mac
return self.serial_number
return self.mac_addr
@property @property
def name(self) -> Optional[str]: def name(self) -> Optional[str]: