WeatherFlow Weather Station (Tempest) integration into Homematic

Support for our english speaking visitors

Moderator: Co-Administratoren

MichaelN
Beiträge: 9561
Registriert: 27.04.2020, 10:34
System: CCU
Hat sich bedankt: 696 Mal
Danksagung erhalten: 1608 Mal

Re: WeatherFlow - Tempest

Beitrag von MichaelN » 20.12.2020, 19:16

You can try it yourself as a URL command in a browser, this works 100%
If this don't work on, your System it wouldn't help.
please test on your System with the correct url
LG, Michael.

Wenn du eine App zur Bedienung brauchst, dann hast du kein Smarthome.

Wettervorhersage über AccuWeather oder OpenWeatherMap+++ Rollladensteuerung 2.0 +++ JSON-API-Ausgaben auswerten +++ undokumentierte Skript-Befehle und Debugging-Tipps +++

omicronCZ
Beiträge: 206
Registriert: 31.07.2011, 17:37
System: CCU
Wohnort: Czech Rep.
Hat sich bedankt: 80 Mal
Danksagung erhalten: 12 Mal

Re: WeatherFlow - Tempest

Beitrag von omicronCZ » 21.12.2020, 12:03

Hi Michael,

I don't understand, this URL command (including the test token) is functional and returns the data below in the browser

Code: Alles auswählen

https://swd.weatherflow.com/swd/rest/observations/station/2867?token=2fdf9a5b-19a0-46e6-99b3-28d67f8cab44
Returned data:

Code: Alles auswählen

{"station_id":2867,"station_name":"Bleiberg (Bublava, Ore Mountains), Czech Republic","public_name":"Bleiberg (Bublava, Ore Mountains), Czech Republic","latitude":50.36208,"longitude":12.50608,"timezone":"Europe/Prague","elevation":700.0,"is_public":true,"status":{"status_code":0,"status_message":"SUCCESS"},"station_units":{"units_temp":"c","units_wind":"kph","units_precip":"mm","units_pressure":"mb","units_distance":"km","units_direction":"degrees","units_other":"metric"},"outdoor_keys":["timestamp","air_temperature","barometric_pressure","station_pressure","pressure_trend","sea_level_pressure","relative_humidity","precip","precip_accum_last_1hr","precip_accum_local_day","precip_accum_local_yesterday","precip_minutes_local_day","precip_minutes_local_yesterday","wind_avg","wind_direction","wind_gust","wind_lull","solar_radiation","uv","brightness","lightning_strike_last_epoch","lightning_strike_last_distance","lightning_strike_count","lightning_strike_count_last_1hr","lightning_strike_count_last_3hr","feels_like","heat_index","wind_chill","dew_point","wet_bulb_temperature","delta_t","air_density"],"obs":[{"timestamp":1608547995,"air_temperature":-0.1,"barometric_pressure":940.5,"station_pressure":940.5,"sea_level_pressure":1023.0,"relative_humidity":99,"precip":0.0,"precip_accum_last_1hr":0.0,"precip_accum_local_day":0.101547,"precip_accum_local_yesterday":0.001252,"precip_minutes_local_day":27,"precip_minutes_local_yesterday":1,"wind_avg":0.2,"wind_direction":214,"wind_gust":0.7,"wind_lull":0.0,"solar_radiation":50,"uv":0.27,"brightness":6054,"lightning_strike_last_epoch":1599316508,"lightning_strike_last_distance":14,"lightning_strike_count":0,"lightning_strike_count_last_1hr":0,"lightning_strike_count_last_3hr":0,"feels_like":-0.1,"heat_index":-0.1,"wind_chill":-0.1,"dew_point":-0.2,"wet_bulb_temperature":-0.2,"delta_t":0.1,"air_density":1.19991,"pressure_trend":"falling"}]}
You can try it too, it works anywhere

And here is your script with the correct URL, but it only returns an error, so I don't know :(

Code: Alles auswählen

!WeatherFlow - Tempest auslesen
!V1.0 MichaelN https://homematic-forum.de/forum/viewtopic.php?f=49&t=63711
string url = "https://swd.weatherflow.com/swd/rest/observations/station/2867?token=2fdf9a5b-19a0-46e6-99b3-28d67f8cab44";
string rueck;
string error;
system.Exec("wget --no-check-certificate -O --timeout=10 - '"#url#"'" , &rueck, &error);

if (!rueck== "")
{
   WriteLine("HTTPRequest OK");
   rueck = rueck.Replace('"','');
   string Part; string Part1; string Part2;

   foreach (Part, rueck.Split(",") ){
           if (Part.Contains(":"))
           {
           WriteLine (Part);

           }
   }
} else {
  WriteLine("Error at HHTP Request");
}                                   
Output from Homematic script test:

Code: Alles auswählen

Error at HHTP Request
Can you please try it on your Homematic system?

MichaelN
Beiträge: 9561
Registriert: 27.04.2020, 10:34
System: CCU
Hat sich bedankt: 696 Mal
Danksagung erhalten: 1608 Mal

Re: WeatherFlow - Tempest

Beitrag von MichaelN » 21.12.2020, 12:10

OK, thanks. This leads me into the right direction.
The timeout command was wrong. Try this:

Code: Alles auswählen

!WeatherFlow - Tempest auslesen
!V1.0 MichaelN https://homematic-forum.de/forum/viewtopic.php?f=49&t=63711
string url = "https://swd.weatherflow.com/swd/rest/observations/station/2867?token=2fdf9a5b-19a0-46e6-99b3-28d67f8cab44";
string rueck;
string error;
system.Exec("wget --no-check-certificate -O - '"#url#"'" , &rueck, &error);

if (!rueck== "")
{
   WriteLine("HTTPRequest OK");
   rueck = rueck.Replace('"','');
   string Part; string Part1; string Part2;

   foreach (Part, rueck.Split(",") ){
           if (Part.Contains(":"))
           {
           WriteLine (Part);

           }
   }
} else {
  WriteLine("Error at HTTP Request");
}                                   
LG, Michael.

Wenn du eine App zur Bedienung brauchst, dann hast du kein Smarthome.

Wettervorhersage über AccuWeather oder OpenWeatherMap+++ Rollladensteuerung 2.0 +++ JSON-API-Ausgaben auswerten +++ undokumentierte Skript-Befehle und Debugging-Tipps +++

omicronCZ
Beiträge: 206
Registriert: 31.07.2011, 17:37
System: CCU
Wohnort: Czech Rep.
Hat sich bedankt: 80 Mal
Danksagung erhalten: 12 Mal

Re: WeatherFlow - Tempest

Beitrag von omicronCZ » 21.12.2020, 12:12

Yeees :D

Output:

Code: Alles auswählen

HTTPRequest OK
{station_id:2867
station_name:Bleiberg (Bublava
public_name:Bleiberg (Bublava
latitude:50.36208
longitude:12.50608
timezone:Europe/Prague
elevation:700.0
is_public:true
status:{status_code:0
status_message:SUCCESS}
station_units:{units_temp:c
units_wind:kph
units_precip:mm
units_pressure:mb
units_distance:km
units_direction:degrees
units_other:metric}
outdoor_keys:[timestamp
obs:[{timestamp:1608549074
air_temperature:0.1
barometric_pressure:940.5
station_pressure:940.5
sea_level_pressure:1023.0
relative_humidity:99
precip:0.0
precip_accum_last_1hr:0.0
precip_accum_local_day:0.101547
precip_accum_local_yesterday:0.001252
precip_minutes_local_day:27
precip_minutes_local_yesterday:1
wind_avg:0.6
wind_direction:208
wind_gust:0.9
wind_lull:0.4
solar_radiation:32
uv:0.16
brightness:3875
lightning_strike_last_epoch:1599316508
lightning_strike_last_distance:14
lightning_strike_count:0
lightning_strike_count_last_1hr:0
lightning_strike_count_last_3hr:0
feels_like:0.1
heat_index:0.1
wind_chill:0.1
dew_point:-0.0
wet_bulb_temperature:0.0
delta_t:0.1
air_density:1.19903
pressure_trend:steady}]}

MichaelN
Beiträge: 9561
Registriert: 27.04.2020, 10:34
System: CCU
Hat sich bedankt: 696 Mal
Danksagung erhalten: 1608 Mal

Re: WeatherFlow - Tempest

Beitrag von MichaelN » 21.12.2020, 13:33

OK. Finished!

Code: Alles auswählen

!WeatherFlow - Tempest auslesen
!V1.0 MichaelN https://homematic-forum.de/forum/viewtopic.php?f=49&t=63711
string url = "https://swd.weatherflow.com/swd/rest/observations/station/STATIONID?token=TOKEN";
string prefix = "WF_";
string rueck;
string error;
object SV;

system.Exec("wget --no-check-certificate --timeout=2 -O - '"#url#"'" , &rueck, &error);
if (!rueck== "")
{
   WriteLine("HTTP-Request OK");
   rueck = rueck.Replace('"','');
   string Part; 

   foreach (Part, rueck.Split(",") ){
           if (Part.Contains(":"))
           {
           Part = Part.Replace(":",";");
           WriteLine (prefix # web.webGetValueFromList(Part,0) #" = "# web.webGetValueFromList(Part,1));
           SV = dom.GetObject(ID_SYSTEM_VARIABLES).Get((prefix # web.webGetValueFromList(Part,0)));
           if (SV) {
              SV.State(web.webGetValueFromList(Part,1));
              WriteLine("=== SV "#prefix # web.webGetValueFromList(Part,0)#" written ===");
              }
           }
   }
} else {
  WriteLine("Error at HTTP Request");
}
Put in the URL with right Station ID and Token
Edit the prefix to your needs. I choosed "WF_"
Create the needed systemvariables like the scheme "prefix_tag" i.e. "WF_wind_gust" as number or string depends on the expected data.
If you run the script in the script-testing-area you will get an output whichs shows the possible names of systemvariables and the value. If the variable exist you find a write confirmation.
Run the script daily or hourly.
LG, Michael.

Wenn du eine App zur Bedienung brauchst, dann hast du kein Smarthome.

Wettervorhersage über AccuWeather oder OpenWeatherMap+++ Rollladensteuerung 2.0 +++ JSON-API-Ausgaben auswerten +++ undokumentierte Skript-Befehle und Debugging-Tipps +++

omicronCZ
Beiträge: 206
Registriert: 31.07.2011, 17:37
System: CCU
Wohnort: Czech Rep.
Hat sich bedankt: 80 Mal
Danksagung erhalten: 12 Mal

Re: WeatherFlow - Tempest

Beitrag von omicronCZ » 21.12.2020, 13:49

Thanks Michael, I'll try in a moment, that's great -)

Otherwise, WeatherFlow states in its API documentation that there is no problem with polling every 1 minute, so the script should definitely run faster than once an hour. To keep the wind and rain data relevant and up-to-date if it is necessary to control eg awnings, outdoor blinds or shutters.

And to be precise, the WF weather station also has a UDP channel for capturing data directly from the hub in the same LAN - this method does not even require an Internet connection.

MichaelN
Beiträge: 9561
Registriert: 27.04.2020, 10:34
System: CCU
Hat sich bedankt: 696 Mal
Danksagung erhalten: 1608 Mal

Re: WeatherFlow - Tempest

Beitrag von MichaelN » 21.12.2020, 14:03

Too many calls of the script could have an influence on the stability of the ccu. I would not go below once per minute. But it's your decision.
LG, Michael.

Wenn du eine App zur Bedienung brauchst, dann hast du kein Smarthome.

Wettervorhersage über AccuWeather oder OpenWeatherMap+++ Rollladensteuerung 2.0 +++ JSON-API-Ausgaben auswerten +++ undokumentierte Skript-Befehle und Debugging-Tipps +++

omicronCZ
Beiträge: 206
Registriert: 31.07.2011, 17:37
System: CCU
Wohnort: Czech Rep.
Hat sich bedankt: 80 Mal
Danksagung erhalten: 12 Mal

Re: WeatherFlow - Tempest

Beitrag von omicronCZ » 21.12.2020, 14:29

Hi Michael, so it works very well, but there are a few minor bugs, could you fix it?

- incorrectly loaded value "timestamp" - on the contrary the variable "WF_obs" is created, but it should rather be "WF_timestamp"

- if it could be corrected, is it possible to write "WF_timestamp" on the correct date (conversion from UNIX Timestamp)? Here is the script

- the same for the variable "WF_lightning_strike_last_epoch", where again is the "UNIX timestamp" of the last recorded flash

- the variable "WF_pressure_trend" has some parentheses at the end, example "falling}]}", is it possible to fix it as well?

Thank you very much Michael

omicronCZ
Beiträge: 206
Registriert: 31.07.2011, 17:37
System: CCU
Wohnort: Czech Rep.
Hat sich bedankt: 80 Mal
Danksagung erhalten: 12 Mal

Re: WeatherFlow - Tempest

Beitrag von omicronCZ » 21.12.2020, 14:32

You're right, do you think the frequency of script calls, maybe once every 3-5 minutes, could be suitable?
MichaelN hat geschrieben:
21.12.2020, 14:03
Too many calls of the script could have an influence on the stability of the ccu. I would not go below once per minute. But it's your decision.

MichaelN
Beiträge: 9561
Registriert: 27.04.2020, 10:34
System: CCU
Hat sich bedankt: 696 Mal
Danksagung erhalten: 1608 Mal

Re: WeatherFlow - Tempest

Beitrag von MichaelN » 21.12.2020, 16:11

Try this one:

Code: Alles auswählen

!WeatherFlow - Tempest auslesen
!V1.1 MichaelN https://homematic-forum.de/forum/viewtopic.php?f=49&t=63711
string url = "https://swd.weatherflow.com/swd/rest/observations/station/2867?token=2fdf9a5b-19a0-46e6-99b3-28d67f8cab44"; ! URL of API Call
string prefix = "WF_";  ! Prefix for systemvariables

! no changes required after this line
string rueck;
string error;
object SV;

system.Exec("wget --no-check-certificate --timeout=2 -O - '"#url#"'" , &rueck, &error);
if (!rueck== "")
{
   WriteLine("HTTP-Request OK");
   rueck = rueck.Replace('"','');
   string Part; string Part1; string Part2;

   foreach (Part, rueck.Split(",") ){
           if (Part.Contains(":"))
           {
           Part = Part.Replace(":",";"); ! aus : ein ; machen, damit dr Inahlt als Liste behandelt wird
           ! stoerende Sonderzeichen entfernen
           Part = Part.Replace("{","");
           Part = Part.Replace("}","");
           Part = Part.Replace("[","");
           Part = Part.Replace("]","");
           ! Part 1 ist der Tag-Name
           Part1 = web.webGetValueFromList(Part,0);
           ! Part 2 ist der Wert des Tags
           Part2 = web.webGetValueFromList(Part,1);
           ! statt obs den Timestamp auslesen
           if (Part1 == "obs") { Part1 = Part2; Part2 = web.webGetValueFromList(Part,2); }
           ! Timestamps in lesbares Datum umwandeln
           if ((Part1 == "timestamp") || (Part1 == "lightning_strike_last_epoch")) { Part2 = Part2.ToInteger().ToTime(); }
           WriteLine (prefix # Part1 #" = "# Part2);
           ! wenn die SV existiert neuen Wert schreiben
           SV = dom.GetObject(ID_SYSTEM_VARIABLES).Get((prefix # Part1));
           if (SV) {
              SV.State(Part2);
              WriteLine("=== SV "#prefix # Part1#" written ===");
              }
           }
   }
} else {
  WriteLine("Error at HTTP Request");
}
if 3-5 minutes are OK or NOT you will notice if there any glitches ;-)
LG, Michael.

Wenn du eine App zur Bedienung brauchst, dann hast du kein Smarthome.

Wettervorhersage über AccuWeather oder OpenWeatherMap+++ Rollladensteuerung 2.0 +++ JSON-API-Ausgaben auswerten +++ undokumentierte Skript-Befehle und Debugging-Tipps +++

Antworten

Zurück zu „HomeMatic - english“