Hey all,
Been messing around today, and I’ve converted the RAM Usage of the HASS Agent from Percent into Usage/Total.
Now, most people probably don’t need this, but I find it easier to visualize a number rather than a percentage, so I though I’d share in-case anyone wanted it. It does require the use of a WMI Sensor and a template sensor to achieve, at least, for me it did.
HASS Agent WMI Query Sensor:
WMI Query: SELECT Capacity FROM Win32_PhysicalMemory
Scope: \\.\Root\CIMV2
I called laptop_ramtotal, but obviously, feel free to call it what you wish.
Home Assistant Template Sensor:
- sensor:
- name: "RAM Usage"
state: >
{% set ram = states('sensor.laptop_memoryusage') | float %}
{% set ramTotal = states('sensor.laptop_ramtotal') | int * 2 / 1024 / 1024 / 1024 %}
{% set usage = ramTotal | float / 100 * ram | round(0, default=0) %}
{% set state = usage | string + "GB" + "/" + ramTotal | string + "GB" %}
{{state}}
The sensor makes the assumption that you have 2 identical sticks of RAM installed, which you should have for performance, but if you only have 1 stick, simply remove the * 2.
sensor.laptop_memoryusage is my percentage sensor reported by HASS Agent by default. I simply changed my entity in the card from the HASS Percent Entity to my own sensor.