KNX thermostat with modes and homekit

Hi,

Trying to configure knx thermostat so that it can be controlled via homekit.
The openhab config is fine and working good in sitemap, but i have some issues when trying to controll it from homekit, especially if i try to set up automations in homekit.

i have a rule that on this event:
Item ‘TargetMode_Hall’ received command OFF

switches the Heating_Mode_Hall to standby and then on received command HEATING switches Heating_Mode_Hall back to comfort.

After the HEATING command, the command “‘Setp_Temp_HALL’ received command 22.0” is received. This just sets the temp to the same temperature as is set for comfort in my thermostat, so practically does nothing.

So the problem that i am having is that sometimes, and especially when i try to automate several mode switches at the same time, openhab does not execute or register the events in the “correct” order. This leads to the Setp_Temp_HALL’ received command beeing executed with the standby temp first, which then sets sets the comfort temp in the thermostat to the standby temperature before switching to the comfort mode.

Kind of hard to explain, but i hope it makes sense.

Does anyone have a good solution for this integration that they would like to share, or have any input to how I can fix this to get a stable and reliable solution?
Or should i just forget about getting these thermostats integrated with homekit as they operate in a completely different way?

Thanks for any input!

Regards
Espen

Group  gHall_Therm                    "Termostat Vindfang"                                                               { homekit="Thermostat" }
Switch Heating_1F_Hall                "Vindfang"                 <heating>       (g1F_Hall, Heat)                        { channel="knx:device:bridge:heating:Heating_1F_Hall" }
Number Temperature_Hall               "Temperatur [%.1f °C]"     <temperature>   (g1F_Hall,gHall_Therm)                  { homekit="Thermostat.CurrentTemperature" [minValue=0, maxValue=40], channel="knx:device:bridge:heating:Temperature_Hall" }
Number Setp_Temp_Hall                 "Setpoint [%.1f °C]"       <temperature>   (g1F_Hall,gHall_Therm)                  { homekit="Thermostat.TargetTemperature" [minValue=10.5, maxValue=32], channel="knx:device:bridge:heating:Setp_Temp_Hall" }
String CurrentMode_Hall               "Vindfang Current Mode"                    (g1f_Bath_Therm,gHall_Therm)            { homekit="Thermostat.CurrentHeatingCoolingMode" [HEAT="HEATING", OFF="OFF"] }
String TargetMode_Hall                "Vindfang Target Mode"                     (g1f_Bath_Therm,gHall_Therm)            { homekit="Thermostat.TargetHeatingCoolingMode" [HEAT="HEATING", OFF="OFF"] }
Number Heating_Mode_Hall              "Modus"                    <temperature>                                           { channel="knx:device:bridge:heating:Heating_Mode_Hall" }
Switch Heat_Timer_1F_Hall             "InAktivt ur"              <time>                                                  { channel="knx:device:bridge:heating:Heat_Timer_1F_Hall" }

Hi Espen,

just to confirm my understanding

  • switching modes via homekit is working if you do it one by one
  • but if you try to switch multiple thermostats you get issues with the orders of the commands

if this is the case then it could be an issue at multiple places: homekit, openhab or KNX as they are designed to process commands in parallel and sometimes order cannot be ensured.
please explain more how you automate it, e.g. how the rule looks like.

i do use homekit and KNX (MDT-AKH Actor) myself but i dont switch modes via homekit. i use homekit to set target temperature. the modes are switched by openhab rules at specific time or event without homekit, e.g. night mode, vacation, everyone left home, person detected at home, etc
it works fine for me, but it is different logic.

so, please share more details on your automation.

Does the question boil down to “Can I control a flurry of commands as a sequence of commands with a short delay between each?”
When issuing commands from a rule, yes.

So, seems to be coming in correctly when triggered manually, but i can not say for sure. When scheduled in homekit there are issues according to the log below. The first rules is for switching between Heating and Off from homekit and the second is when mode is switched from openhab/knx:

rule "Homekit Mode 2F Bath"
when
    Item TargetMode_2F_Bath received command
then
    if (receivedCommand == "OFF") {
        Heating_Mode_2F_Bath.sendCommand(4)
    }
    else if (receivedCommand == "HEATING") {
        Heating_Mode_2F_Bath.sendCommand(1)
    }
end

rule "KNX mode 2F Bath"
when
    Item Heating_Mode_2F_Bath received command
then
    if (receivedCommand == 1) {
        postUpdate(TargetMode_2F_Bath, "HEATING")
        postUpdate(CurrentMode_2F_Bath, "HEATING")
    }
    else if (receivedCommand == 2 || receivedCommand == 3 || receivedCommand == 4) {
        postUpdate(TargetMode_2F_Bath, "OFF")
        postUpdate(CurrentMode_2F_Bath, "OFF")
    }
end

So the issue is the first rule there, when homekit wants to switch the thermostat off.
If the OFF command would be the first event triggered, i guess it would have been fine. But this is from the event log and shows that the setpoint temperature for comfort is set to 10 before switching away from comfort. So the next time I switch to comfort, the setpoint temperature will be only 10 c and have the same temperature as night mode::

2022-11-22 05:00:02.917 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Setpoint_Temperature_2F_Bath' received command 10.0
2022-11-22 05:00:02.921 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'TargetMode_2F_Bath' received command OFF
2022-11-22 05:00:02.936 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Setpoint_Temperature_2F_Bath' predicted to become 10.0
2022-11-22 05:00:02.973 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Heating_Mode_2F_Bath' received command 4
2022-11-22 05:00:02.980 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Setpoint_Temperature_2F_Bath' changed from 18.0 to 10.0
2022-11-22 05:00:02.983 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TargetMode_2F_Bath' changed from HEATING to OFF
2022-11-22 05:00:03.004 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Heating_Mode_2F_Bath' predicted to become 4
2022-11-22 05:00:03.019 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Heating_Mode_2F_Bath' changed from 1.0 to 4
2022-11-22 05:00:03.021 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'CurrentMode_2F_Bath' changed from HEATING to OFF

where the temperature 10/Setpoint_Temperature_2F_Bath is coming from? is it from home app or from other rules or KNX?
e.g. in my case the target temperature is set by the KNX on the mode switch.

Temp is set to 10 by homekit/home app, overwriting the comfort temp, and then homekit also do the Item ‘TargetMode_2F_Bath’ received command OFF right after.

If i switch mode from within sitemap or on the thermostat, it will also set the correct temperature in homekit for that mode, so it is working in that way. As you can se in my configuration the knx sepoint temp is mapped to homekits “Thermostat.TargetTemperature”.

It is more convenient and accessible to set automations in the home app rather than configuring rules in openhab, I think.

so, you only switch to “OFF” and you dont touch the temperature and home apps send automatically 10 and OFF. you have also no automation in this regard in home app automation tab.

I just wondering how to define the temperature for “OFF” in home app. e.g. what has to be done if you want to have temperature 15.

sorry for all these questions but it is important to understand which systems sends what. e.g. in my case it is KNX that sends “10” on mode switch and not homekit

Questions are welcome :slight_smile:

In this situation there is an automation in home app that is set to switch thermostat to off at a given time.

When it executes at the given time, it first sends the temp 10c and then Off… that is the annoying part here. It should only have sent Off.

From your explanation i understand that when the mode is switched, the new setpoint temp for the “new” mode is transmitted from the knx bus, which makes sense. That also happens in my setup. The problem is when i want to control the mode from homekit. It is not supported directly, so i have the rule. But when the temp is sent before Off, it messes up the preset temps for my modes.

can you change the 10c to something else, eg. 15c. i still try to understand where 10c is configured. anyway, if home apps sends the temperature before “OFF” we dont have that many options to filter it or ensure correct order. we dont know whether it is just temperature change or “OFF” will follow.

the only solution would be to implement the automation in openhab - maybe not as convenient as home app but still pretty easy to do with main ui or text rules

While in mode standby(knx) setp temp is 16c / homekit shows Off, then homekit scheduler switches thermostat to heating, 20c
Before switching on the thermostat it sends the command “Item ‘Setp_Temp_Hall’ received command 20.0” which overwrites the knx standby temp from 16c to 20c
I guess it kind of makes sense as for this event one wants to start heating to 20c … but since the thermostat has not switched mode yet, 20c is written to the Standby mode.

2022-11-22 14:35:03.884 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Setp_Temp_Hall' received command 20.0
2022-11-22 14:35:03.889 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'TargetMode_Hall' received command HEATING
2022-11-22 14:35:03.893 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Setp_Temp_Hall' predicted to become 20.0
2022-11-22 14:35:03.907 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Setp_Temp_Hall' changed from 16.0 to 20.0
2022-11-22 14:35:03.909 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TargetMode_Hall' changed from OFF to HEATING
2022-11-22 14:35:03.911 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Heating_Mode_Hall' received command 1
2022-11-22 14:35:03.926 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Heating_Mode_Hall' predicted to become 1
2022-11-22 14:35:03.937 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Heating_Mode_Hall' changed from 2.0 to 1
2022-11-22 14:35:03.940 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'CurrentMode_Hall' changed from OFF to HEATING

While in mode Comfort temp (knx) 20c / heating 20c (homekit), homekit scheduler switches thermostat off.
Now when homekit switches off thermostat, the standby temp is also 20c from the switch to heating sequence earlier. I dont know why the temp would be sent here.

2022-11-22 14:37:04.369 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Setp_Temp_Hall' received command 20.0
2022-11-22 14:37:04.373 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'TargetMode_Hall' received command OFF
2022-11-22 14:37:04.377 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Setp_Temp_Hall' predicted to become 20.0
2022-11-22 14:37:04.386 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Heating_Mode_Hall' received command 2
2022-11-22 14:37:04.391 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TargetMode_Hall' changed from HEATING to OFF
2022-11-22 14:37:04.392 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Heating_Mode_Hall' predicted to become 2
2022-11-22 14:37:04.398 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Heating_Mode_Hall' changed from 1.0 to 2
2022-11-22 14:37:04.405 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'CurrentMode_Hall' changed from HEATING to OFF


When starting and stopping manually in the home app, the temp is not sent from homekit at all… ::

2022-11-22 14:23:12.398 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'TargetMode_Hall' received command HEATING
2022-11-22 14:23:12.406 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TargetMode_Hall' changed from OFF to HEATING
2022-11-22 14:23:12.411 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Heating_Mode_Hall' received command 1
2022-11-22 14:23:12.418 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Heating_Mode_Hall' predicted to become 1
2022-11-22 14:23:12.425 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Heating_Mode_Hall' changed from 2.0 to 1
2022-11-22 14:23:12.437 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'CurrentMode_Hall' changed from OFF to HEATING



2022-11-22 14:23:50.913 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'TargetMode_Hall' received command OFF
2022-11-22 14:23:50.919 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'TargetMode_Hall' changed from HEATING to OFF
2022-11-22 14:23:50.921 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'Heating_Mode_Hall' received command 2
2022-11-22 14:23:50.928 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'Heating_Mode_Hall' predicted to become 2
2022-11-22 14:23:50.933 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'Heating_Mode_Hall' changed from 1.0 to 2
2022-11-22 14:23:50.945 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'CurrentMode_Hall' changed from HEATING to OFF

thanks. that helped.

I think I got it. I just did similar automation in home app and if i create automation i have to select the mode and temperature. There is no way in home app automation to define only the mode. Hence, home app sends always the mode and the temperature and the order of these 2 commands is wrong.

im afraid there is no easy & elegant solution in openHAB for it.
but one could think about

  • a separate set of items for target temperatures from homekit, e.g. homekit_Setp_Temp_Hall
  • a rule that is triggered by homekit_Setp_Temp_Hallchanges
  • that rules would check the item for mode TargetMode_Hall and only if is was not changed recently then it would send temperature to Setp_Temp_Hall.

something similar to this discussion

why not set the thermostat to basic :wink: if you are planning on controlling from Alexa google etc the benefits you get with modes are not that significant

Thanks for the input and suggestion :slight_smile: . I had already tried to create a proxy item for the homekit setpoint temp, called Mock_Setp_Temp, but that was as far as i got before thinking i should try to check with the forum if there were better ways to do this. My initial issues with that approach was that how would i know in the rules if the change to the target temperature from homekit was intended or pre-sent from some automation like above examples before forwarding the setpoint temp to knx thermostat. I will try to ivesitage a bit further with timers etc and see where that leads me.

Hi,

What … how… ?? Set the thermostat to basic? What is this, I can not find any option for this in ETS…

My thermostat is Gira Push button sensor 3 Plus 2-gang (5142 00)

when you add the device you install the ts plugin that comes with it and then just use the basic setpoint and setpoint status and that is all you need for heating