remove hostname from data["name"] = hostname + " CPU Usage" ... due to home assistant naming convention
This commit is contained in:
@@ -31,7 +31,7 @@ def check_wifi_signal(format):
|
|||||||
wifi_signal = round((int(wifi_signal) / 70)* 100)
|
wifi_signal = round((int(wifi_signal) / 70)* 100)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
wifi_signal = 'NA'
|
wifi_signal = 0
|
||||||
|
|
||||||
return wifi_signal
|
return wifi_signal
|
||||||
|
|
||||||
@@ -165,57 +165,57 @@ def config_json(what_config):
|
|||||||
data["unique_id"] = hostname + "_" + what_config
|
data["unique_id"] = hostname + "_" + what_config
|
||||||
if what_config == "cpuload":
|
if what_config == "cpuload":
|
||||||
data["icon"] = "mdi:speedometer"
|
data["icon"] = "mdi:speedometer"
|
||||||
data["name"] = hostname + " CPU Usage"
|
data["name"] = "CPU Usage"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
data["unit_of_measurement"] = "%"
|
data["unit_of_measurement"] = "%"
|
||||||
elif what_config == "cputemp":
|
elif what_config == "cputemp":
|
||||||
data["icon"] = "hass:thermometer"
|
data["icon"] = "hass:thermometer"
|
||||||
data["name"] = hostname + " CPU Temperature"
|
data["name"] = "CPU Temperature"
|
||||||
data["unit_of_measurement"] = "°C"
|
data["unit_of_measurement"] = "°C"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "diskusage":
|
elif what_config == "diskusage":
|
||||||
data["icon"] = "mdi:harddisk"
|
data["icon"] = "mdi:harddisk"
|
||||||
data["name"] = hostname + " Disk Usage"
|
data["name"] = "Disk Usage"
|
||||||
data["unit_of_measurement"] = "%"
|
data["unit_of_measurement"] = "%"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "voltage":
|
elif what_config == "voltage":
|
||||||
data["icon"] = "mdi:flash"
|
data["icon"] = "mdi:flash"
|
||||||
data["name"] = hostname + " CPU Voltage"
|
data["name"] = "CPU Voltage"
|
||||||
data["unit_of_measurement"] = "V"
|
data["unit_of_measurement"] = "V"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "swap":
|
elif what_config == "swap":
|
||||||
data["icon"] = "mdi:harddisk"
|
data["icon"] = "mdi:harddisk"
|
||||||
data["name"] = hostname + " Disk Swap"
|
data["name"] = "Disk Swap"
|
||||||
data["unit_of_measurement"] = "%"
|
data["unit_of_measurement"] = "%"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "memory":
|
elif what_config == "memory":
|
||||||
data["icon"] = "mdi:memory"
|
data["icon"] = "mdi:memory"
|
||||||
data["name"] = hostname + " Memory Usage"
|
data["name"] = "Memory Usage"
|
||||||
data["unit_of_measurement"] = "%"
|
data["unit_of_measurement"] = "%"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "sys_clock_speed":
|
elif what_config == "sys_clock_speed":
|
||||||
data["icon"] = "mdi:speedometer"
|
data["icon"] = "mdi:speedometer"
|
||||||
data["name"] = hostname + " CPU Clock Speed"
|
data["name"] = "CPU Clock Speed"
|
||||||
data["unit_of_measurement"] = "MHz"
|
data["unit_of_measurement"] = "MHz"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "uptime_days":
|
elif what_config == "uptime_days":
|
||||||
data["icon"] = "mdi:calendar"
|
data["icon"] = "mdi:calendar"
|
||||||
data["name"] = hostname + " Uptime"
|
data["name"] = "Uptime"
|
||||||
data["unit_of_measurement"] = "days"
|
data["unit_of_measurement"] = "days"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "wifi_signal":
|
elif what_config == "wifi_signal":
|
||||||
data["icon"] = "mdi:wifi"
|
data["icon"] = "mdi:wifi"
|
||||||
data["name"] = hostname + " Wifi Signal"
|
data["name"] = "Wifi Signal"
|
||||||
data["unit_of_measurement"] = "%"
|
data["unit_of_measurement"] = "%"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "wifi_signal_dbm":
|
elif what_config == "wifi_signal_dbm":
|
||||||
data["icon"] = "mdi:wifi"
|
data["icon"] = "mdi:wifi"
|
||||||
data["name"] = hostname + " Wifi Signal"
|
data["name"] = "Wifi Signal"
|
||||||
data["unit_of_measurement"] = "dBm"
|
data["unit_of_measurement"] = "dBm"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
elif what_config == "rpi5_fan_speed":
|
elif what_config == "rpi5_fan_speed":
|
||||||
data["icon"] = "mdi:fan"
|
data["icon"] = "mdi:fan"
|
||||||
data["name"] = hostname + " Fan Speed"
|
data["name"] = "Fan Speed"
|
||||||
data["unit_of_measurement"] = "RPM"
|
data["unit_of_measurement"] = "RPM"
|
||||||
data["state_class"] = "measurement"
|
data["state_class"] = "measurement"
|
||||||
else:
|
else:
|
||||||
@@ -366,6 +366,7 @@ if __name__ == '__main__':
|
|||||||
wifi_signal_dbm = check_wifi_signal('dbm')
|
wifi_signal_dbm = check_wifi_signal('dbm')
|
||||||
if config.rpi5_fan_speed:
|
if config.rpi5_fan_speed:
|
||||||
rpi5_fan_speed = check_rpi5_fan_speed()
|
rpi5_fan_speed = check_rpi5_fan_speed()
|
||||||
|
|
||||||
# Publish messages to MQTT
|
# Publish messages to MQTT
|
||||||
if hasattr(config, 'group_messages') and config.group_messages:
|
if hasattr(config, 'group_messages') and config.group_messages:
|
||||||
bulk_publish_to_mqtt(cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, wifi_signal, wifi_signal_dbm, rpi5_fan_speed)
|
bulk_publish_to_mqtt(cpu_load, cpu_temp, used_space, voltage, sys_clock_speed, swap, memory, uptime_days, wifi_signal, wifi_signal_dbm, rpi5_fan_speed)
|
||||||
|
|||||||
Reference in New Issue
Block a user