Page 1 of 1

Create virtual sensor from thb0

Posted: Fri Dec 03, 2010 12:06 am
by cgn
I found that the pressure which my WMR200 shows is dependent on indoor temperature.
E.g. indoor temp is 22°C, pressure is 1010 hPa. At 16°C indoor temp it shows 1012 hPa.

Is it possible to create a virtual sensor (thb1) to adjust this?
My trials with selectmaster and –slave were not successful, I didn’t check the right parameters. The example in the meteohub manual uses temp only.
I need a formula like this: pressure = pressure + (indoor temp -22) / 3

It would be helpful to know which parameters are required to use thb0 as trigger for a virtual sensor thb1.

Thanks for your help.

Re: Create virtual sensor from thb0

Posted: Thu Dec 16, 2010 12:54 am
by cgn
Doesn't anyone have an idea?

My problem is to find the right parameters.

I tried to define thb1 with the following parameters (no operation with the values):

selectmaster 5 300 | awk '{ printf ''%d %d %d %d %d %d'', $1, $2, $3, $4, $5, $6 }'
selectslave 5 300 | awk '{printf ''%d %d %d %d %d %d'', $1, $2, $3, $4, $5, $6 }'

This returns "1018.0° 100% 0.0mb (0.0mb) fc:0"
instead of "23.5° 25% 1018.0mb (1018.0mb) fc:4" which are the current values.

What is wrong with the parameters ???

Re: Create virtual sensor from thb0

Posted: Mon Jan 17, 2011 7:00 pm
by cgn
No idea ???

Re: Create virtual sensor from thb0

Posted: Mon Jan 17, 2011 9:07 pm
by YJB
Hi,

I've not really played with this, but what you are trying to do is wrong from an awk perspective:

Code: Select all

'{printf ''%d %d %d %d %d %d'', $1, $2, $3, $4, $5, $6 }'
This tells awk to expect 6 variables and display those as Decimal integers (that's what %d is telling awk).

If you just want all the variables back you can use:

Code: Select all

'{print $1, $2, $3, $4, $5, $6 }'
or if you are really hooked to printf:

Code: Select all

'{printf ''%s %s %s %s %s %s'', $1, $2, $3, $4, $5, $6 }'
If you want to do some formatting you can use the following printf format specifiers:

Code: Select all

c	      ASCII Character
d	      Decimal integer
e	      Floating Point number
	      (engineering format)
f	      Floating Point number
	      (fixed point format)
g	      The shorter of e or f,
	      with trailing zeros removed 
o	      Octal
s	      String
x	      Hexadecimal
%	      Literal %
Does that help?

Ysbrand

Re: Create virtual sensor from thb0

Posted: Tue Jan 18, 2011 12:05 am
by cgn
Hi,

thanks for your answer.
I'm not familiar with awk, so I only copied the examples from the meteohub manual
and expanded it because thb0 has more parameters than th0.
But why is "%d" wrong when I expect decimal integers?

I tried the codes which you recommended, in combination with selectmaster and -slave:

selectmaster 5 300 | awk '{ print $1, $2, $3, $4, $5, $6 }'
selectslave 5 300 | awk '{print $1, $2, $3, $4, $5, $6 }'

and

selectmaster 5 300 | awk '{ printf ''%s %s %s %s %s %s'', $1, $2, $3, $4, $5, $6 }'
selectslave 5 300 | awk '{printf ''%s %s %s %s %s %s'', $1, $2, $3, $4, $5, $6 }'

but both gave NO results.

The code which I mentioned in my 2nd post gave results, but the wrong values.

cgn

Re: Create virtual sensor from thb0

Posted: Tue Jan 18, 2011 5:51 am
by YJB
HI,

I have no access to my test rig at the moment, so I can't try this, you will need to wait I guess.
But why is "%d" wrong when I expect decimal integers?
All of the values are not really integers when you look closely:
23.5°: is a real and a trailing character: °
25%: is indeed an integer but has a trailing character "%"
1018.0mb: is a real and a trailing string "mb"
(1018.0mb): is a real with a character preceeding and a string trailing
fc:4: is indeed an integer but with a leading string

So, things are not really that straightforward. I guess that Boris' code expects indeed reals, which means that you will need to tear apart the numbers from the strings etc, not really straightforward.

Re: Create virtual sensor from thb0

Posted: Tue Jan 18, 2011 11:17 pm
by cgn
Hi,

the awk instructions only use the raw data of the sensor which are without units.
E.g. "thb0 158 39 0019 10230 6 10230"
After computation with 'awk' meteohub displays the units like '°' or 'mb'.

The command awk '{ printf ''%d %d %d %d %d %d'', $3, $4, $5, $6, $7, $8 }'
returns the correct values: 15.8° 39% 1023.0mb (1023.0mb) fc:6 with their units.

After some further trials it seems that "selectmaster/selectslave" does only return one value,
so it's not usable to return all values from a combined sensor like thb0.