FHEM - Hausautomations-Systeme > Wettermodule

Neues Modul für die WS980WiFi Wetterstation

(1/53) > >>

choenig:
Hallo zusammen,

Das Modul ist seit dem 07.04.2019 ins svn eingecheckt.

mit Unterstützung aus dem ELV-Forum(https://www.elv.de/topic/protokolldefinition-zum-datenaustausch-ws980-zum-pc.html) ist es mir gelungen, die o.a. Wetterstation direkt auszulesen, ohne über wunderground oder ähnliche Services zu gehen.

Unterstützt werden zur Zeit folgende Daten:

* Aktuelles Wetter
* heutiges Maxium
* heutiges Minimum
* absolutes Maximum
* absolutes Minimum
* Firmware-Version
Ich freue mich auch über Verbesserungsvorschläge, insbesondere über die Namen der Readings, falls es fhem-weit etwas standardisierteres gibt.

Hier der Ausschnitt aus der commandref:


--- Code: ---WS980 - Requests weather data locally from WS980WiFi weather stations

Define

define <name> WS980 [IP] [INTERVAL]

[IP] Optional: The IP of the WS980WiFi. If no IP is given, the station is auto-discovered.
[INTERVAL] Optional: The interval in seconds to request updates, default: 30 seconds.

Example:

define ws980wifi WS980 192.168.2.177 60

This statement creates an WS980 instance with the name ws980wifi with the IP 192.168.2.177.
With an interval of 60 seconds the weather information are requested.

Readings
temperatureInside [°C]
The IN-temperature at the display.
temperature [°C]
The temperature measured by the outdoor probe.
dewPoint [°C]
The dew-point calculated by the weather station.
windChill [°C]
The wind-chill calculated by the weather station.
heatIndex [°C]
The heat-index calculated by the weather station.
humidityInside [%]
The IN-humidity at the display.
humidity [%]
The humidity measured by the outdoor probe.
pressureAbs [hPa]
The absolute pressure measured by the outdoor probe.
pressureRel [hPa]
The relative pressure measured by the outdoor probe. This only differs from pressureAbs if you have an offset configured in your WS980.
pressureRel_calculated [hPa]
The relative pressure calculated using the QFF forumula based on temperature, pressureAbs, altitude and humidity.
windDirection [°]
The wind-direction measured by the outdoor probe.
wind [m/s]
The wind-seed measured by the outdoor probe.
windGusts [m/s]
The speed of wind-gusts measured by the outdoor probe.
rainRate [mm]
The current rain-rate measured by the outdoor probe.
rainPerDay [mm]
The rain-rate per day measured by the outdoor probe.
rainPerWeek [mm]
The rain-rate per week measured by the outdoor probe.
rainPerMonth [mm]
The rain-rate per month measured by the outdoor probe.
rainPerYear [mm]
The rain-rate per year measured by the outdoor probe.
rainTotal [mm]
The total rain-rate measured by the outdoor probe.
rain24h [mm]
The amount of rain in the last 24h. This value is calculated from rainTotal and is updated once per hour. In the first 24h, the amunt is displayed in "()" and shows the count of hours recorded already.
brightness [lux]
The brightness measured by the outdoor probe.
uv [uW/m²]
The raw UV-values measured by the outdoor probe.
uvIndex [0-15]
The UV-Index calculated by the weather station.

Set
update
manually update current weather data

Attributes
attr <name> altitude <height>
Specifies the mean sea level in meters. Default is 0. Used to calculate the pressureRel_calculated-reading. If unset, the altitude from global is used.
attr <name> connection <Keep-Alive|Close>
Keep-Alive: The connection to the WS980 is kept open as long as possible. Reconnect is only done if necessary. Keep-Alive is default and a good setting in most cases.
Close: The connection is opened on-the-fly and closed directly after doing requests. Close should only be used if you have multiple clients connection to your WS980 which might cause frequent read-timeouts. ConnectionState will display disconnected most of the time, this is OK!
attr <name> events <Configuration>|<Configuration>|...
Allows to configure custom events based on the readings of this instance.
<Configuration> must have the form: NAME:READING<LIMIT,HYSTERESIS or NAME:READING>LIMIT,HYSTERESIS.
NAME: The name used for the reading and the event. To reduce the possibility of collisions with existing readings, the Name of the reading will always be prefixed with 'is'.
READING:The name of the reading which will be compared to LIMIT to set the resulting event to 0 or 1.
< or >: For '<' the reading-value must be less than the LIMIT to result in 1, for '>' the reading-value must be above LIMIT to result in 1.
LIMIT: The value which will be compared to the READINGs current value.
HYSTERESIS: The hysteresis-value is used to reduce fast flipping of 0 and 1.
Configurations can be separated by either "|" or newline. All whitespace will be removed when parsing events.
Examples:
attr <name> events dusk:brightness<30,20
A new reading isDusk will be autogenerated with possible values 0 or 1. As soon as the brightness drops below 30lux, isDusk will switch to 1. The hystereses value of 20 means, that isDusk will switch back to 0 only after either the brightness has reached 50lux (30+20) or the brightness dropped below 10lux (30-20) and then rises above 30lux again.
attr <name> brightSunlight:brightness>80000,5000
A new reading isBrightSunlight will be autogenerated with possible values 0 or 1. As soon as the brightness rises above 80000lux, isBrightSunlight will switch to 1. The hystereses value of 5000 means, that isBrightSunlight will switch back to 0 only after either the brightness has dropped below 75000lux or the brightness was above 85000lux and then drops below 80000lux again.
You can concatenate as many Configurations with '|' as you like. For example:
attr <name> dusk:brightness<30,20|brightSunlight:brightness>80000,5000

attr <name> requests current todayMax ...
A comma or space separated list of values to requests. If empty, all known values are requested.
Valid values: firmware, current, todayMax, todayMin, historyMax, historyMin.
attr <name> showRawBuffer 1
used for development: show raw data received from the WS980WiFi
attr <name> unit_temperature <unit>
set the unit used for temperature-readings. Default: °C
attr <name> unit_pressure <unit>
set the unit used for pressure-readings. Default: hPa
attr <name> unit_wind <unit>
set the unit used for wind-readings. Default: m/s
attr <name> unit_rain <unit>
set the unit used for rain-readings. Default: mm
attr <name> unit_light <unit>
set the unit used for brightness-readings. Default: lux
attr <name> disable 1
disables this WS980-instance

--- Ende Code ---

Ausblick:
Vermutlich ist folgendes noch möglich:

* Auto-discovery der Wetterstation, sodass beim Einrichten keine IP angegeben werden muss
* Abrufen der historischen Wetterdaten. Die Station kann ca. 3500 Datenpunkte speichern
* Berechnen der Niederschlagsmenge der letzen 24h
Updates:

* 0.6.0: Fix coding error (its 'next' in perl, not 'continue' ;) )
* 0.7.0: change to FHEM ReadFn and WriteFn to enhance blocking networks and some other internal changes
* 0.8.0: keep connection alive, if possible
* 0.9.0: make things more stable, calculate relative pressure (pressureRel_calculated)
* 0.11.0:

* use "altitude" from global if defined
* fix nasty bug where each request was sent twice
* don`t try to send msg if connect failed
* reconnect if request did not receive reply
* 0.12.0:

* fix blocking calls to sysread() - set SO_RCVTIMEO on socket to fix blocking-problems
* implement autodiscovery - you can now leave the IP out
* change default interval to 30 secs
* 0.13.0:

* show ConnectionState as internal instead of using »state«
* remove decimals from »humidity« and »uv«
* show »T: 12.5°C H: 70% W: 2.0m/s P: 1011.3hPa« in »state«
* new attribute: connection Keep-Alive|Close to be able to connect to WS980 on-the-fly
* increase connect timeout to 250msecs and display connect error in lastError
* commandref: document altitude, pressureRel_calculated and hide unsupported entries
* implement unit conversion for temperature, pressure, wind, rain and light
* 0.14.0:

* calculate rain24h based on rainTotal (see "rain24h"-reading)
* implement custom "events" (see "events"-attribute)
* support attribute-specific help in FHEMWEB
* internal changes regarding the use of const variables
* internal changes to possibly support more than one WS980
* 1.0.0:

* No changes to 0.14.0.

LG
Christian

CoolTux:
Hallo,

Hast Du mal geschaut wie lange FHEM blockiert wenn die Station nicht erreichbar ist? Ich kann mir vorstellen das auch im normalen Betrieb merkbar ein blockieren ist. Hier wäre empfehlenswert mit in FHEM vorhandenen Funktionen zu arbeiten.
Im Grunde arbeitet Dein Modul wie das Modul 82_LGTV_WebOS. Wenn Du magst kannst Du Dir da anschauen wie ein TCP Clientsocket aufgebaut wird und die File Descriptor Infos ins select geschickt werden. Es wird nun nicht blockierend geschaut ob Daten am Socket anliegen, wenn ja wird automatisch die ReadFn aufgerufen und die Daten können so abgeholt werden.
Kannst ja mal schauen und wenn Du fragen hast helfe ich sehr gerne.


Grüße

choenig:
Hi,

vielen Dank für Deine Aufmerksamkeit und die Hinweise.

Ich hatte ursprünglich vor, FHEM-Funktionalität für das Networking zu verwenden um das interne select zu nutzen, hab' aber dann nur die HTTP-Funktionen gefunden. 82_LGTV_WebOS werde ich mir angucken!

Seit ich den Read-Timeout auf 500msecs gestellt habe, habe ich keinerlei Probleme mehr gehabt, aber 500 msecs sind auch nicht optimal. Zum Glück antwortet die Station immer sehr schnell :)


--- Code: ---$socket->setsockopt(SOL_SOCKET, SO_RCVTIMEO, pack('l!l!', 0, 500*1000)) or die "setsockopt: $!";

--- Ende Code ---

Und da fällt mir jetzt auf, dass das »or die "setsockopt: $!"« nicht optimal ist :).

LG
Christian

CoolTux:

--- Code: ---$socket->setsockopt(SOL_SOCKET, SO_RCVTIMEO, pack('l!l!', 0, 500*1000)) or die "setsockopt: $!";

--- Ende Code ---

Und da fällt mir jetzt auf, dass das »or die "setsockopt: $!"« nicht optimal ist :).

LG
Christian
[/quote]

Siehst so weit war ich noch gar nicht.
or die darf in der Tat nie in einem FHEM Modul vorhanden sein, da es ansonsten das ganze FHEM in den Tot reißt  :D

Wie gesagt wenn Du Fragen hast einfach fragen.


Grüße

choenig:
Hi,

ich habe gerade eine aktualisierte Version an den 1. Post gehängt.

Ich nutze jetzt, wie von Marko vorgeschlagen, die FHEM-Funktionen zum Lesen und Schreiben in Sockets. Ansonsten habe ich noch diverse Interna optimiert. Z.b. hab' ich auch das unsägliche 'die' entfernt, welches vom copy'n'paste übrig geblieben war ;).

@Marko: Ich würde mich über weiteres Feedback von Dir freuen!

Ansonsten gilt: Diese Version ist alpha, ich habe sie erst seit ein paar Minuten im Einsatz, aber ... freiwillige vor :)

LG
Christian

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln