{"id":26189078,"url":"https://github.com/snip3rnick/pyhardwaremonitor","last_synced_at":"2025-04-15T01:31:13.118Z","repository":{"id":57728672,"uuid":"527322450","full_name":"snip3rnick/PyHardwareMonitor","owner":"snip3rnick","description":"Thin Python layer for LibreHardwareMonitor","archived":false,"fork":false,"pushed_at":"2024-11-08T14:30:23.000Z","size":858,"stargazers_count":19,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T13:21:36.094Z","etag":null,"topics":["hardware","hardware-information","libre-hardware-monitor","monitoring","open-source","opensource","python3","system","system-monitoring","system-monitoring-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snip3rnick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-08-21T20:44:12.000Z","updated_at":"2025-03-21T19:54:47.000Z","dependencies_parsed_at":"2024-03-11T19:52:51.993Z","dependency_job_id":null,"html_url":"https://github.com/snip3rnick/PyHardwareMonitor","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snip3rnick%2FPyHardwareMonitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snip3rnick%2FPyHardwareMonitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snip3rnick%2FPyHardwareMonitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snip3rnick%2FPyHardwareMonitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snip3rnick","download_url":"https://codeload.github.com/snip3rnick/PyHardwareMonitor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248989130,"owners_count":21194534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hardware","hardware-information","libre-hardware-monitor","monitoring","open-source","opensource","python3","system","system-monitoring","system-monitoring-api"],"created_at":"2025-03-12T00:30:19.608Z","updated_at":"2025-04-15T01:31:13.101Z","avatar_url":"https://github.com/snip3rnick.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyHardwareMonitor\n\nPython Harware Monitor is a thin package layer for [`LibreHardwareMonitorLib`](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor) using [`pythonnet`](https://github.com/pythonnet/pythonnet). \nLibre Hardware Monitor, a fork of Open Hardware Monitor, is free software that can monitor the temperature sensors, fan speeds, voltages, load and clock speeds of your computer. \nThis package is mostly auto generated using the [`pythonstubs`](https://github.com/mcneel/pythonstubs) generator tool for .NET libraries.\nScripts for generating, altering and extending package resources are located in the [scripts folder](https://github.com/snip3rnick/PyHardwareMonitor/tree/main/scripts).\n\nThe purpose of this layer is the ability to provide extensive typing information and additional utilities around the LibreHardwareMonitorLib.\n\n\u003e **Note:** Python must have **admin privileges** for `HardwareMonitor` to be able to access all available sensors properly!\n\n\n## Prerequisites\n- Python 3.6+\n  - pythonnet\n  - .NET 4.7\n\n\n## Installation\n\nInstall from PyPi directly\n```\npip3 install HardwareMonitor\n```\n\nor install locally from source\n\n```\ngit clone https://github.com/snip3rnick/PyHardwareMonitor\ncd PyHardwareMonitor\npip3 install .\n```\n\n\n## Basic Usage\n\nThis simple example is a python adaptation of the [**C#** example of the LibreHardwareMonitor repository](https://github.com/LibreHardwareMonitor/LibreHardwareMonitor#whats-the-easiest-way-to-start).\n\n```python\nfrom HardwareMonitor.Hardware import *  # equivalent to 'using LibreHardwareMonitor.Hardware;'\n\nclass UpdateVisitor(IVisitor):\n    __namespace__ = \"TestHardwareMonitor\"  # must be unique among implementations of the IVisitor interface\n    def VisitComputer(self, computer: IComputer):\n        computer.Traverse(self);\n\n    def VisitHardware(self, hardware: IHardware):\n        hardware.Update()\n        for subHardware in hardware.SubHardware:\n            subHardware.Update()\n\n    def VisitParameter(self, parameter: IParameter): pass\n\n    def VisitSensor(self, sensor: ISensor): pass\n\n\ncomputer = Computer()  # settings can not be passed as constructor argument (following below)\ncomputer.IsMotherboardEnabled = True\ncomputer.IsControllerEnabled = True\ncomputer.IsCpuEnabled = True\ncomputer.IsGpuEnabled = True\ncomputer.IsBatteryEnabled = True\ncomputer.IsMemoryEnabled = True\ncomputer.IsNetworkEnabled = True\ncomputer.IsStorageEnabled = True\n\ncomputer.Open()\ncomputer.Accept(UpdateVisitor())\n\nfor hardware in computer.Hardware:\n    print(f\"Hardware: {hardware.Name}\")\n    for subhardware  in hardware.SubHardware:\n        print(f\"\\tSubhardware: {subhardware.Name}\")\n        for sensor in subhardware.Sensors:\n            print(f\"\\t\\tSensor: {sensor.Name}, value: {sensor.Value}\")\n    for sensor in hardware.Sensors:\n        print(f\"\\tSensor: {sensor.Name}, value: {sensor.Value}\")\n\ncomputer.Close()\n```\n\n---\n\n## Utilities\n\nUtilities are located in the `HardwareMonitor.Util` module.\n\n### Function `OpenComputer`\n\nThe `OpenComputer` function provides a shorthand for creating the `HardwareMonitor.Hardware.Computer` instance including the settings and update visitor.  \nSettings are given as keyword arguments, the following example enables just the `cpu` and `motherboard` component.\n\n```python\ncomputer = OpenComputer(cpu=True, motherboard=True)  # use 'all=True' to enable every component\n# Access sensors\n...\ncomputer.Update()  # Updates all sensors\n...\ncomputer.Close()\n```\n\n### Function `ToBuiltinTypes`\n\nInstances from the `HardwareMonitor` module can be reduced to primitive python types instead of `HardwareMonitor` object instances with the `ToBuiltinTypes` function.  \nObjects are recursively converted to Python builtin types (`dict`, `list`, ...).\nThis can be useful for applications that serialized the data (e.g. with json).\n\n```python\ncomputer = OpenComputer(cpu=True)\n\ndata = ToBuiltinTypes(computer.Hardware)\n# [{'Type': 'Hardware', 'HardwareType': 'Cpu', 'Name': 'Intel Core i5-8265U', 'Sensors': [...], 'SubHardware': [...]}]\n```\n\n### Function `GroupSensorsByType`\n\nSensors of an instance of `HardwareMonitor.Harware.Hardware` are held in a flat list.  \nThe helper function `GroupSensorsByType` converts the sensor list into a list of lists grouping sensors by type.\n\n```python\nGroupSensorsByType(sensors: Iterable[ISensor]) -\u003e List[List[ISensor]]\n```\n\n### Function `SensorValueToString`\n\nThe helper function `SensorValueToString` converts sensor values to strings appending with the appropriate unit.\n\n```python\nSensorValueToString(value: float, type: SensorType) -\u003e str\n# returns \"3100.0 MHz\" for value=3100.0 with type=SensorType.Clock\n```\n\n### Dictionary `HardwareTypeString` and `SensorTypeString`\n\nThese two mappings convert values for `HardwareType` (or `SensorType`) to a string.  \nBoth the integer value for the enum or the instances of the enum value (e.g. `HardwareType.Cpu`) are present as keys.\n\n\u003e In some environments the type fields were set to integers in others to the corresponding type instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnip3rnick%2Fpyhardwaremonitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnip3rnick%2Fpyhardwaremonitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnip3rnick%2Fpyhardwaremonitor/lists"}