Hi there, I’m struggling now for several days by doing just a simple thing.
I’m creating a string containing a value and a timestampf with this rule:
rule “Update Daily Temperature Min- and Max values”
when
Item Weather_Temperature received update
then
var Number Min
var Number Max
var String tmp
var SimpleDateFormat df = new SimpleDateFormat( “HH:mm” )
if (Weather_Temperature.state instanceof DecimalType) {
Min = (Weather_Temperature.minimumSince(now.toDateMidnight, "mysql").state as DecimalType)
tmp = (Math::round(Min.floatValue*10.0)/10.0) + " °C - " + df.format(Weather_Temperature.minimumSince(now.toDateMidnight, "mysql").timestamp)
postUpdate(Weather_Temperature_day_min, tmp)
Max = Weather_Temperature.maximumSince(now.toDateMidnight, "mysql").state as DecimalType
df = new SimpleDateFormat( "HH:mm" )
tmp = (Math::round(Max.floatValue*10.0)/10.0) + " °C - " + df.format(Weather_Temperature.maximumSince(now.toDateMidnight, "mysql").timestamp)
postUpdate(Weather_Temperature_day_max, tmp)
}
end
So, this gives me a daily min and max of a temperature with a timestamp when it occured. This works fine with week/month/year.
But what I want now is, to copy the string at the end of the day (23:59), at the end of the week (Sun 23:59), at the end of the month (last day of month 23:59) and at the end of the year (31.12 23:59) into a new Item as a string.
I want to see the yesterday, last week, last month and last year min and max temperature for statistical use.
To use cron jobs for those tasks is clear so far, but how can I copy this string into another String?
I’m pretty sure that it will be very easy but I really can’t get into it.
Thanks for any help