def device_info(self) -> DeviceInfo: """Return general device information.""" properties = self._all_properties() if Protocol.MRP in self._services: os_type = OperatingSystem.TvOS elif Protocol.DMAP in self._services: os_type = OperatingSystem.Legacy else: os_type = OperatingSystem.Unknown build = properties.get("SystemBuildVersion") version = properties.get("osvers", lookup_version(build)) model_name: Optional[str] = properties.get("model", None) if model_name: model = lookup_model(model_name) else: model = self._model mac = properties.get("macAddress", properties.get("deviceid")) if mac: mac = mac.upper() return DeviceInfo(os_type, version, build, model, mac)
def device_info(service_type: str, properties: Mapping[str, Any]) -> Dict[str, Any]: """Return device information from zeroconf properties.""" devinfo: Dict[str, Any] = {} if "rpmd" in properties: model = lookup_model(properties["rpmd"]) devinfo[DeviceInfo.RAW_MODEL] = properties["rpmd"] if model != DeviceModel.Unknown: devinfo[DeviceInfo.MODEL] = model return devinfo
def _device_info() -> Dict[str, Any]: devinfo = device_info(list(scan().keys())[0], core.service.properties) # Extract build number from DEVICE_INFO_MESSAGE from device if protocol.device_info: info = protocol.device_info.inner() # type: ignore devinfo[DeviceInfo.BUILD_NUMBER] = info.systemBuildVersion if info.modelID: devinfo[DeviceInfo.RAW_MODEL] = info.modelID devinfo[DeviceInfo.MODEL] = lookup_model(info.modelID) return devinfo
def device_info(self) -> DeviceInfo: """Return general device information.""" properties = self._all_properties() build: Optional[str] = properties.get("systembuildversion") version = properties.get("ov") if not version: version = properties.get("osvers", lookup_version(build)) model_name: Optional[str] = properties.get("model", properties.get("am")) if model_name: model = lookup_model(model_name) else: model = self._model # MRP devices run tvOS (as far as we know now) as well as HomePods for # some reason if Protocol.MRP in self._services or model in [ DeviceModel.HomePod, DeviceModel.HomePodMini, ]: os_type = OperatingSystem.TvOS elif Protocol.DMAP in self._services: os_type = OperatingSystem.Legacy elif model in [ DeviceModel.AirPortExpress, DeviceModel.AirPortExpressGen2 ]: os_type = OperatingSystem.AirPortOS else: os_type = OperatingSystem.Unknown mac = properties.get("macaddress", properties.get("deviceid")) if mac: mac = mac.upper() # The waMA property comes from the _airport._tcp.local service, announced by # AirPort Expresses (used by the admin tool). It contains various information, # for instance MAC address and software version. wama = properties.get("wama") if wama: props: Mapping[str, str] = dict( cast(Tuple[str, str], prop.split("=", maxsplit=1)) for prop in ("macaddress=" + wama).split(",")) if not mac: mac = props["macaddress"].replace("-", ":").upper() version = props.get("syVs") return DeviceInfo(os_type, version, build, model, mac)
def device_info(service_type: str, properties: Mapping[str, Any]) -> Dict[str, Any]: """Return device information from zeroconf properties.""" devinfo: Dict[str, Any] = {} if "am" in properties: model = lookup_model(properties["am"]) devinfo[DeviceInfo.RAW_MODEL] = properties["am"] if model != DeviceModel.Unknown: devinfo[DeviceInfo.MODEL] = model if "ov" in properties: devinfo[DeviceInfo.VERSION] = properties["ov"] # This comes from _airport._tcp.local and belongs to AirPort Expresses if "wama" in properties: props: Mapping[str, str] = dict( cast(Tuple[str, str], prop.split("=", maxsplit=1)) for prop in ("macaddress=" + properties["wama"]).split(",")) if DeviceInfo.MAC not in devinfo: devinfo[DeviceInfo.MAC] = props["macaddress"].replace("-", ":").upper() if "syVs" in props: devinfo[DeviceInfo.VERSION] = props["syVs"] return devinfo
def test_lookup_model(model_str, expected_model): assert lookup_model(model_str) == expected_model
def test_lookup_existing_model(): assert lookup_model("AppleTV6,2") == DeviceModel.Gen4K
def test_lookup_missing_model(): assert lookup_model("bad_model") == DeviceModel.Unknown
def test_lookup_homepod(): assert lookup_model("AudioAccessory5,1") == DeviceModel.HomePodMini
def test_lookup_existing_model(self): self.assertEqual(lookup_model("AppleTV6,2"), DeviceModel.Gen4K)
def test_lookup_missing_model(self): self.assertEqual(lookup_model("bad_model"), DeviceModel.Unknown)