Re: Basic UI wird nicht mehr korrekt dargestellt
Verfasst: 26. Jan 2024 19:52
ja es ist ein ungebundenes Item welches durch diese Rule gefüttert wird
wo soll ich das [%s] hin machen ? Im Item oder in der Sitemap ?
Code: Alles auswählen
rule "Gasverbrauch Tag Woche Monat Jahr" // Deutscher Zeichensatz zulässig
when
Item heatQuellen_consumption changed // changed reicht.
then
val kwprol = 0.140 // Umrechnung kWh in Liter
val Preis = 1.061 // Preis pro Liter
val ZonedDateTime zdt = ZonedDateTime.now() // jetzt
val ZonedDateTime start_of_day = zdt.with(LocalTime.MIDNIGHT) // heute, Mitternacht
val ZonedDateTime start_of_week = start_of_day.minusDays(start_of_day.getDayOfWeek.getValue - 1) // Montag
val ZonedDateTime start_of_month = start_of_day.withDayOfMonth(24) // Erster Tag des Monats (1)
val ZonedDateTime start_of_year = start_of_day.withDayOfYear(24) // Erster Tag des Jahres (1)
val Gas_Heute = (heatQuellen_consumption.deltaSince(start_of_day) as Number).floatValue // kWh Delta holen
val Gas_Woche = (heatQuellen_consumption.deltaSince(start_of_week) as Number).floatValue
val Gas_Monat = (heatQuellen_consumption.deltaSince(start_of_month) as Number).floatValue
val Gas_Jahr = (heatQuellen_consumption.deltaSince(start_of_year) as Number).floatValue
val Liter_Heute = Gas_Heute * kwprol // kWh in Liter umrechnen
val Liter_Woche = Gas_Woche * kwprol
val Liter_Monat = Gas_Monat * kwprol
val Liter_Jahr = Gas_Jahr * kwprol
val Euro_Heute = String::format("%.2f €",(Liter_Heute * Preis)) // Summe in Euro berechnen
val Euro_Woche = String::format("%.2f €",(Liter_Woche * Preis))
val Euro_Monat = String::format("%.2f €",(Liter_Monat * Preis))
val Euro_Jahr = String::format("%.2f €",(Liter_Jahr * Preis))
GasSumme_Heute.postUpdate(Gas_Heute.toString+" kWh/"+ String::format("%.2f",(Liter_Heute)) +" l/" + Euro_Heute)
GasSumme_Woche.postUpdate(Gas_Woche.toString+" kWh/"+ String::format("%.2f",(Liter_Woche)) +" l/" + Euro_Woche)
GasSumme_Monat.postUpdate(Gas_Monat.toString+" kWh/"+ String::format("%.2f",(Liter_Monat)) +" l/" + Euro_Monat)
GasSumme_Jahr.postUpdate(Gas_Jahr.toString+" kWh/"+ String::format("%.2f",(Liter_Jahr)) +" l/" + Euro_Jahr)
end