add logical cores sensor #12
3 changed files with 15 additions and 7 deletions
|
@ -15,7 +15,7 @@
|
|||
};
|
||||
packages.ha-mqtt-agent = pkgs.python3Packages.buildPythonApplication {
|
||||
pname = "ha-mqtt-agent";
|
||||
version = "0.3.11";
|
||||
version = "0.3.12";
|
||||
src = ./.;
|
||||
|
||||
build-system = with pkgs.python3Packages; [ setuptools ];
|
||||
|
|
|
@ -9,16 +9,24 @@ from ha_mqtt_agent.sensor import BaseSensor, Factory
|
|||
|
||||
class CPUSensor(BaseSensor):
|
||||
value = -1
|
||||
cpu_count_sensor = None
|
||||
cpu_logical_cores_sensor = None
|
||||
cpu_physical_cores_sensor = None
|
||||
cpu_sensor = None
|
||||
|
||||
def setup(self, device: Device):
|
||||
cpu_count_info = ha_mqtt_discoverable.sensors.SensorInfo(
|
||||
name="CPU Count",
|
||||
cpu_logical_cores_info = ha_mqtt_discoverable.sensors.SensorInfo(
|
||||
name="CPU Count (Logical)",
|
||||
icon="mdi:chip",
|
||||
)
|
||||
self.cpu_count_sensor = Factory.sensor(cpu_count_info, device)
|
||||
self.cpu_count_sensor.set_state(psutil.cpu_count(logical=False))
|
||||
self.cpu_logical_cores_sensor = Factory.sensor(cpu_logical_cores_info, device)
|
||||
self.cpu_logical_cores_sensor.set_state(psutil.cpu_count(logical=True))
|
||||
|
||||
cpu_physical_cores_info = ha_mqtt_discoverable.sensors.SensorInfo(
|
||||
name="CPU Count (Physical)",
|
||||
icon="mdi:chip",
|
||||
)
|
||||
self.cpu_physical_cores_sensor = Factory.sensor(cpu_physical_cores_info, device)
|
||||
self.cpu_physical_cores_sensor.set_state(psutil.cpu_count(logical=False))
|
||||
|
||||
cpu_info = ha_mqtt_discoverable.sensors.SensorInfo(
|
||||
name="CPU Load (%)",
|
||||
|
|
2
setup.py
2
setup.py
|
@ -4,7 +4,7 @@ from setuptools import setup, find_packages
|
|||
|
||||
setup(
|
||||
name="ha-mqtt-agent",
|
||||
version="0.3.11",
|
||||
version="0.3.12",
|
||||
packages=find_packages(),
|
||||
scripts=["ha-mqtt-agent"],
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue