Skip to content

Commit

Permalink
Some more Device_Classes and two digit CPU_Temp (#140)
Browse files Browse the repository at this point in the history
* Added data["device_class"] = "temperature" to align with other temperature values.

* Device_Class = temperature also for device + "_temp"

* Added some more device_classes: voltage, frequency, duration, signal_strength
Changed 'check_cpu_temp' to work with locale "DE" and showing 2 digits
(maybe this needs to be double checked on different systems/hardware)

* Bugfix: changed unit_of_measurement from days to d
to suppress warning: ... using native unit of measurement 'days' which is not a valid unit for the device class ('duration') it is using; expected one of ['h', 'ms', 'd', 's', 'min']; in homeassistant log
  • Loading branch information
amse2000 authored Oct 21, 2024
1 parent 778c0b2 commit b615f7f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/rpi-cpu2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ def config_json(what_config, device=0):
data["icon"] = "mdi:flash"
data["name"] = "CPU Voltage"
data["unit_of_measurement"] = "V"
data["device_class"] = "voltage"
data["state_class"] = "measurement"
elif what_config == "swap":
data["icon"] = "mdi:harddisk"
Expand All @@ -375,11 +376,13 @@ def config_json(what_config, device=0):
data["icon"] = "mdi:speedometer"
data["name"] = "CPU Clock Speed"
data["unit_of_measurement"] = "MHz"
data["device_class"] = "frequency"
data["state_class"] = "measurement"
elif what_config == "uptime_days":
data["icon"] = "mdi:calendar"
data["name"] = "Uptime"
data["unit_of_measurement"] = "days"
data["unit_of_measurement"] = "d"
data["device_class"] = "duration"
data["state_class"] = "total_increasing"
elif what_config == "uptime_seconds":
data["icon"] = "mdi:timer-outline"
Expand All @@ -396,6 +399,7 @@ def config_json(what_config, device=0):
data["icon"] = "mdi:wifi"
data["name"] = "Wifi Signal"
data["unit_of_measurement"] = "dBm"
data["device_class"] = "signal_strength"
data["state_class"] = "measurement"
elif what_config == "rpi5_fan_speed":
data["icon"] = "mdi:fan"
Expand Down

0 comments on commit b615f7f

Please sign in to comment.