KWH Item on KNX read with factor 10 sometimes sometimes not

Hi all, i have a lot of items from knx like this:

  • id: KWH_BoilerU
    channelTypeUID: knx:number
    label: KWH_BoilerU
    description: null
    configuration:
    ga: 13.013:<4/2/1
    Knx is all cabled (no wireless) and i have an mdt ip router for connection openhab to knx.
    the problem i have is that sometimes i dont know why and when but it appears that all values with KWH are with factor 10 in database. And after some minutes or sometimes days (maybe new starts of openhab between) the values were again correct read.
2023-03-18 01:42:55.326 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'KWH_KWH_BoilerU' changed from 434.0 to 436.0
2023-03-21 08:52:25.759 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'KWH_KWH_BoilerU' changed from 436.0 to 4369.0

Someone has an idea how to avoid this? The problem is that then all my statistics were wrong.

What is it in ETS diagnostic? May be the problem is not in OH.
At least you can make proxy item that will be intead of KWH_KWH_BoilerU and with help of rules do not send unreal values from itself to KWH_KWH_BoilerU.

Hi Pavel,
thank you that was a good hint. The Actor itself deliveres the wrong values with factor 10.


So it seems more an knx device issue. I dont know how to solve it… Maybe a good idea to contact mdt

Do you think i could implement somehow a workaround? Maybe a rule like if value greater than 4000 then divide through 10. Because i see no new firmware for the mdt measurement-actor

Update: Ah, OK, now i know what you mean with proxy item. an item which receives value from knx, a rule which checks the value and device if nessecary and write it to the used-item. ok, now i have an idea how to do :slight_smile:

Best thanks and regards
Andreas

As I understand, KWH_KWH_BoilerU is counter of consumed energy. So, may be better to compare with previously value. Like this if KWH_KWH_BoilerU_Current/KWH_KWH_BoilerU_Previously > 9 then KWH_KWH_BoilerU = KWH_KWH_BoilerU_Current/10. It will be universal method even when real value will be more then 4000.
But if this couter will reset, you must understand, that real values at restart can be 0, 1, 20… As you see 20 more than 1 in 20 times. And we can get wrong value in the chart.
You need one more condition when you compared new and previously value. For example

 if (KWH_KWH_BoilerU_Previously>50)&&(KWH_KWH_BoilerU_Current/KWH_KWH_BoilerU_Previously > 9) 
{
     KWH_KWH_BoilerU =  KWH_KWH_BoilerU_Current/10
}

More about previously value, for example, here Item Previous State/Value - #4 by Masterz

Hi Pavel,
thank you very much. I did an universal rule which is doing the job now. Im copying this here if someone has same problem:

//rule kwh_updated
//trigger from  multiple [xxx]_orig items which filled from knx
//write correct value to [xxx] new items same name without_orig
var debug=1;

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution");
var ZonedDateTime   = Java.type("java.time.ZonedDateTime");

//which kwh-item was changed?
var trigger="";
if (this.event !== undefined){
  trigger= event.itemName; 
}
if (trigger.contains("_orig")){
  (debug==1)?logger.info ("getriggert"):null;
  trigger2=trigger.replace('_orig', '');
  
  var origstate=ir.getItem(trigger).getState();
  var state=ir.getItem(trigger2).getState();
  (debug==1)?logger.info(state-10):null;
  (debug==1)?logger.info(origstate >(state+10)):null;
  
  if (origstate<=10){//less than 10
    (debug==1)?logger.info("value less 10"):null;
     events.sendCommand(trigger2, origstate);
  }
  else if ((origstate <(state+10))&&(origstate>10)){//correct value
     (debug==1)?logger.info("value correct"):null;
     events.sendCommand(trigger2, origstate);
  }
  else if (((origstate/10) <(state+10))&&(origstate>10)){
    state=origstate/10;//too big then correct it
    (debug==1)?logger.info("value divided"):null;
     events.sendCommand(trigger2, state);

  }
  else {
     (debug==1)?logger.info("value not in limits"):null;
  }
  
  (debug==1)?logger.info(trigger+" from knx: "+origstate):null;
  (debug==1)?logger.info(trigger2+" to item: "+state):null;
  
}

Best regards
Andreas

1 Like