so hab ich mitlerweile bei mir drin inkl SystemdatenHallo djuscha,
ich hab mich dem Thema wieder angenommen und mit Hilfe des Forum jetzt eine andere Lösung gefunden die jetzt läuft.
system.rules
Code: Alles auswählen
import java.lang.management.ManagementFactory
import java.time.ZonedDateTime
import java.time.Instant
import java.time.ZoneOffset
val formatDurationToText = [ Number millis |
// http://stackoverflow.com/questions/13018550/time-since-ago-library-for-android-java
val Number SECOND_MILLIS = 1000;
val Number MINUTE_MILLIS = 60 * SECOND_MILLIS;
val Number HOUR_MILLIS = 60 * MINUTE_MILLIS;
val Number DAY_MILLIS = 24 * HOUR_MILLIS;
var String tmp;
if (millis < MINUTE_MILLIS) {
tmp = "less than a minute";
} else if (millis < 2 * MINUTE_MILLIS) {
tmp = "couple of minutes";
} else if (millis < 50 * MINUTE_MILLIS) {
tmp = String::format("%.2f", millis / MINUTE_MILLIS) + " minutes";
} else if (millis < 90 * MINUTE_MILLIS) {
tmp = "an hour ago";
} else if (millis < 24 * HOUR_MILLIS) {
tmp = String::format("%.2f", millis / HOUR_MILLIS) + " hours";
} else if (millis < 48 * HOUR_MILLIS) {
tmp = "since yesterday";
} else {
tmp = String::format("%.1f", millis / DAY_MILLIS) + " Tage";
}
return tmp
]
rule "Openhab Uptime"
when
Time cron "0/10 * * * * ?"
then
val runtime = ManagementFactory::getRuntimeMXBean();
val long startedMillis = runtime.getStartTime()
if(Openhab_Started.state == NULL || Openhab_Started.state == UNDEF) {
Openhab_Started.postUpdate(new DateTimeType(ZonedDateTime.ofInstant(Instant.ofEpochMilli(startedMillis), ZoneOffset.UTC)))
}
var uptimeAsText = formatDurationToText.apply(now.millis - startedMillis)
postUpdate(Openhab_Uptime, uptimeAsText)
end
rule "CPU Uptime readable"
when
Item CPU_Uptime changed or
Time cron "0/10 * * * * ?"
then
if(CPU_Uptime.state != NULL && CPU_Uptime.state != UNDEF) {
// CPU_Uptime is in minutes, convert it to millis
var cpuUptimeMillis = (CPU_Uptime.state as Number).longValue * 60 * 1000
var uptimeAsText = formatDurationToText.apply(cpuUptimeMillis)
postUpdate(CPU_Uptime_Text, uptimeAsText)
} else {
postUpdate(CPU_Uptime_Text, "-")
}
end
Code: Alles auswählen
String Network_IP "Netzwerk_IP" { channel="systeminfo:computer:openHABianPi:network#ip" }
String Network_Mac "Netzwerk_MAC" { channel="systeminfo:computer:openHABianPi:network#mac" }
Number Network_DataSent "Netzwerk_Daten_Gesendet" { channel="systeminfo:computer:openHABianPi:network#dataSent" }
Number Network_DataRecevied "Netzwerk_Daten_Empfangen" { channel="systeminfo:computer:openHABianPi:network#dataReceived" }
Number Network_PacketsSent "Netzwerk_Pakete_Gesendet" { channel="systeminfo:computer:openHABianPi:network#packetsSent" }
Number Network_PacketsRecevied "Netzwerk_Pakete_Empfangen" { channel="systeminfo:computer:openHABianPi:network#packetsReceived" }
/* CPU information*/
String CPU_Name "CPU_Name" { channel="systeminfo:computer:openHABianPi:cpu#name" }
Number CPU_Uptime "CPU_Betriebzeit" { channel="systeminfo:computer:openHABianPi:cpu#uptime" }
/* Drive information*/
String Drive_Model "Laufwerk_Modell" { channel="systeminfo:computer:openHABianPi:drive#model" }
String Drive_Serial "Laufwerk_Seriennummer" { channel="systeminfo:computer:openHABianPi:drive#serial" }
/* Storage information*/
String Storage_Name "Speicher_Name" { channel="systeminfo:computer:openHABianPi:storage#name" }
String Storage_Type "Speicher_Typ" { channel="systeminfo:computer:openHABianPi:storage#type" }
String Storage_Description "Speicher_Beschreibung" { channel="systeminfo:computer:openHABianPi:storage#description" }
Number Storage_Available "Speicher_Verfuegbar" { channel="systeminfo:computer:openHABianPi:storage#available" }
Number Storage_Used "Speicher_Verwendet" { channel="systeminfo:computer:openHABianPi:storage#used" }
Number Storage_Total "Speicher_Total" { channel="systeminfo:computer:openHABianPi:storage#total" }
Number Storage_Available_Percent "Speicher_Verfuegbar [%d %%]" { channel="systeminfo:computer:openHABianPi:storage#availablePercent" }
Number Storage_Used_Percent "Speicher_Verwendet[%d %%]" { channel="systeminfo:computer:openHABianPi:storage#usedPercent" }
/* Memory information*/
Number Memory_Available "RAM_Verfuegbar" { channel="systeminfo:computer:openHABianPi:memory#available" }
Number Memory_Used "RAM_Verwendet" { channel="systeminfo:computer:openHABianPi:memory#used" }
Number Memory_Total "RAM_Total" { channel="systeminfo:computer:openHABianPi:memory#total" }
Number Memory_Available_Percent "RAM_Verfuegbar [%d %%]" { channel="systeminfo:computer:openHABianPi:memory#availablePercent" }
Number Memory_Used_Percent "RAM_Verwendet [%d %%]" { channel="systeminfo:computer:openHABianPi:memory#usedPercent" }
/* Swap memory information*/
Number Swap_Available "Tauschspeicher_Verfuegbar" { channel="systeminfo:computer:openHABianPi:swap#available" }
Number Swap_Used "Tauschspeicher_Verwendet" { channel="systeminfo:computer:openHABianPi:swap#used" }
Number Swap_Total "Tauschspeicher_Total" { channel="systeminfo:computer:openHABianPi:swap#total" }
Number Swap_Available_Percent "Tauschspeicher_Verfuegbar [%d %%]" { channel="systeminfo:computer:openHABianPi:swap#availablePercent" }
Number Swap_Used_Percent "Tauschspeicher_Verwendet [%d %%]" { channel="systeminfo:computer:openHABianPi:swap#usedPercent" }
/* Sensors information*/
Number Sensor_CPUTemp "CPU_Temperatur" { channel="systeminfo:computer:openHABianPi:sensors#cpuTemp" }
Number Sensor_CPUVoltage "CPU_Spannung" { channel="systeminfo:computer:openHABianPi:sensors#cpuVoltage" }
DateTime Openhab_Started "openHAB started [%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS]" <status>
String Openhab_Uptime "openHAB uptime [%s]" <status>
String CPU_Uptime_Text "Raspi uptime [%s]" <status>
Code: Alles auswählen
String OH2_Service "OH2 Service" { channel="exec:command:oh2service:input" }
String PI_Service "PI Service" { channel="exec:command:piservice:input" }
Code: Alles auswählen
Text label="SystemInfo" icon=status {
Text label="Netzwerk Information" {
Default item=Network_IP
Default item=Network_Mac
Default item=Network_DataSent
Default item=Network_DataRecevied
Default item=Network_PacketsSent
Default item=Network_PacketsRecevied
}
Text label="CPU information" {
Default item=CPU_Load
Default item=CPU_Uptime
}
Text label="Laufwerk information" {
Default item=Drive_Model
Default item=Drive_Serial
}
Text label="Speicher Information" {
Default item=Storage_Name
Default item=Storage_Type
Default item=Storage_Description
Default item=Storage_Available
Default item=Storage_Used
Default item=Storage_Total
Default item=Storage_Available_Percent
Default item=Storage_Used_Percent
}
Text label="RAM Information" {
Default item=Memory_Available
Default item=Memory_Used
Default item=Memory_Total
Default item=Memory_Available_Percent
Default item=Memory_Used_Percent
}
Text label="Tauschspeicher Information" {
Default item=Swap_Available
Default item=Swap_Used
Default item=Swap_Total
Default item=Swap_Available_Percent
Default item=Swap_Used_Percent
}
Default item=Sensor_CPUTemp
Default item=CPU_Uptime
//Default item=CPU_Load
Default item=Openhab_Started
Default item=Openhab_Uptime
Default item=CPU_Uptime_Text
Switch item=OH2_Service mappings=[restart="Restart" ]
Switch item=PI_Service mappings=[reboot="Reboot", shutdown="Shutdown"]
