WXforum.net

Weather Software => Meteohub/Meteobridge => Topic started by: Gyvate on September 18, 2020, 07:34:43 AM

Title: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on September 18, 2020, 07:34:43 AM
The inbuilt Weather-Netupload for meteotemplate is still faulty/incomplete - still only 4 Soil-Moisture and only 1 PM2.5 and no lightning sensor values posted.

In the live data and history of MB Pro these sensor data are available, but they are probably missing in the upload string (call of the meteotemplate api.php)

That's what is sent by MB-Pro:

 [ You are not allowed to view attachments ]

and this it what should be sent (I had to create my own http call as nothing is moving at this front here even though a respective post was sent already 10-Aug-2020 in the MB forum):
I know that Boris was busy creating the fantastic new multi-station feature for Meteobridge, but this being +/- completed and an update released, now the repair could start.

 [ You are not allowed to view attachments ]
** I just noticed that meteotemplate chose the German "Bodenfeuchtigkeit" in the API picture - that's soil moisture in English  :-P **

@anybody else using meteotemplate with Meteobridge and want to have more than 1 PM2.5, more than 4 Soil Moisture sensors and at least one of the lightning values sent and stored in the meteotemplate database: (of course you need to activate the entries in the extra sensor table for them to be stored).

http://YOUR-SITE/yourpath-to-the-template-directory/template/api.php?U=[epoch.1:]&T=[th0temp-lastval.1:]&TMX=[th0temp-max5:]&TMN=[th0temp-min5:]&H=[th0hum-lastval.1:]&P=[thb0seapress-lastval:1]&W=[wind0avgwind-lastval=kmh:1]&G=[wind0wind-lastval=kmh:1]&B=[wind0dir-lastval:1]&R=[rain0total-daysum:--]&RR=[rain0rate-lastval:1]&S=[sol0rad-lastval:2]&UV=[uv0index-lastval:1]&TIN=[thb0temp-lastval.1:]&HIN=[thb0hum-lastval.1:]&T1=[th1temp-lastval.1:]&H1=[th1hum-lastval.1:]&SM1=[th20hum-lastval.0:]&SM2=[th21hum-lastval.0:]&SM3=[th22hum-lastval.0:]&SM4=[th23hum-lastval.0:]&SM5=[th24hum-lastval.0:]&L=[lgt0energy-lastval.0:]&PP1=[air0pm-lastval:2]&PP2=[air1pm-lastval:2]&PASS=yourpassword

To be clear: instead of using the faulty/incomplete Weather Net entry for Meteotemplate, I have created my own http call in the service section which provides also the missing sensors (see pictures)

 [ You are not allowed to view attachments ]
 [ You are not allowed to view attachments ]
Here all the extra sensors in the database - including lightning (as so far only one value can be stored for lightning, I have chosen the occurrence [called: energy in MB Pro]).
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: docbee on September 19, 2020, 06:08:32 PM
Did Yachim release a new upload protocol? If so I can implement in Meteobridge. Haven't heard from Yachim quite a while, I hope he is well.
Title: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on September 20, 2020, 03:54:06 AM
Yachim has still the same protocol - that's what I'm using.
He only needs to extend his table definition for the extra sensors with the soil moisture and the lightning (SM only 4 entries, lightning only one so far) for the values also to be stored in the DB, but the API already accepts these sensor values; you just have to send PPn:value, SMn:value, L:value.

I talked/wrote to him recently and he plans to extend the table definition as there are more people now who want to see all their extra sensors. In that process SM5-8 will have to get a new column each, and some LD, LT to be added to L, so he can store all three values.
And he better be prepared for the other multichannel extra sensors (T/H 5-8, WaterLeakage (1-4), PM10 [WH45], Soil temp, Water temp [WH34],
Right now you only need to send (if existing) PP1 - PP4, SM1 - SM8, and L (where I chose the occurence per day ("energy") as it has the imho the highest information value if you have to choose one of the 3 lightning values). I will send him the details (need of extra columns).

But for what is already possible now as for values, PP2-4, SM5-8, and L are missing in your definition. CO2 will come soon (WH45) but the field is already there.
http://www.meteotemplate.com/web/wiki/wikiAPI.php
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: docbee on September 20, 2020, 05:47:55 AM
I added the requested fields in the just released update. But for now mapping the tons of potential soil sensors to the IDs of Meteotemplate is a bit of a challenge. Therefore, I think the advanced user having tons of Ecowitt sensors all over the place might still need to make his very special individual upload definition. Meteobridge allows that, so no problem for the enthusiast.
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on September 20, 2020, 07:17:37 AM
Quote

I added the requested fields in the just released update. But for now mapping the tons of potential soil sensors to the IDs of Meteotemplate is a bit of a challenge.
=D> - will check/verify

Quote
Therefore, I think the advanced user having tons of Ecowitt sensors all over the place might still need to make his very special individual upload definition. Meteobridge allows that, so no problem for the enthusiast.
That's how and why I published the api-string - can be modified, updated, .... if needed for new sensors
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on September 21, 2020, 03:01:58 AM
as for the SM sensors all looks ok - but the particulate matter (PM2.5) are weird.
Only one sent instead of two - and the value of sensor PM2.5 #1 is the data of sensor #2  :roll:
(i.e. the PP1 should have the data of "Air" and PP2 should have the data of "Air#1").
Now PP1 has Air#1 and PP2 is not sent (with a value). See attachments.
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 15, 2022, 12:33:49 PM
thx, I have 2 airlinks.

how do add 2*pm1, 2*pm2.5, and 2*pm10,

your example is only for 2*pm2.5?

thx

https://www.sint-katelijne-waver-meteo.be/template/indexDesktop.php
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 15, 2022, 01:13:53 PM
a) pretty old post - much happend ever since ...
b) I meanwhile use my proprietary API string to Meteotemplate successfully.
It contains 3 x PM2.5, 1 x PM10 and 1 x CO2 - and all I want to send to Meteotemplate.

http://mydomain/my_webroot/template/api.php?U=[epoch.1:]&T=[th0temp-lastval.1:]&TMX=[th0temp-max5:]&TMN=[th0temp-min5:]&H=[th0hum-lastval.1:]&
P=[thb0seapress-lastval:1]&W=[wind0avgwind-lastval=kmh:1]&G=[wind0wind-lastval=kmh:1]......&L=[lgt0total-act.0:]&PP1=[air0!0pm-lastval:2]&
PP2=[air0!1pm-lastval:2]&PP3=[air0!4pm-lastval:2]&PP4=[air0!5-lastval:2]&..............&PASS=xxxxxxxxxx

But at the end of the day it all depends on the MT end and which database fields you use - you can repurpose existing ones and in Meteobridge you just use its name (e.g. SM1).
Of course the unit should match. And/or you can extend the MT database by the columns you need - and create your own short-cut names if what is available is not sufficient.
This needs the execution of a respective SQL command at your server side.
I did in fact both. I started with repurpose for my two 2 PM2.5 sensors, and when it became more, especially for my lightning detector, I extended the database schema (added columns).
 My lightning detector provides three observations - total, distance, time stamp whereas Metetemplate only has one field ("L"). So I created two more columns LT and LD and Meteobridge sends the respective data. The MT API program assigns the values to the existing database fields whose name is provided.
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 15, 2022, 01:28:49 PM
I tried to change the mapping inside meteobridge, doesn't work, it overwrites the airlink1 which is default, how can do a http call?
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 15, 2022, 01:50:03 PM
- you will have to switch off the MB default Meteotemplate posting in the weather networks tab
- in the Services -->events tab you create a http event

New --> service type "http request" --> servicevent type "periodical" and add service event

It should look like this:
 [ You are not allowed to view attachments ]

The string has to contain all variables you want to send - it has to start with the time stamp U=[epoch.1], as in the string in the post before.
The names of the identifyers like U, H, T, TMX, TMN .... you find in Meteotemplate (Settings, control panel, database "edit data" and/or "edit Extra data extra sensors" if you have extra sensors).

For Meteobridge to provide the data you have to provide an expression of the type
sensor_selector-converter.decimals:replacement example T=[th0temp-lastval.1:] provides the outdoor temperature, the last value read by MB from your station, one place behind the decimal point (e.g. 23.4)
see in the Meteobridge WiKi https://meteobridge.com/wiki/index.php/Templates

you can use my string and fill in your missing sensors or remove the ones you don't use (PASS= will have to be your MT password)

..../template/api.php?U=[epoch.1:]&T=[th0temp-lastval.1:]&TMX=[th0temp-max5:]&TMN=[th0temp-min5:]&H=[th0hum-lastval.1:]&P=[thb0seapress-lastval:1]&W=[wind0avgwind-lastval=kmh:1]&G=[wind0wind-lastval=kmh:1]&B=[wind0dir-lastval:1]&R=[rain0total-daysum:--]&RR=[rain0rate-lastval:1]&S=[sol0rad-lastval:2]&UV=[uv0index-lastval:1]&TIN=[thb0temp-lastval.1:]&HIN=[thb0hum-lastval.1:]&T1=[th1temp-lastval.1:]&H1=[th1hum-lastval.1:]&T2=[th2temp-lastval.1:]&H2=[th2hum-lastval.1:]&T3=[th3temp-lastval.1:]&H3=[th3hum-lastval.1:]&T4=[th4temp-lastval.1:]&H4=[th4hum-lastval.1:]&SM1=[th20hum-lastval.0:]&SM2=[th21hum-lastval.0:]&SM3=[th22hum-lastval.0:]&SM4=[th23hum-lastval.0:]&SM5=[th24hum-lastval.0:]&L=[lgt0!0total-dmax.0:]&LD=[lgt0!0dist-lastval.0:77]&LT=[lgt0!0total-nonzerotime=epoch:]&PP1=[air0!0pm-lastval:2]&PP2=[air0!1pm-lastval:2]&PP3=[air0!4pm-lastval:2]&PP4=[air0!5-lastval:2]&CO2_1=[data4num-lastval:2]&TS1=[th5temp-lastval.1:]&TS2=[th6temp-lastval.1:]&TS3=[th7temp-lastval.1:]&T5=[th5temp-lastval.1:]&T6=[th6temp-lastval.1:]&H6=[th6hum-lastval.1:]&T7=[th7temp-lastval.1:]&H7=[th7hum-lastval.1:]&T8=[th0temp-lastval.1:]&H8=[th0hum-lastval.1:]&PASS=xxxxxxxx

In order to make MT save the values, you have to set this up in SetUp --> database --> extra sensors

But be aware of what you do  8-) - I have done already same mapping in my string - just taking it 1:1 could create unexpected results.
On the other hand the string should be quite self-explanatory.
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 15, 2022, 04:52:59 PM
jut doesn't work....
i'm doing something wrong.

the second airlink isn't mapped.

it's visible in the raw sensor data,

when I update the api.php with your examples I do not get sensible values in, I only see in the apisetup.php someting like air2!0pm-lastval:2,air2!1pm-lastval:2, air2!2pm-lastval:2]

thanks for your quick reply though, this will be a hard nutt to crack for me, please bare with me...
any help would be nice;
https://www.sint-katelijne-waver-meteo.be/template/indexDesktop.php

thx





Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 15, 2022, 06:05:52 PM
you have to look into meteotemplateLive.txt  in ../template
There you can see what arrives at Meteotemplate,
if only [xxxxxxxx] arrives, then the chosen sensor/selector has no data (i.e. you need to choose another sensor/selector).

The [xxxxxx] appears then, because in the e.g. [th0temp-lastval.1:] there is nothing behind the ":"
If you had put the text "empty" (without "") there, e.g. [th0temp-lastval.1:empty], the text "empty" would appear.
What stands behind the ":" is what will be printed/exported when no data is available.
If there is nothing behind the ":" and no value is found in the database, then the selection expression [xxxxxx-yyyyy.n:] will be printed/exported.

You can make a test regarding the "mapping" - or better regarding the right choice of sensors/selectors:

take the API string and make an export out of it .
Take the file \\METEOBRIDGE\data\templates\standard-iso.exp as an example.
Make a copy of it, copy the API string into the 4th line, remove all "&L="  etc. so that only [xxxxxxxxxxx], [xxxxxxxxx], .....
is left.
In the line above (starting with $#) put the names of the sensors, separated by "," (without ""), so you can recognize the values later, i.e. know, which value is at what position
Save the file under a new name but with the ending .exp into \\METEOBRIDGE\data\templates
Create an event under Services --> events (event type Data Export, periodical) choose "Data export: after each new day",  "current day" for Time Frame, minutes for resolution and your freshly created template as Template, save, and then press "test" to start the export.

The result (export) will be created in \\METEOBRIDGE\data\export with the name you gave the template (make sure it ends with .exp, otherwise you cannot choose it). e.g. meteotemplate-test-20220515-min.txt, assuming you named the new template file meteotemplate-test.exp

Now you can see what the selectors (e.g. air0!1pm) have provided. You have to choose the selector name as it shows in the raw sensor data respectively in the min/max history.

If you are not sure what the exact name of your sensor is (some are only shown there with their descriptive name i.e. Air instead of air0!pm), check in History --> edit hourly data under sensor
(select the current month and date and see which of the possible sensor names produces the results you are looking for - that's the one you are looking for).

Once you have found your proper sensor names, insert them again into the API string.

regarding the sensor naming:
if you have only one station connected, for outdoor temperature you will have only one sensor: th0temp or th0!0temp (the same here). If you have two stations, you will have two outdoor temperature sensors: th0!0temp (=th0temp) and th1!0temp etc.
If some of your sensor values you want to send to Meteotemplate come from a second station, you have to choose the sensor belonging to that station (this may be different from my API string).
Primary station: ...0!....
Station 1: ....1!....
Station 2: ....2!.... (station 2 is here your 3rd station !! - as the counting starts with zero)

attention: air1!0pm is different from air0!1pm !!!! (can be easily confused)
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Mchd17 on May 15, 2022, 07:34:28 PM
very good write up Gyvate  =D>
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 16, 2022, 01:06:05 AM
jut doesn't work....
.....
when I update the api.php with your examples I do not get sensible values in, I only see in the apisetup.php someting like air2!0pm-lastval:2,air2!1pm-lastval:2, air2!2pm-lastval:2]
.....
air2!0pm-lastval:2 you won't see from my API string - maybe air0!0pm-lastval: (that's the air quality sensor #1 [counting starts with zero !] of the primary station (station #0) or air0!1pm (air sensor#2 of primary)  or air0!2pm (air sensor #3 of primary) ... - you need to understand the syntax !!! of the sensor names and of the sensor-selection expressions: sensor-selector.decimal:replacement   8-)

quote from the WiKi (reading recommended - e.g. setup --> primary station --> mapping (https://meteobridge.com/wiki/index.php/Select_Station)

Physical sensor names are composed of

    the sensor category (t, th, thb, wind, rain, uv, sol, air, ...)
    station number (0 = primary station)
    exclamation mark "!" as delimiter
    sensor number (0 = primary sensor of the specific station)
    sensor type (temp, hum, dew, ...)

Therefore, "th1!0temp" is the primary temp outdoor sensor of station #1.

take your time - in my country we say - "no master just fell down from the sky" - or, in English: "no one is born a master"  :-)

I assume (I haven't seen your system though) that your second airlink is air0!2pm (selection expression: [air0!2pm-lastval.1:] ), provided it comes from the primary station. In your raw sensor data it may just show as Air#1.

maybe you attach a screencopy of your raw sensor data and your min/max history  8-)

and - maybe just start with a very simple export - see attachment (you have to rename the file from .txt to .exp - the forum software doesn't allow attachments with the ending .exp)
use the export instructions from Reply #11 - nothing to edit yet - you've got already a ready-made little export template

the export template:
- # as a first character means that the line is a commentary and is ignored by the MB processor
- what stands behind $# is just a text line creating the headers of the selector values created in the following line (for better reading)
- now comes the export instruction line:
[YYYY]-[MM]-[DD] [hh]:[mm],[air0!0pm],[air0!3pm],[air0!3pm],[air0!3pm]
the first five selectors with the characters in between will create an entry: year-month-day hour:minute (e.g. 2022-05-16 00:00),
the entry [air0!0pm] inside the export file is an instruction for Meteobridge to read from its database the values of the chosen resolution (here minutes [Reply #11] inside the chosen time frame (here current day) and write them into a file named template-name-date.txt (e.g. air-sensors-20220516.txt) and place it into the \\METEOBRIDGE\data\export directory.
If after the first selector a second one comes, separated by a comma, it means to the processor: write that comma and place the value of the 2nd selector behind it etc. until the end of the line

the complete export lines should look like (if you do the export today) - values just ficticious

date-time, Air Quality  [ug/m3], Air Quality 2 [ug/m3], Air Quality 3 [ug/m3], Air Quality 4 [ug/m3]
2022-05-16 00:00, 4, 6, 4, 2
2022-05-16 00:01, 4, 6, 4, 3
......

run it - see what it produces (in \\METEOBRIDGE\data\export) and understand what it does  \:D/

once your export provides the wanted results, transfer the expressions (what's inside the [ ] including the [ ]  ;)) to the API string
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 17, 2022, 03:19:45 PM
on  the MB side: i think its ok

standard-iso.exp

# Standard CSV template with data in metric units
#
$# date, time, air(µg/m³)
[YYYY]-[MM]-[DD],[hh]:[mm],[[air1!0pm-lastval.1],[[air1!1pm-lastval.1],[[air1!2pm-lastval.1],[[air1!0pm-lastval.1],[[air1!1pm-lastval.1],[[air1!2pm-lastval.1]

then i get : in the lastexport.exp

2022-05-17,21:00,[17.7,[16.3,[10.7,[17.7,[16.3,[10.7

which correspondens to airlink 1, 1 pm......airlink 2,... etc

when I copy the [[air1!0pm-lastval.1],[[air1!1pm-lastval.1],[[air1!2pm-lastval.1],[[air1!0pm-lastval.1],[[air1!1pm-lastval.1],[[air1!2pm-lastval.1]

inside the update/api.php it doesnt work.

grrz

Alex





Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 17, 2022, 04:16:50 PM
yes, because you have put too many brackets "[" .... and MB just did what you asked it to do (but probably not what you wanted it to do  :roll:)

and that's why your export output shows brackets - the API doesn't understand brackets !!! - only identifiers [L, T, H, ...] and values as real numbers [1.0, 2.4, ....].  ]

One set of brackets is for the definition and MB will replace it by the sensor value, the second bracket will just be written as "[".  ](*,)

=>
you must NOT write
[[air1!0pm-lastval.1],[[air1!1pm-lastval.1],[[air1!2pm-lastval.1],[[air1!0pm-lastval.1],[[air1!1pm-lastval.1],[[air1!2pm-lastval.1]
(because then you get [17.7,[16.3, ... and the API doesn't understand "[17.7", only "17.7".
but
[air1!0pm-lastval.1],[air1!1pm-lastval.1],[air1!2pm-lastval.1],[air1!0pm-lastval.1],[air1!1pm-lastval.1],[[air1!2pm-lastval.1]
in order to get
17.7,16.3,10.7,17.7,16.3,10.7
(I guess you are aware that you have created each sensor value twice in your export definition)

you have to enter into the API string
PP1=[air1!0pm-lastval.1]&PP2=[air1!1pm-lastval.1]&PP3=[air1!2pm-lastval.1]
 :idea:
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 17, 2022, 06:13:51 PM
somehow i need [

i choose
# Standard CSV template with data in metric units
#
$# date, time, air(µg/m³)
[YYYY]-[MM]-[DD],[hh]:[mm],[air1!0pm-lastval.1],[air1!1pm-lastval.1],[air1!2pm-lastval.1],[air2!0pm-lastval.1],[air2!1pm-lastval.1],[air2!2pm-lastval.1]

i get

2022-05-18,00:00,[air1!0pm-lastval.1],[air1!1pm-lastval.1],[air1!2pm-lastval.1],[air2!0pm-lastval.1],[air2!1pm-lastval.1],[air2!2pm-lastval.1]

when i choose

# Standard CSV template with data in metric units
#
$# date, time, air(µg/m³)
[YYYY]-[MM]-[DD],[hh]:[mm],[[air1!0pm-lastval.1],[[air1!1pm-lastval.1],[[air1!2pm-lastval.1],[[air2!0pm-lastval.1],[[air2!1pm-lastval.1],[[air2!2pm-lastval.1]

see the double [

i get values with [

2022-05-18,00:10,[15.7,[15.1,[10.8,[54.9,[40.3,[26.3

you see my issue?

I did every possible combination, the latest is the best I got with values,

sorry my friend,

 8-)

Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 17, 2022, 06:18:55 PM
what about using
[YYYY]-[MM]-[DD],[hh]:[mm],[air1!0pm-lastval.1:],[air1!1pm-lastval.1:],[air1!2pm-lastval.1:],[air2!0pm-lastval.1:],[air2!1pm-lastval.1:],[air2!2pm-lastval.1:]
instead ?
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 17, 2022, 06:30:44 PM
then i get

2022-05-18,00:20,,,,,,

using Meteobridge 5.4 (May 7 2022, build 14745), FW 1.4

next i will try 5.3?
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 17, 2022, 06:41:22 PM
same in 5.3...
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 17, 2022, 06:49:33 PM
14745 works with me and "my" syntax. It produces the proper export and the proper API values.
And the ":" is a necessary part of the expression for a sensor value inside the [  ].

Maybe you could try replacing lastval by act

[YYYY]-[MM]-[DD],[hh]:[mm],[air1!0pm-act.1:0],[air1!1pm-act.1:0],[air1!2pm-act.1:0],[air2!0pm-act.1:0],[air2!1pm-act.1:0],[air2!2pm-act.1:0]
in this syntax a "0" will be put if the expression has no data

did you export minute data for the current day or yesterday ?
You should have got 25 lines at 00:25 with the proper time frame (current day)
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: davidefa on May 17, 2022, 06:59:06 PM
then i get

2022-05-18,00:20,,,,,,


Seems like air1 and air2 are not defined
Is there a list of defined/available sensors ( I mean only those known by your meteobridge configuration )
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 17, 2022, 07:07:57 PM
in your last example i get

2022-05-18,00:55,0,0,0,0,0,0

last reading some minutes ago.

in the mapping It shows:
Physical Sensor      Logical Sensor      Meaning   
  air1!0pm        air0pm        air quality (10 microns or default)
  air1!1pm        air1pm        air quality (2.5 microns)
  air1!2pm        air2pm        air quality (1 micron)


the air2!0pm etc... are in white, without logical sensor

if i map the air2!0pm to a sensor i can only choose the above logical sensors meaning the air1!0pm for example will be overwritten,

my apologies,

Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 17, 2022, 07:08:16 PM
coming back to @davidefa:
air1!0pm and air2!0pm mean you have a primary station (air0!0pm), a 2nd station (air1!0pm) and a 3rd station (air2!0pm).
How many stations do you have connected. If only one, the primary station, then the result you got
date, time, ,,,,, was correct !!
If you have only one (=primary) station, the expression should be:
[YYYY]-[MM]-[DD],[hh]:[mm],[air0!0pm-lastval.1:],[air0!1pm-lastval.1:],[air0!2pm-lastval.1:],[air0!3pm-lastval.1:],[air0!4pm-lastval.1:],[air0!5pm-lastval.1:]
If you have two stations (primary = station 0 and station 1), and 3 sensors are from station 0 and 3 from station 1, then the expression should be
[YYYY]-[MM]-[DD],[hh]:[mm],[air0!0pm-lastval.1:],[air0!1pm-lastval.1:],[air0!2pm-lastval.1:],[air1!0pm-lastval.1:],[air1!1pm-lastval.1:],[air1!2pm-lastval.1:]

Beware of the syntax:
sensor station separator sensor-number

in order to avoid missing data in the test, your time frame should be "yesterday", resolution "minute" or "hour"
also include some sensors in the export which are there anyway to verify the proper syntax e.g. [th0!0temp-lastval.1:],[th0!0hum-lastval.1:]
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 17, 2022, 07:19:39 PM
yes indeed i have 2 airlinks
one is set to primary station:
and a second ::

I attached screenshots in word of the sensors and mapping,

thank you guys! [ You are not allowed to view attachments ]
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 17, 2022, 07:27:38 PM
OK - you have three stations and station 1 and 2 provide three air quality sensors each.
These pictures would have been helpful from the start.

then try:
[YYYY]-[MM]-[DD],[hh]:[mm],[th0!0temp-lastval.1:],[th0!0hum-lastval.0:],[air1!0pm-lastval.1:],[air1!1pm-lastval.1:],[air1!2pm-lastval.1:],[air2!0pm-lastval.1:],[air2!1pm-lastval.1:],[air2!2pm-lastval.1:]

time frame: yesterday - resolution: minute (don't forget to save the event before pressing the "test" button)

another test option (same time frame, same resolution) could be:
[YYYY]-[MM]-[DD],[hh]:[mm],[th0!0temp-avg.1:],[th0!0hum-avg.0:],[air1!0pm-avg.1:],[air1!1pm-avg.1:],[air1!2pm-avg.1:],[air2!0pm-avg.1:],[air2!1pm-avg.1:],[air2!2pm-avg.1:]
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 18, 2022, 01:53:09 AM
thx, the last try with the avg.1 worked,
i get my 6 pp's exported

getting somewhere finally, i thought then it was solved , but,

when i put it into the string:

api.php?U=[epoch.1:]&T=[th0temp-lastval.1:]&TMX=[th0temp-max5:]&TMN=[th0temp-min5:]&H=[th0hum-lastval.1:]&P=[thb0seapress-lastval:1]&W=[wind0avgwind-lastval=kmh:1]&G=[wind0wind-lastval=kmh:1]&B=[wind0dir-lastval:1]&R=[rain0total-daysum:--]&RR=[rain0rate-lastval:1]&S=[sol0rad-lastval:2]&UV=[uv0index-lastval:1]&TIN=[thb0temp-lastval.1:]&HIN=[thb0hum-lastval.1:]&T1=[th1temp-lastval.1:]&H1=[th1hum-lastval.1:]&SM1=[th20hum-lastval.0:]&SM2=[th21hum-lastval.0:]&SM3=[th22hum-lastval.0:]&SM4=[th23hum-lastval.0:]&SM5=[th24hum-lastval.0:]&L=[lgt0energy-lastval.0:]& PP1=[air1!0pm-avg.1:]&PP2=[air1!1pm-avg.1:]&PP3=[air1!2pm-avg.1:]&PP4=[air2!0pm-avg.1:]&PP5=[air2!1pm-avg.1:]&PP6=[air2!2pm-avg.1:]& PASS=(my password)


i don't get it in meteo template

see picture

at least we, I, made progress, thx again
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 18, 2022, 02:07:44 AM
when MB posts the expression instead of a value, it is because it doesn't find anything in the database.
if you had put [air2!0pm-avg.1:--], it would send the -- instead.

Your posting to MT is in which timing ? (10 seconds, 30 seconds, 1 minute, 5 minutes ...) ?

I think it has to do with the timing the air sensors of station 2 produce new data and this data is stored in the database.
You could try [air2!0pm-lastval.1:--] instead (for the 2! AQ sensors only) or  [air2!0pm-act.1:--]

Do you have minute based sensor data archiving activated in the System --> Administration Tab, Database section ?

are these station 2 air quality sensors different hardware from the station 1 air quality sensors ?

You can see that the syntax is correct as the values of the other sensors and air sensors are sent !

What Meteobridge hardware do you use in the first place ? MB Pro, MB Nano, MB RPi ?
What's your (=MB) RAM usage ?

what does MB report from the database  (History, edit minute data) for the sensors air2!xpm ? (x=0,1,2) for the actual time ?
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 18, 2022, 07:14:54 AM
made some progress , when i add
[air0pm-lastval:2]
[air1pm-lastval:2]
[air2pm-lastval:2]
[air2!0pm-lastval:2]
[air2!1pm-lastval:2]
[air2!2pm-lastval:2]
--
[air2!0pm-lastval.1:--]
[air2!0pm-act.1:--]

into a realtimeMB template and upload it, i get all the data.

but not into MT :-(

the fact that senor 1 is visible, is because it's mapped inside MB

the storage is persistent inside MT,

i also get through my wetaherlink live.

i think it's on the mt side,
thx again for your help.
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: davidefa on May 18, 2022, 08:00:45 AM
Extract from your ( meteotemplate ) cache/apiLog.txt:
Code: [Select]
2022-05-18 13:29:15
INFOS:
Authorized access.
Current date/time: 2022-05-18 13:29:15
api called by http
update U: 1652873354
update SW: meteobridge
update T: 25.9
update TMX: 25.9
update TMN: 25.9
update H: 48
update P: 1022.3
update W: 6.1
update G: 7.9
update B: 230
update R: 0.0
update RR: 0.0
update S: 821.0
update UV: 5.1
update TIN: 24.1
update HIN: 50
update TS1: 46.5
update TS2: 30.8
update TS3: 20.7
update TS4: 37.2
update SM1: 0.0
update SM2: 0.0
update SM3: 0.0
update SM4: 0.0
update SM5: 0.0
update SM6: 0.0
update LW1: 0.0
update LT1: 46.5
update LW2: 0.0
update LT2: 30.8
update PP3: 5.1
update PP2: 8.4
update PP1: 9.1
Begin of common part of api script
Start handling live data
Checking if extra sensors should be logged
Extra sensors data to save in db: TIN, HIN, UV, ET, TS1, LW1, LT1, SM1, PP1, TS2, LW2, LT2, SM2, PP2, TS3, SM3, PP3, TS4, SM4, SM5, SM6
add live data: D: 14
add live data: DTime: 1652873344
add live data: A: 26.3
add live data: ATime: 1652873344
calculated D: 14
calculated A: 26
Save meteotemplateLive.txt: {"U":1652873354,"SW":"meteobridge","T":25.9,"TMX":25.9,"TMN":25.9,"H":48,"P":1022.3,"W":6.1,"G":7.9,"B":230,"R":0,"RR":0,"S":821,"UV":5.1,"TIN":24.1,"HIN":50,"TS1":46.5,"TS2":30.8,"TS3":20.7,"TS4":37.2,"SM1":0,"SM2":0,"SM3":0,"SM4":0,"SM5":0,"SM6":0,"LW1":0,"LT1":46.5,"LW2":0,"LT2":30.8,"PP3":5.1,"PP2":8.4,"PP1":9.1,"UTime":1652873355,"SWTime":1652873355,"TTime":1652873355,"TMXTime":1652873355,"TMNTime":1652873355,"HTime":1652873355,"PTime":1652873355,"WTime":1652873355,"GTime":1652873355,"BTime":1652873355,"RTime":1652873355,"RRTime":1652873355,"STime":1652873355,"UVTime":1652873355,"TINTime":1652873355,"HINTime":1652873355,"TS1Time":1652873355,"TS2Time":1652873355,"TS3Time":1652873355,"TS4Time":1652873355,"SM1Time":1652873355,"SM2Time":1652873355,"SM3Time":1652873355,"SM4Time":1652873355,"SM5Time":1652873355,"SM6Time":1652873355,"LW1Time":1652873355,"LT1Time":1652873355,"LW2Time":1652873355,"LT2Time":1652873355,"PP3Time":1652873355,"PP2Time":1652873355,"PP1Time":1652873355,"D":14,"DTime":1652873355,"A":26,"ATime":1652873355}

The first part with the list of:
Code: [Select]
update SSS: XXXis the list of the parameters passed to api.php ( you can pass any parameter for example if you pass: &MIKEY=MOUSE youll find a row 'update MIKEY: MOUSE' )
from this list I can see there is no PP4, PP5, PP6

For a further check you can use the 'ear' tool (https://ear.phantasoft.de/) ( from olicat ) this will show you what your meteobridge is sending
Simply direct your meteobridge upload to the ear tool

NOTE
When making these tests ( changing the fields sent to the api.php script ) you should/could delete the meteotemplateLive.txt file, not to get confused ( by new and 'stale' values/fields ).
I mean that even if you send a field only once ( the MIKEY=MOUSE in the above example ) the meteotemplateLive.txt file will contein this field for 30 minutes ( then it will be removed ).
This is, I think, to  overcome the wireless sensors 'hiccups' that may happen.
These 'stale' fields are distinguished in the cache/apiLog.txt file as:
Code: [Select]
add live data: MIKEY: MOUSE
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 18, 2022, 08:12:44 AM
can you post (attach !) the MT meteotemplateLive.txt from the .../template directory after the MB posts (it contains your MB posted data)!?
Also, can you post (a) picture(s) of the MT database schema !?
as @davidefa has shown, something is fishy ....
MT will only accept data via the API for existing database fields - and the PPx fields are in the extra table.
When the PP4-PP6 markers are not contained in the meteotemplateLive.txt file, even though they have been posted by MB, maybe the API doesn't identify them as fields to be filled and archived.

Have you switched off the standard MB posting for Meteotemplate in "Weather Nets" ? - put  "upload interval" to "no upload" and save (!!)
If you have two parallel posts, the API might get a hickup.
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 18, 2022, 09:23:47 AM
need some pointers for the eartool, does mb have a custom server option?

switched the upload to mt, data stops coming, switched on upload, data starts again;

see the requested files attached,  [ You are not allowed to view attachments ]  [ You are not allowed to view attachments ]
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: davidefa on May 18, 2022, 09:51:41 AM
In meteotemplateLive.txt you will find any field api.php receives ( even the MIKEY field, if you pass it, which is clearly uknown to meteotemplate ), so if api.php 'GETS' the PP4-PP6 fields they will be in meteotemplateLive.txt
But these fields will be saved in the database only if enabled via the control panel ( but this is a second step, after you receive these fields correctly ).
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 18, 2022, 10:34:52 AM
OK, thx.

the data is sent through the networks tab, you select meteotemplate, site name, password.

so if the template used by this, doesn't contain the datafields op pp, it isn't sent through, correct?

can you get yr hands on a template, which contains all the necessary fields, so I can upload this into MB, and send it through my site as meteotemplateLive.txt? just an open question.

thx for the clarification.

Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: Gyvate on May 18, 2022, 11:39:24 AM
the data is either sent to the API by a predefined template (which is not directly accessible inside meteobridge - you would really have to do some deep digging), but this template is incomplete - hence the creation of the custom http request I has mentioned earlier.
The usual approach is to stop the posting via the "weather nets" tab and replace it by a custom event. (you cannot send data via the "Network" tab)

Theoretically, with some effort, you could create an export with the content of meteotemplateLive.txt (create an export named meteotemplateLive.exp or any name, rename it to meteotemplateLive.txt and send it via a ftp event (inside MB) to http://my-domain/my-web-root/template every let's say 15 seconds.
 
The API string starting after api.php? (without the password) starting with "{" and ending with "}" would be the first part of the data export definition (replacing the '&XXX='  by ',"XXX":' - without ' ' and a comma after the sensor selector expression)
e.g. {"U":[epoch.1:],"T":"[th0temp-lastval.1:]", etc.
and the second part would be
adding the '"XXXTime": "[epoch.1:]", for each marker variable (without ' ') - XXX = H, L, T, PP1, .... e.g. '"PP1Time":"[epoch.1:]",' (without ' ')

The result should look like:
Code: [Select]
{"U":1629299002,"T":20,"TMX":20.3,"TMN":19.9,"H":68,"P":1016,"W":3.2,"G":4,"B":118,"R":1.8,"RR":0,"S":219,"UV":1,"TIN":27,"HIN":50,"T1":21.5,"H1":63,"T2":24,"H2":72,"T3":20.2,"H3":67,"T4":20,"H4":73,"SM1":77,"SM2":71,"SM3":89,"SM4":27,"SM5":32,"L":0,"LD":14,"LT":1629113787,"PP1":6,"PP2":5,"PP3":0.8,"PP4":2,"CO2_1":792,"TS1":-22.3,"TS2":26.3,"TS3":6.9,"T5":-22.3,"T6":26.3,"H6":66,"T7":6.9,"H7":51,"T8":20.3,"H8":66,
"UTime":1629299103,"TTime":1629299103,"TMXTime":1629299103,"TMNTime":1629299103,"HTime":1629299103,"PTime":1629299103,"WTime":1629299103,"GTime":1629299103,"BTime":1629299103,"RTime":1629299103,"RRTime":1629299103,"STime":1629299103,"UVTime":1629299103,"TINTime":1629299103,"HINTime":1629299103,"T1Time":1629299103,"H1Time":1629299103,"T2Time":1629299103,"H2Time":1629299103,"T3Time":1629299103,"H3Time":1629299103,"T4Time":1629299103,"H4Time":1629299103,"SM1Time":1629299103,"SM2Time":1629299103,"SM3Time":1629299103,"SM4Time":1629299103,"SM5Time":1629299103,"LTime":1629299103,"LDTime":1629299103,"LTTime":1629299103,"PP1Time":1629299103,"PP2Time":1629299103,"PP3Time":1629299103,"PP4Time":1629299103,"CO2_1Time":1629299103,"TS1Time":1629299103,"TS2Time":1629299103,"TS3Time":1629299103,"T5Time":1629299103,"T6Time":1629299103,"H6Time":1629299103,"T7Time":1629299103,"H7Time":1629299103,"T8Time":1629299103,"H8Time":1629299103,"D":13.9,"DTime":1629299103,"A":20.6,"ATime":1629299103}
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: davidefa on May 18, 2022, 01:38:56 PM
Don't update a meteotemplateLive.txt file ( as doing this will not update the database ).
But you can upload a csv file ( a text file, with field separated by commas as you have already tested ).
Then configure meteotemplate ( control panel -> database update ) and select custom file and configure the fields you want to update.
You will have to setup 2 cron jobs ( the first to upload the csv file, the second to execute the update/update.php script, that will read the csv file and generate the api.php call with the configured fields )
Currently this method supports only the main sensors, but I can extend it to support also all extra sensors ( as needed by you ).
Title: Re: MB Pro extra sensor data upload to Meteotemplate incomplete - workaround
Post by: alexvanuxem on May 18, 2022, 01:44:15 PM
thx a lot everybody!!

I will let it rest, for now, and take a look at it when I get some vacation, and time to try all this.
seems like a lot of work.

Learned a lot the last few days, so thank you again.