Rule fill values from KNX number item to dummy number item

Hi,
I need to set non binding variable according contact item state as follows:

rule "Heating Modulation""
when
        Item Heating_Status changed from OFF to ON
then
{
if(Heating_Status.state == ON)
        postUpdate(Heating_Mod, Boiler_Mod)
else
        postUpdate(Heating_Mod, 0)
}
end

Heating_Status is a contact KNX item
Boiler_Mod is a number KNX item
Heating_Mod is a number non bindings item for display and archive.
They is on Boiler only one KNX variable Boiler_Mod for gas flame present (regardsless if for heating or for hot water).
So I need to calculate a dummy var for actually flame mod if Heating is active
and another if hot water is active.

Thanks.

Please try

    Heating_Mod.postUpdate(Boiler_Mod.state as Number)

instead. Keep in mind, that, if the item Heating_Status is of type Contact, the trigger would be

Item Heating_Status changed from CLOSED to OPEN

As the rule will only trigger if the state changes from OFF to ON, the else part will never take place…

Thanks for answer.

But I need functionality in a other way :0)

My boiler is warming both water cirles, one for heating one for warm water.
I have some KNX items from Opentherm to KNX communication.

  1. Two contact KNX items with Open Closed State of boiler (Heating and Warm water)
  2. One common Flame state variable with Open Closed for both (Heating and Warm water)
  3. Two internal dummy non bindigs/communication items for displaying in App and store in measured values archive.

If heating State is active a need to periodically/permanent active copy the numerical value of Flame item to heating dummy item. If heating State is non active a zero value should be set/copied to dummy.

If warm water State is active a need to periodically/permanent active copy the numerical value of Flame item to warm water dummy item. If warmawater State is non active a zero value should be set/copied to dummy.

So I don’t think the AND permanent relationship between number Flame KNX item and contact State is possible.

Thanks for any help for beginner.

First thing is, there is no need to use a contact item, in real this is more like a switch (Heating ON/OFF) the only difference between Switch Item and Contact Item is the state (ON/OFF vs. OPEN/CLOSED). If it’s about the presentation in UI, please use the text widget instead of default or switch widget, then the “switch” will disappear. So

Switch Heating_Status "Heating is [%s]" {knx="..."}
Switch Boiler_Status "Boiler is [%s]" {knx="..."}
Number Flame_Mod "Gas Mod is [%d]" {knx="..."}
Number Heating_Mod "Heating_Mod is [%d]"  //virtual or unbound item
Number Boiler_Mod "Boiler_Mod is [%d]"  //virtual or unbound item

rule:

rule "update Heating and Boiler Mod"
when
    Item Flame_Mod changed or
    Item Heating_Status changed or
    Item Boiler_Status changed or
then
    if (Heating_Status.state == ON)                       // heating active, so
        Heating_Mod.postUpdate(Flame_Mod.state as Number) // set to flame mod
    else
        Heating_Mod.postUpdate(0)

    if (Boiler_Status.state == ON)                        // boiler active, so
        Boiler_Mod.postUpdate(Flame_Mod.state as Number)  // set to flame mod
    else
        Boiler_Mod.postUpdate(0)
    
end

or (shorter but less readable):

rule "update Heating and Boiler Mod"
when
    Item Flame_Mod changed or
    Item Heating_Status changed or
    Item Boiler_Status changed or
then
    Heating_Mod.postUpdate(if (Heating_Status.state == ON) Flame_Mod.state as Number else 0)
    Boiler_Mod.postUpdate(if (Boiler_Status.state == ON) Flame_Mod.state as Number) else 0)
end

So, if Heating_Status is ON, Heating_Mod will be the same as Flame_Mod, otherwise it will be 0. And if Boiler_Status is ON, Boiler_Mod will be the same as Flame_Mod, otherwise it will be 0.

Did I get it right?

1 Like

Thank you very much. I will try it.
Item Heating_Status and Boiler_Status are return information from Heating device. To switch the device on I have separate switches for initiate the Heating or Warm water function. Return information should be type Contact or ?

NOW IS OK, THANKS.

rule "update Heating and Boiler Mod"
when
Item Flame_Mod changed or
Item Heating_Status changed or
Item Boiler_Status changed or
then
Heating_Mod.postUpdate(if (Heating_Status.state == OPEN) Flame_Mod.state as Number else 0)
Boiler_Mod.postUpdate(if (Boiler_Status.state == OPEN) Flame_Mod.state as Number ) else 0)
end

without Boiler_Status changed or
and )

Definitely no. A contact item is for contacts (doors, windows). Switch items can be used to control but you don’t have to control, you can simply use switch items as read only.
Of course you have to pay attention not to send a command to a switch items, but this applies for contact items either.
So, if in UI, you should use Text item=MyItem instead of Switch item=MyItem
In rules you shouldn’t use MyItem.sendCommand() but only (if needed) MyItem.postUpdate().

OK Udo, thanks for detailed explanation.