Add suggested_area support to Apple TV (#47015)

This commit is contained in:
J. Nick Koston 2021-03-08 07:39:57 -10:00 committed by GitHub
parent 8018097c54
commit 9d14ff8105
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -348,10 +348,16 @@ class AppleTVManager:
"name": self.config_entry.data[CONF_NAME],
}
area = attrs["name"]
name_trailer = f" {DEFAULT_NAME}"
if area.endswith(name_trailer):
area = area[: -len(name_trailer)]
attrs["suggested_area"] = area
if self.atv:
dev_info = self.atv.device_info
attrs["model"] = "Apple TV " + dev_info.model.name.replace("Gen", "")
attrs["model"] = DEFAULT_NAME + " " + dev_info.model.name.replace("Gen", "")
attrs["sw_version"] = dev_info.version
if dev_info.mac: