Wrong average of Group:Number:AVG with DPT knx="5.001:

Hi Community,

might be a newbie question.

my knx humidity items are of type

Number RelHumidity_EG_Kind1  			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Kind1, RelHumidityEG) 		{ knx="5.001:12/3/0" }
Number RelHumidity_EG_Kind2  			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Kind2, RelHumidityEG) 		{ knx="5.001:12/3/1" }
Number RelHumidity_EG_Flur   			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Flur, RelHumidityEG)			{ knx="5.001:12/3/2" }
Number RelHumidity_EG_Toilette			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Toilette, RelHumidityEG)		{ knx="5.001:12/3/3" }
Number RelHumidity_EG_Garderobe			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Garderobe, RelHumidityEG)		{ knx="5.001:12/3/4" }
Number RelHumidity_EG_Eingang			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Eingang, RelHumidityEG)		{ knx="5.001:12/3/5" }
Number RelHumidity_EG_Kueche			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Kueche, RelHumidityEG)		{ knx="5.001:12/3/6" }
Number RelHumidity_EG_Wohnzimmer		"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Wohnzimmer, RelHumidityEG)	{ knx="5.001:12/3/7" }
Number RelHumidity_EG_Kellertreppe	  	"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityEG, EG_Kellertreppe, RelHumidityEG)	{ knx="5.001:12/3/8" }
Number RelHumidity_KG_Vorratsraum 	  	"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityKG, KG_Vorratsraum, RelHumidityKG)  	{ knx="5.001:12/3/9" }
Number RelHumidity_KG_HWR1  			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityKG, KG_HWR, RelHumidityKG)  			{ knx="5.001:12/3/10" }
Number RelHumidity_KG_HWR2	  			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityKG, KG_HWR, RelHumidityKG)  			{ knx="5.001:12/3/11" }
Number RelHumidity_KG_Sauna				"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityKG, KG_Sauna, RelHumidityKG)  		{ knx="5.001:12/3/12" }
Number RelHumidity_KG_Geraeteraum		"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityKG, KG_Geraeteraum, RelHumidityKG)  	{ knx="5.001:12/3/13" }
Number RelHumidity_KG_Sportzimmer 	  	"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityKG, KG_Sportzimmer, RelHumidityKG)  	{ knx="5.001:12/3/14" }
Number RelHumidity_KG_Heizungsraum 	 	"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityKG, KG_Heizungsraum, RelHumidityKG) 	{ knx="5.001:12/3/15" }
Number RelHumidity_OG_Schlafzimmer 	 	"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityOG, OG_Schlafzimmer, RelHumidityOG) 	{ knx="5.001:12/3/16" }
Number RelHumidity_OG_Badezimmer		"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityOG, OG_Badezimmer, RelHumidityOG) 	{ knx="5.001:12/3/17" }
Number RelHumidity_OG_Empore  			"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityOG, OG_Empore, RelHumidityOG)  		{ knx="5.001:12/3/18" }
Number RelHumidity_OG_Arbeitszimmer		"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityOG, OG_Arbeitszimmer, RelHumidityOG) { knx="5.001:12/3/19" }
Number RelHumidity_OG_Ankleidezimmer	"rel. Luftfeuchte [%.1f %%]" <humidity>   (gRelHumidityOG, OG_Ankleide, RelHumidityOG)		{ knx="5.001:12/3/20" }


and

Group:Number:AVG		RelHumidityOG "Avg. Obergeschoss rel. Luftfeuchte [%.1f %%]"	<humidity>	(gRelHumidityOG)
Group:Number:AVG		RelHumidityEG "Avg. Erdgeschoss rel. Luftfeuchte [%.1f %%]"		<humidity>	(gRelHumidityEG)
Group:Number:AVG		RelHumidityKG "Avg. Keller rel. Luftfeuchte [%.1f %%]"			<humidity>	(gRelHumidityKG)


The averages of other temperature or light intensity knx items are scaled correctly, only the humidity is wrong.



Where is the mistake?
regards, tim

That is weird. It is as if it is either storing the values as decimal (i.e. 0.4) instead of percents (i.e. 40). I’m not sure how or why that would be the case. There is nothing in the configs to explain this behavior. Weird.

According to the Wiki entry, the Average function will use only decimals… so in theory this “malfunction” is by design :slight_smile:

Maybe the stored item state is 0.400 (check it in Karaf console with the command: smarthome:items list RelHumidity_EG_Kind1).
Afterwards, you are using [%.1f %%] to display it on your sitemap and this shows correctly the percentage value (40.0 %)

If this is the case (0.400 item state) I don’t know if there is a solution to “transform” the stored state in a way to be used by the average function to display averages of percentages (maybe there is no way)…

Something else that you could try:
Remove the 5.001 DPT definition from the knx item or use 6.001 to see if the item state is stored as an integer (i.e. 40)

5.001: percentage (0…100%) Unit: %, Default Value: 0%, Integer or floating number: e.g. 123 or 123.56 between 0 and 255

6.001: percentage (-128 … 127%) Unit: %, Default Value: 0%, Integer number, e.g. 123 between -128 and 127

That certainly fits with the behavior but not with the expected behavior.

There is nothing in the docs or my experience to say that %% does anything more than print a % as part of the label.

If you want to display a special character you must mask the character with a ‘%’. So, to display one ‘%’ enter the text ‘%%’.

It should not be converting 0.4 to 40% for display. And even if it were, it should do the same for the AVG from the Group since %% is there too.

Out of curiosity and just to absolutely prove this one way or the other, what happens if you remove the %% from all the labels?

You are correct. I had a wrong understanding of what [%.1f %%] does :slight_smile:

I just tested a similar setup in my installation…

My roller-shutter items have the following state (from karaf console: smarthome:items)

P11_J1 (Type=RollershutterItem, State=100, Label=P11_J1, Category=null, Groups=[GF_P11_Living, Shutters])
P11_J2 (Type=RollershutterItem, State=100, Label=P11_J2, Category=null, Groups=[GF_P11_Living, Shutters])
P11_J3 (Type=RollershutterItem, State=100, Label=P11_J3, Category=null, Groups=[GF_P11_Living, Shutters])
P06_J4 (Type=RollershutterItem, State=66, Label=P06_J4, Category=null, Groups=[GF_P06_Office, Shutters])
P07_J5 (Type=RollershutterItem, State=100, Label=P07_J5, Category=null, Groups=[GF_P07_Guest, Shutters])
E06_J6 (Type=RollershutterItem, State=100, Label=E06_J6, Category=null, Groups=[FF_E06_S, Shutters])
E03_J7 (Type=RollershutterItem, State=100, Label=E03_J7, Category=null, Groups=[FF_E03_M, Shutters])
E09_J8 (Type=RollershutterItem, State=100, Label=E09_J7, Category=null, Groups=[FF_E09_Bedroom, Shutters])
E09_J9 (Type=RollershutterItem, State=100, Label=E09_J9, Category=null, Groups=[FF_E09_Bedroom, Shutters])
E09_J10 (Type=RollershutterItem, State=100, Label=E09_J10, Category=null, Groups=[FF_E09_Bedroom, Shutters])

They are defined as:

/* Ground Floor Rollershutters = knx=Up/Down,Step/Stop,GoTo,Status */
Rollershutter   P11_J1          "P11_J1"                (GF_P11_Living,Shutters)        {knx="2/0/0,2/0/1,2/3/0+<2/2/0"}
Rollershutter   P11_J2          "P11_J2"                (GF_P11_Living,Shutters)        {knx="2/0/2,2/0/3,2/3/2+<2/2/2"}
Rollershutter   P11_J3          "P11_J3"                (GF_P11_Living,Shutters)        {knx="2/0/4,2/0/5,2/3/4+<2/2/4"}
Rollershutter   P06_J4          "P06_J4"                (GF_P06_Office,Shutters)        {knx="2/0/6,2/0/7,2/3/6+<2/2/6"}
Rollershutter   P07_J5          "P07_J5"                (GF_P07_Guest,Shutters)         {knx="2/0/8,2/0/9,2/3/8+<2/2/8"}

/* First Floor Rollershutters = knx=Up/Down,Step/Stop,GoTo,Status */
Rollershutter   E06_J6          "E06_J6"                (FF_E06_S,Shutters)         {knx="2/1/0,2/1/1,2/3/10+<2/2/10"}
Rollershutter   E03_J7          "E03_J7"                (FF_E03_M,Shutters)        {knx="2/1/2,2/1/3,2/3/12+<2/2/12"}
Rollershutter   E09_J8          "E09_J7"                (FF_E09_Bedroom,Shutters)       {knx="2/1/4,2/1/5,2/3/14+<2/2/14"}
Rollershutter   E09_J9          "E09_J9"                (FF_E09_Bedroom,Shutters)       {knx="2/1/6,2/1/7,2/3/16+<2/2/16"}
Rollershutter   E09_J10         "E09_J10"               (FF_E09_Bedroom,Shutters)       {knx="2/1/8,2/1/9,2/3/18+<2/2/18"}

And if I use an Average function in a Group within the .items file:

Group:Number:AVG        Shutters        "Avg. RolShut [%.1f %%]"        <humidity>      (gTest)

I get a wrong result also:

using the following .sitemap entry:

Frame {
                Group item=Shutters
        }

Maybe this is a bug after all :slight_smile:

This is strange…
Using also MIN & MAX I have similar wrong results (MIN shows 0.660000 % for an item in the Group with a min state of 66 and MAX shows 1.000000 % for an item with a state of 100)

I am using the default .precision of 6 digits

Group:Number:MIN        Shutters        "Avg. RolShut [%f %%]"  <humidity>      (gTest)

So… the item value is not the item state?
(*in the description of the AVG function it writes: “Calculates the numeric average over all item values of decimal type.”)

I see the following in the logs (with the MIN function on the Group):

2017-01-18 01:56:13.259 [ItemCommandEvent          ] - Item 'P06_J4' received command 100
2017-01-18 01:56:23.704 [ItemStateChangedEvent     ] - P06_J4 changed from 66 to 100
2017-01-18 01:56:23.705 [GroupItemStateChangedEvent] - Shutters changed from 0.66000000 to 1.00000000 through P06_J4
2017-01-18 01:56:23.707 [GroupItemStateChangedEvent] - gTest changed from 0.66000000 to 1.00000000 through Shutters

If I use a simple Group without any function, the value of the Group is coming up correctly:

2017-01-18 02:01:30.202 [ItemCommandEvent          ] - Item 'P06_J4' received command 50
2017-01-18 02:01:45.491 [ItemStateChangedEvent     ] - P06_J4 changed from 100 to 50
2017-01-18 02:01:45.493 [GroupItemStateChangedEvent] - Shutters changed from 100 to UNDEF through P06_J4
2017-01-18 02:03:01.888 [ItemCommandEvent          ] - Item 'P06_J4' received command 100
2017-01-18 02:03:17.175 [ItemStateChangedEvent     ] - P06_J4 changed from 50 to 100
2017-01-18 02:03:17.176 [GroupItemStateChangedEvent] - Shutters changed from UNDEF to 100 through P06_J4

Tried all 3 possible DPT settings (none, 5:001, 6:001)… same (wrong) result of the AVG, MIN & MAX functions

I opened up a new issue on https://github.com/eclipse/smarthome/issues/2847

1 Like

@Kai gaves us the right direction (for my case):

Define the group to be of Rollershutter type as well:

Group:Rollershutter:AVG Shutters "Avg. Rollershutters [%.2f %%]"

He wrote: “You are transforming PercentTypes to a DecimalType here, so it is imho fully correct that the value of the group item is a value between 0-1.”

This shows up correctly in the sitemap:

On the other hand, I just realized that I opened an issue, describing my case (which uses “Rollershutter” item types but maybe I didn’t cover correctly @tjakobi 's case… (with a Number)

I don’t know what should be used in the case of Group:Number:AVG for his item values. I added this question to the issue :slight_smile:

1 Like

@Dim, All
Thx for the helpfull answers. The same items I use for temperature values, which is a KNX DPT:9.001 (datatype) and the Group:AVG will be scaled correctly. Might be an important information for @Kai. The first screenshot shows, the correct scaling for temperatures.

Hi @tjakobi,

Can you please post the output of the following karaf console command:

smarthome:items list |grep RelHumidity

We should check the stored value of “State=” for these Humidity items.

Kai tried to replicate the problem and he didn’t get the same result/error. See below:

openhab> smarthome:items
ItemAVG (Type=GroupItem, BaseType=NumberItem, Members=2, State=NULL, Label=null, Category=null)
Item1 (Type=NumberItem, State=NULL, Label=null, Category=null, Groups=[ItemAVG])
Item2 (Type=NumberItem, State=NULL, Label=null, Category=null, Groups=[ItemAVG])
openhab> smarthome:update Item1 38
Update has been sent successfully.
openhab> smarthome:update Item2 40
Update has been sent successfully.
openhab> smarthome:items
ItemAVG (Type=GroupItem, BaseType=NumberItem, Members=2, State=39, Label=null, Category=null)
Item1 (Type=NumberItem, State=38, Label=null, Category=null, Groups=[ItemAVG])
Item2 (Type=NumberItem, State=40, Label=null, Category=null, Groups=[ItemAVG])

Hi Dim,
sorry for the delayed reply. See below the output of the group of humidity and temperature sensors of the first floor.

openhab> smarthome:items list |grep RelHumidityEG
RelHumidity_EG_Kind1 (Type=NumberItem, State=40, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Kind1, RelHumidityEG])
RelHumidity_EG_Kind2 (Type=NumberItem, State=40, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Kind2, RelHumidityEG])
RelHumidity_EG_Flur (Type=NumberItem, State=40, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Flur, RelHumidityEG])
RelHumidity_EG_Toilette (Type=NumberItem, State=41, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Toilette, RelHumidityEG])
RelHumidity_EG_Garderobe (Type=NumberItem, State=NULL, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Garderobe, RelHumidityEG])
RelHumidity_EG_Eingang (Type=NumberItem, State=41, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Eingang, RelHumidityEG])
RelHumidity_EG_Kueche (Type=NumberItem, State=42, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Kueche, RelHumidityEG])
RelHumidity_EG_Wohnzimmer (Type=NumberItem, State=36, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Wohnzimmer, RelHumidityEG])
RelHumidity_EG_Kellertreppe (Type=NumberItem, State=NULL, Label=rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG, EG_Kellertreppe, RelHumidityEG])
gRelHumidityEG (Type=GroupItem, Members=10, State=UNDEF, Label=rel. Luftfeuchte EG, Category=humidity, Groups=[gStatus])
RelHumidityEG (Type=GroupItem, BaseType=NumberItem, Members=9, State=0.40000000, Label=Avg. Erdgeschoss rel. Luftfeuchte, Category=humidity, Groups=[gRelHumidityEG])
openhab> 
openhab> smarthome:items list |grep TemperatureEG
Temperature_EG_Kind1 (Type=NumberItem, State=22.18, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Kind1, TemperatureEG])
Temperature_EG_Kind2 (Type=NumberItem, State=22.5, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Kind2, TemperatureEG])
Temperature_EG_Flur (Type=NumberItem, State=22.5, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Flur, TemperatureEG])
Temperature_EG_Toilette (Type=NumberItem, State=NULL, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Toilette, TemperatureEG])
Temperature_EG_Garderobe (Type=NumberItem, State=22.8, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Garderobe, TemperatureEG])
Temperature_EG_Eingang (Type=NumberItem, State=22.36, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Eingang, TemperatureEG])
Temperature_EG_Kueche (Type=NumberItem, State=22.56, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Kueche, TemperatureEG])
Temperature_EG_Wohnzimmer (Type=NumberItem, State=18.56, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Wohnzimmer, TemperatureEG])
Temperature_EG_Kellertreppe (Type=NumberItem, State=22.56, Label=Temperatur, Category=temperature, Groups=[gTemperatureEG, EG_Kellertreppe, TemperatureEG])
gTemperatureEG (Type=GroupItem, Members=10, State=UNDEF, Label=Temperaturen EG, Category=temperature, Groups=[gStatus])
TemperatureEG (Type=GroupItem, BaseType=NumberItem, Members=9, State=22.00, Label=Avg. Erdgeschoss Temperatur, Category=temperature, Groups=[gTemperatureEG])
openhab> 

Any Idea someone?
The issue was closed on github by Kai, maybe someone can help. Might be a problem of the KNX handling…

Hi,

It was closed because there was no issue! Furthermore, the number of factors that lead to your error are too many to be comprehended at this point. I have faced issues with openjdk that i could not have imagined (way back) :wink: (your post does not show the full environment). This is a framework with rules, if you comply, everything will work as planned! As for possible bugs, that is why everyone is here!

BR,

George

Hi,
George thanks for reply. How, can I give more information about the issue to solve the problem?

I have posted screenshots and explained the problem by text. In addition, I have posted the output from the console, which by the way show the wrong output. In addition, I have posted the same console output with temperature values and there the average is scaled correctly. If anything is missing, please give feedback.
regards, tim

Dear Tim,

What you are complaining seems that has nothing to do with OH, at least as what I am aware of! To be honest, I really don’t understand why you would look in the upper layers of a system just because those layers threw the error! Just to be clear: I have worked with KNX devices that gave so much unclear data (DPT especially)! First, please look in to that! The manufacturers don’t really care about how you integrate! :wink:

BR,

George

Hi George,
well,I thought that Dim nearly figured out, that there is a problems, but Kai´s test, did not cover the case with item read by KNX. (Especially the percentage of humidity. DPT 5.001) By the way, each value will be scaled correctly, only the group does not. Therefore, I thought, If someone can simulate it or read the knx binding, to figure out, if maybe KNX DPT5.001 will be handled different. As my first post say: "…might be a newbie question."
regards, tim

Dear Tim,

I really don’t argue your experience with OH, I am just saying there are so many variables to be taken in to account!
I have used your scenario in many setups (especially KNX), and yes indeed I had some problems! Fortunately they were not related to OH!
I am more than glad to help you solve here any OH related problem that I know, but what you are issuing right now is deeper, and not related to OH!

BR,
George

Hi George

…but what you are issuing right now is deeper, and not related to OH!

If that is the case, it is an issue and from my point of view shall be posted, am I wrong?
I do not want to dig into the code, as I am sadly not the skilled person, but maybe the ones, who have written or were involved in the code. You point out that it is not the OH2 core but then it is the KNX 1.9 code. Or the interface between. Please correct, if I am wrong?

I am wondering, why Dim exactly figured out the problem and you are just writing, that it is something general in the deeper grounds, but not in OH2. Well, it might be, but come on, I just want to friendly ask for help and if someone runs into the same issue, it is stated as open issue and not as closed.

BEST regards Tim

Dear Tim,

There is no closed discussion to anyone here! I was just saying: I, and everyone else here do not entirely know your setup! As for the deeper stuff in OH and all the other underlaying libraries, yes they are very “creepy”… :wink: … they are all public!
Of course I can help voluntarily as long as you will disclose your setup!

Absolutely the BEST REGARDS,
George

Hi George,
have you read the post before. Dim has opened a thread on github, which was closed by kai. Summarizing: Kai could not identify the problem as OH2 issue. So, the problem might be somewhere else. → expected in KNX binding.

Of course I can help voluntarily as long as you will disclose your setup!

First of all, what do you need?
Setup in general?
KNX DPT5.001 → humidity and temperature (DPT9.001) by WireGate (1wire sensor)
RPI3 with OH2 (openHAB 2.0.0~20170107034332 (Build #752)) KNX1.9 binding reads KNX messages. Temperatures and humidity reads are fine. Temperature Group:AVG are also fine. Humidity Group:AVG are are fine by value but scaled wrong. This it by the way nearly the topic of the thread.

items are posted
screenshot of error is posted
karaf console is posted

Please advice me to give more information about my setup.
regards, tim