diff --git a/homeassistant/components/squeezebox/coordinator.py b/homeassistant/components/squeezebox/coordinator.py index ef0a5c31b20..4d949bbdf11 100644 --- a/homeassistant/components/squeezebox/coordinator.py +++ b/homeassistant/components/squeezebox/coordinator.py @@ -51,23 +51,26 @@ class LMSStatusDataUpdateCoordinator(DataUpdateCoordinator): if not data: raise UpdateFailed("No data from status poll") - _LOGGER.debug("Raw serverstatus %s=%s", self.my_api.name, data) - # Sensor that need special handling + + return self._prepare_status_data(data) + + def _prepare_status_data(self, data: dict) -> dict: + """Sensors that need the data changing for HA presentation.""" + # 'lastscan': '1718431678', epoc -> ISO 8601 not always present data[STATUS_SENSOR_LASTSCAN] = ( STATUS_SENSOR_LASTSCAN in data and dt_util.utc_from_timestamp(int(data[STATUS_SENSOR_LASTSCAN])) or None ) - # rescan # bool are we rescanning alter poll not always present + # rescan bool are we rescanning alter poll not always present data[STATUS_SENSOR_RESCAN] = STATUS_SENSOR_RESCAN in data and True or False # needsrestart bool plugin updates... not always present data[STATUS_SENSOR_NEEDSRESTART] = ( STATUS_SENSOR_NEEDSRESTART in data and True or False ) - # newversion str not always present - # Sample text 'A new version of Logitech Media Server is available (8.5.2 - 0). Click here for further information.' + # newversion str not always present and we wish to remove the link supplied for now data[STATUS_SENSOR_NEWVERSION] = ( STATUS_SENSOR_NEWVERSION in data and self.newversion_regex.sub("...", data[STATUS_SENSOR_NEWVERSION]) @@ -77,10 +80,4 @@ class LMSStatusDataUpdateCoordinator(DataUpdateCoordinator): data[STATUS_SENSOR_NEWPLUGINS] = ( STATUS_SENSOR_NEWPLUGINS in data and data[STATUS_SENSOR_NEWPLUGINS] or None ) - - # "info total duration" in fractions of seconds - # progressdone Returned with the current value of items completed for current scan phase. Not returned if no scan is in progress. - # progresstotal Returned with the total value of items found for current scan phase. Not returned if no scan is in progress. - # lastscanfailed Information about a possible failure in case a scan has not finished in an attended manner. _LOGGER.debug("Processed serverstatus %s=%s", self.my_api.name, data) - return data