Help for rule simplification

Dear all,

after a long time I was able to get my Eurotronics Z-Wave thermostat running.

To get Google Home and Alexa involved, I needed to create rules that translate between the voice commands and the thermostate modes (see Thermostat items for voice control (Echo/Alexa and Google Assistant)).

That means I have to synchonize between the hardware modes (Thermostate_Mode_Office) of the thermostat and the “dummy” item Homekit_HeatingCoolingMode_Office that receives the voice commands.

Plus, there is an issue with Alexa which is not able to switch the thermotat on or off (see Thermostat works well in Google Home, but not with Alexa). This is why I created an additional switch (Heating_Mode_Office) that serves as a representative and also needs to be synchronized with the other two items.

In total, this leads to three items receiving commands and thus three blocks that care for the synchronization. But as upon a change all items will change (one by the user command, the other two by the first rule that is executed), always all three blocks are executed. This works, but is clearly redundant and very unelegant.

Does someone have a proposal to simplify these rules? Thanks a lot!

rule "Heizungsregelung Büro Switch"
when
  Item  Heating_Mode_Office changed 
then
if (Heating_Mode_Office.state == ON)
  {
    Homekit_HeatingCoolingMode_Office.sendCommand("heat")
    Thermostate_Mode_Office.sendCommand(0x01)
   
  }
  else if (Heating_Mode_Office.state == OFF) 
  {
    Homekit_HeatingCoolingMode_Office.sendCommand("off")    
    Thermostate_Mode_Office.sendCommand(0x00)
  }
end

rule "Heizungsregelung Büro Homekit"
when
  Item Homekit_HeatingCoolingMode_Office changed
then
if (Homekit_HeatingCoolingMode_Office.state == "on")
  Homekit_HeatingCoolingMode_Office.sendCommand("heat")
if (Homekit_HeatingCoolingMode_Office.state == "heat" || Homekit_HeatingCoolingMode_Office.state == "auto" || Homekit_HeatingCoolingMode_Office.state == "heatcool")
  {    
    Heating_Mode_Office.sendCommand(ON)
    Thermostate_Mode_Office.sendCommand(0x01)   
  }
  else if (Homekit_HeatingCoolingMode_Office.state == "off") 
  {    
    Heating_Mode_Office.sendCommand(OFF)
    Thermostate_Mode_Office.sendCommand(0x00)
  }
end

rule "Heizungsregelung Büro Eurotronics"
when
  Item Thermostate_Mode_Office changed
then
if (Thermostate_Mode_Office.state == 0x0F || Thermostate_Mode_Office.state == 0x01 || Thermostate_Mode_Office.state == 0x0B)
  {    
    Homekit_HeatingCoolingMode_Office.sendCommand("heat")
    Heating_Mode_Office.sendCommand(ON)   
  }
  else if (Thermostate_Mode_Office.state == 0x00) 
  {    
    Homekit_HeatingCoolingMode_Office.sendCommand("off")
    Heating_Mode_Office.sendCommand(OFF)
  }
end

No Idea?

I haven’t followed why you need to do that? Maybe what commands are allowed depend on its state, if Alexa is involved.

Again, I haven’t really followed what you are doing and why.
But separation of commands from states can be useful in this kind of situation.

If you need to update X and Y when Z gets a command, do just that. I.e. trigger the rule on command, not change. Update the other Items with postUpdate, not command.

I do this because I have three items in total which all can receive commands to switch the thermostat.

Now I need to synchronize them, where update of one item switches the others accordingly.

This is also necessary as I need to translate between Alexa commands and the thermostat modes…

Is there any chance you can help me?

I’ve just skimmed over this post, so forgive me if I’ve misunderstood. I think you need to take a look at how groups work. Put all three items in the same group and when one updates you can get the other to update at the same time.

Dear @Maximo,

thanks for caring.

The idea is great, however, you might notice that I need to do some “translations” between the items as e.g. ‘heat’ of the ‘Homekit_HeatingCoolingMode_Office.state’ means ON for other items and vice versa.

So there is no simple 1:1 state copying, but I would need some translation table between.

Is there any chance to realize that? Any help is greatly appreciated…

I’ll be honest and say I’m no expert, but do try and help out where I can. If my understanding is correct then you should be able to use a MAP file to perform your translation. Although I could be completely wrong.
Sadly I’ve not managed to find a great deal of detailed documentation on how to setup MAP files and the way they work. There are however some basic examples around the forum.

That’s probably the way to go, thanks. So I will have to try things out…