bkbilly / lnxlink

🖥 Effortlessly manage your Linux machine using MQTT.

Home Page:https://bkbilly.gitbook.io/lnxlink

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory Reporting Enhancements

beecho01 opened this issue · comments

Describe the solution you'd like
I am proposing the inclusion of additional Memory measurements, not just percentage, but the addition of In-Use and Total. This appears as an available option of the current psutil utility.

Additional context
I believe I have identified the python code needed, but its my first go at python, so may be incorrect.

# Memory In-Use

import psutil

class Addon():

    def __init__(self, lnxlink):
        self.name = 'Memory In Use'
        self.sensor_type = 'sensor'
        self.icon = 'mdi:memory'
        self.unit = 'GB'
        self.state_class = 'measurement'
        self.device_class = 'data_size'

    def getInfo(self):
        memory_info = psutil.virtual_memory().used
        in_use_gb = round(memory_info / 1024 ** 3, 1)
        return in_use_gb
# Memory Total

import psutil

class Addon():

    def __init__(self, lnxlink):
        self.name = 'Memory Total'
        self.sensor_type = 'sensor'
        self.icon = 'mdi:memory'
        self.unit = 'GB'
        self.state_class = 'measurement'
        self.device_class = 'data_size'

    def getInfo(self):
        memory_info = psutil.virtual_memory().total
        total_gb = round(memory_info / 1024 ** 3, 1)
        return total_gb

I will add this on the next release.

I've released the new version 2023.6.0 which includes the percentage, used and available memory.
Make sure you read the release notes.