You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hass-workstation-service/documentation/WMIQuery.md

7.6 KiB

WMIQuerySensor

The WMI query sensor is an advanced sensor that executes a user defined WMI query and exposes the result.

To use the WMI query sensor, you should create a WMI query and paste it in the box. For example, If you wanted to find the current CPU frequency you can use this command:

SELECT CurrentClockSpeed FROM Win32_Processor

which results in 4008 for my PC. Because this query returns a single value (CPU frequency in MHz), it can be used with the current WMI query sensor implementation.

The command sql SELECT * FROM Win32_Processor cannot be used because it returns |64|9|To Be Filled By O.E.M.|3| ... |GAME-PC-2016|8|1|False|False|, and the current WMI query implementation only supports commands that return a single value.

You can use WMI Explorer to construct a query, or alternatively look at the user submitted sensors below


User Submitted Sensor Examples

User Information

Data Query Example Response Info Contributor
Current User SELECT UserName FROM Win32_ComputerSystem Admin 🔗 @grizzlyjere

Network Information

Data Query Example Response Info Contributor
Get IPv4 Address SELECT IPv4Address FROM MSFT_NetIPAddress WHERE AddressFamily=2 AND AddressState=4 AND (PrefixOrigin=1 OR PrefixOrigin=3 OR PrefixOrigin=4) 192.168.1.101 🔗 @deftnerd
Link Speed SELECT Speed FROM MSFT_NetIPAddress WHERE AddressFamily=2 AND AddressState=4 AND (PrefixOrigin=1 OR PrefixOrigin=3 OR PrefixOrigin=4) 780000000 (In bps. Divide by 1,000,000 to get Mbps) 🔗 @deftnerd
Manufacturer SELECT DNSHostName FROM Win32_ComputerSystem mycomputer 🔗 @deftnerd

Hardware Information

Data Query Example Response Info Contributor
Manufacturer SELECT Manufacturer FROM Win32_ComputerSystem Dell Inc. 🔗 @deftnerd
Model SELECT Model FROM Win32_ComputerSystem OptiPlex 7010 🔗 @deftnerd
System is a VM SELECT HypervisorPresent FROM Win32_ComputerSystem 0 🔗 @deftnerd
Physical Processors SELECT NumberOfProcessors FROM Win32_ComputerSystem 1 🔗 @deftnerd
Logical Processors SELECT NumberOfLogicalProcessors FROM Win32_ComputerSystem 8 (Processors * Cores * Threads) 🔗 @deftnerd
System Type SELECT PCSystemType FROM Win32_ComputerSystem 1 (0=Unspecified, 1=Desktop, 2=Laptop, 3=Workstation, etc) 🔗 @deftnerd
Processor Architecture SELECT SystemType FROM Win32_ComputerSystem 64-bit Intel PC 🔗 @deftnerd

Power & Thermal Information

Data Query Example Response Info Contributor
Capable of Power Management SELECT PowerManagementSupported FROM Win32_ComputerSystem 1 (0=Unsupported, 1=Supported) 🔗 @deftnerd
Power Management State SELECT PowerState FROM Win32_ComputerSystem 1 (0=Unknown, 1=Full Power, 2=Low Power Mode, 3=Standby, etc) 🔗 @deftnerd
Power Supply State SELECT PowerSupplyState FROM Win32_ComputerSystem 3 (1=Other, 2=Unknown, 3=Safe, 4=Warning, 5=Critical, etc) 🔗 @deftnerd
Enclosure Thermal State SELECT ThermalState FROM Win32_ComputerSystem 3 (1=Other, 2=Unknown, 3=Safe, 4=Warning, 5=Critical, etc) 🔗 @deftnerd
Battery Status SELECT BatteryStatus FROM Win32_Battery 2 (1=Discharging, 2=On AC, 3=Fully Charged, 4=Low, 5=Critical, 6=Charging, etc) 🔗 @deftnerd
% Charge Remaining SELECT EstimatedChargeRemaining FROM Win32_Battery 80 🔗 @deftnerd
Remaining Battery Minutes SELECT EstimatedRunTime FROM Win32_Battery 142 🔗 @deftnerd
Max Minutes of Battery SELECT ExpectedLife FROM Win32_Battery 230 🔗 @deftnerd
Minutes to Full Charge SELECT TimeToFullCharge FROM Win32_Battery 14 🔗 @deftnerd
Max Minutes to Recharge SELECT MaxRechargeTime FROM Win32_Battery 65 🔗 @deftnerd
Time on Battery in Seconds SELECT TimeOnBattery FROM Win32_Battery 3640 (0=plugged in) 🔗 @deftnerd

Windows System Assessment Tool Results

Data Query Example Response Info Contributor
Overall score SELECT CPUScore FROM Win32_WinSAT 5.8 🔗 @deftnerd
CPU Score SELECT CPUScore FROM Win32_WinSAT 9.1 🔗 @deftnerd
Disk Score SELECT DiskScore FROM Win32_WinSAT 7.75 🔗 @deftnerd
Graphics Score SELECT GraphicsScore FROM Win32_WinSAT 5.8 🔗 @deftnerd
Memory Score SELECT MemoryScore FROM Win32_WinSAT 9.1 🔗 @deftnerd

Software Information

Data Query Example Response Info Contributor
AntiSpyware Product SELECT displayName FROM AntiSpywareProduct Windows Defender @deftnerd
AntiVirus Product SELECT displayName FROM AntiVirusProduct Windows Defender @deftnerd

Process Information

Data Query Example Response Info Contributor
Is program x running? SELECT ProcessId FROM Win32_Process WHERE Name='notepad.exe' 1842 🔗 @lafferlaffer