Optimizing Rule Files with Groups

I’m currently working on simplifying my OpenHAB rule files and would love some guidance. I have several rules that perform similar actions for different items, and I want to consolidate them into a single rule using groups. Here’s what I’m dealing with:

For temperature and humidity updates, I have individual rules for each sensor:
rule “Xiaomi Temp Status Changed”
when Item Xiaomi_Temp received update
then
var SimpleDateFormat df = new SimpleDateFormat(“dd.MM., HH:mm”)
var String timestamp = df.format(new Date())
Xiaomi_Temp_komplett.postUpdate(String::format(“%.1f”, (Xiaomi_Temp.state as DecimalType).floatValue()) + " °C / " + String::format(“%.0f”, (Xiaomi_Humidity.state as DecimalType).floatValue()) + " % (" + timestamp + “)”)
end

And similarly for time since last connection:
rule “Xiaomi Temp time since”
when Time cron “0 * * * * ?”
then
var Number lastthingy = (Xiaomi_Temp_last_connection.state as DateTimeType).calendar.timeInMillis
var Number myminutes = ((now.millis - lastthingy) / 60000)
Xiaomi_Temp_time_since.postUpdate(myminutes)
end

I want to create a single rule that works for all my Xiaomi sensors by grouping them. I’ve successfully done this for my lighting rules, but adapting it for these temperature and time rules has been challenging. Any advice on how to structure this would be greatly appreciated! :pray:

Thanks in advance for your help!