{"record":{"id":"ba8cfe11b63e1676","repo":"nicolargo/glances","slug":"unsupported-sensor-self-sensor-type","errorCode":null,"errorMessage":"Unsupported sensor: {self.sensor_type}","messagePattern":"Unsupported sensor: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"glances/plugins/sensors/__init__.py","lineNumber":353,"sourceCode":"            self.__fetch_data()\n            self.init = True\n        except AttributeError:\n            logger.debug(f\"Cannot grab {self.sensor_type}. Platform not supported.\")\n\n    def __fetch_data(self) -> dict[str, list]:\n        if self.sensor_type == sensors_definition.get('cpu_temp').get('type'):\n            # Solve an issue #1203 concerning a RunTimeError warning message displayed\n            # in the curses interface.\n            warnings.filterwarnings(\"ignore\")\n\n            # psutil>=5.1.0, Linux-only\n            return psutil.sensors_temperatures()\n\n        if self.sensor_type == sensors_definition.get('fan_speed').get('type'):\n            # psutil>=5.2.0, Linux-only\n            return psutil.sensors_fans()\n\n        raise ValueError(f\"Unsupported sensor: {self.sensor_type}\")\n\n    def update(self) -> list[dict]:\n        \"\"\"Update the stats.\"\"\"\n        if not self.init:\n            return []\n\n        # Temperatures sensors\n        ret = []\n        data = self.__fetch_data()\n        for chip_name, chip in data.items():\n            label_index = 1\n            for chip_name_index, feature in enumerate(chip):\n                sensors_current = {}\n                # Sensor name\n                if feature.label == '':\n                    sensors_current['label'] = chip_name + ' ' + str(chip_name_index)\n                elif feature.label in [i['label'] for i in ret]:\n                    sensors_current['label'] = feature.label + ' ' + str(label_index)","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/plugins/sensors/__init__.py#L335-L371","documentation":"ValueError raised by the sensors subsystem's data fetch when self.sensor_type does not match any known sensor definition (temperature via psutil.sensors_temperatures or fan speed via psutil.sensors_fans). It signals an internal misconfiguration of the sensor type string, since only those two psutil backends exist.","triggerScenarios":"__init__ or update() of the sensors plugin running with a sensor_type not equal to the 'temperature' or 'fan_speed' definitions from sensors_definition — e.g. a custom/renamed definition dict or a code path passing the raw config name instead of the definition's type field.","commonSituations":"Forks adding new sensor kinds (e.g. battery/current) without extending __fetch_data; upstream renames of the definitions dict keys; typo'd sensor type strings in custom configs.","solutions":["Pass the exact value of sensors_definition['temperature'/'fan_speed']['type'] as sensor_type","If adding a new sensor kind, add a matching branch or map it to an existing psutil backend in __fetch_data","Update to matching upstream versions so definitions and fetch logic stay in sync"],"exampleFix":"# before\ns = GlancesSensors(sensor_type='temp')\n# after\nfrom glances.plugins.sensors.sensors_definition import sensors_definition\ns = GlancesSensors(sensor_type=sensors_definition['temperature']['type'])","handlingStrategy":"validation","validationCode":"from glances.plugins.sensors.sensors_definition import sensors_definition\nvalid_types = {d['type'] for d in sensors_definition.values()}\nassert sensor_type in valid_types","typeGuard":"def supported_sensor(t: str) -> bool:\n    from glances.plugins.sensors.sensors_definition import sensors_definition\n    return t in {d['type'] for d in sensors_definition.values()}","tryCatchPattern":"try:\n    data = fetcher.__fetch_data()\nexcept ValueError as e:\n    if 'Unsupported sensor' in str(e):\n        data = None\n    else:\n        raise","preventionTips":["Always source sensor_type from sensors_definition, never hardcode","Extend __fetch_data when adding new sensor kinds","Keep definitions and fetch logic from the same release"],"tags":["glances","sensors","value-error","psutil"],"backgroundTag":"unsupported-enum-value","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}