How to control group of thermostats with different modes?

Hello,
I try to create the rule to switch all of my Thermostats during the day.
I have 7 heat controller in my group from different manufactures. All of them have mode=ON and mode=HEAT. Some of them have additional modes like FULL POWER or ECONOMIC HEAT

My intention is to switch all of the Thermostats at particular condition. So i did this try:

//Group definition in configuration file
Group:Number                gThermostatMode                                           "Thermostats"                                    <heating>            (Home)                                                           ["Modes", "Switchable"]
//Switch all Thermostats OFF during a working week at the point of time if some of them are not switched off mode

rule "Heating Period OFF"
when
    Time cron "0 54 10 ? * MON-FRI *"
    
then
    if (gThermostatMode.state !=0){
        logInfo("Heating period", "Some thermostats are ON " + gThermostatMode.state)
    }
    else logInfo("Heating period", "All thermostats are OFF " + gThermostatMode.state)
end

The outcome in log file of gThermostatMode.state = O if all heaters are OFF and UNDEF if any of them = !ON
The rule works and I could use this condition to switch ON ad OFF the group of thermostats, but my intention is to recognize real state/mode of the thermostat. How can I do that? I feel the group itself needs to be configured properly but I do not know how.

Regards,
Jacek

OH2.5.12
Raspberry PI 3+

The real states seem to be strings (HEAT, FULL POWER etc) so presumably your Group Item must be a String type, not Number?

hmmm.
changing :string gives this if all Thermostats are OFF

2022-01-31 13:47:06.352 [INFO ] [marthome.model.script.Heating period] - Some thermostats are ON 1970-01-01T00:00:00.000+0000

and this if one is set to Economy Heat or HEAT

2022-01-31 13:41:06.384 [INFO ] [marthome.model.script.Heating period] - Some thermostats are ON UNDEF

What are you expecting the Group state to be, exactly? You haven’t defined any aggregation function for your Group.

You can do stuff like count the number of members with state “ON”.
It gets trickier to count “ON” and “FULLPOWER”, because you can only set up one aggregation function for the Group.

It might be easier to iterate through all Group members in your rule, to examine each in turn and do whatever it is you want to do.

I think we need to understand what condition, exactly?

indeed. Reading the specification I shall do first :slight_smile:
Without proper aggregation function it behaves as described:

I wish to switch all Thermostats off when nobody is at home and switch it beck (if possible with previous settings/with persistency) after while. For example when someone comes home.
For this I though I will check the group status and trigger all off. This is an initial try to understand how it works. Of course if I could save all parameters from all Thermostats before switching them off and restoring all parameters later it would be the prefect scenario.

I am not sure if I can store all setting from all thermostats at once so maybe going one by one will be better solution.

/Jacek

You can’t.

While using a Group makes it easy to write rules to deal with all thermostats, and certainly easy to send the same command to all, I don’t think any aggregation function is much help to you here. What you want to do doesn’t depend on if 3 are ON and 1 in ECONOMY, so who cares.

There are some little-known DSL tools to do the individual Item save/restore job

but that will not survive a system reboot. If you decide you need that, you will have exploit persistence services.