Skip to content

Commit 115cad5

Browse files
authored
Merge pull request #6 from briis/V0.1.7
v0.1.7
2 parents 733ac61 + aef0d01 commit 115cad5

File tree

4 files changed

+78
-7
lines changed

4 files changed

+78
-7
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ Python 2 and 3 module to interact via UDP with a Smart Weather station from Weat
33

44
![GitHub release](https://img.shields.io/github/release/briis/pysmartweatherudp.svg)
55

6-
This module communicates with a Smart Home Weather station from the company [WeatherFlow](http://weatherflow.com/smart-home-weather-stations/) using the UDP API. It retrieves current weather data from the attached units. Currently there are two types of Units:
6+
This module communicates with a Smart Home Weather station from the company [WeatherFlow](http://weatherflow.com/smart-home-weather-stations/) using the UDP API. It retrieves current weather data from the attached units. Currently there are three types of Units:
77
* **AIR** - This unit measures Temperature, Humidity, Pressure and Lightning Strikes
88
* **SKY** - This unit measures Precipitation, Wind, Illuminance and UV
9-
They are both attached to a central hub, that broadcasts the data via UDP and sends the data to a cloud database managed by WeatherFlow. This module retrieves the data by listening to the UDP broadcast on the local network.
9+
* **Tempest** - This unit combines the air and sky units into a single device.
10+
11+
They are all attached to a central hub, that broadcasts the data via UDP and sends the data to a cloud database managed by WeatherFlow. This module retrieves the data by listening to the UDP broadcast on the local network.
12+
13+
There are several broadcasts being sent depending on the station. This module processes four of the broadcasts:
1014

11-
There are several broadcasts being send by the system, and currently this module only uses three of them:
1215
* *rapid_wind* - This contains current wind speed and bearing, and is updated every 3 seconds
13-
* *air_obs* - Here we get Temperature, Humidity, Pressure and Lightning Strikes. This sends out data every minute
14-
* *sky_obs* - This is where we get Precipitation, Wind, Illuminance and UV. Also broadcasts every minute.
16+
* *obs_air* - Here we get Temperature, Humidity, Pressure and Lightning Strikes. This sends out data every minute
17+
* *obs_sky* - This is where we get Precipitation, Wind, Illuminance and UV. Also broadcasts every minute.
18+
* *obs_st* - This is for the new Tempest all in one weather station and combines the air/sky data into a single message sent out every minute.<br>
19+
Note: The Tempest unit will return the battery voltage in both the skybattery and airbattery sensors.
1520

1621
The function is built specifically to be used with [Home Assistant](https://www.home-assistant.io/), so data is formatted to suit that. But it might easily be modified for other purposes.
1722

pysmartweatherudp/receiver.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,37 @@ def run(self):
192192
ds.wind_chill = self._wind_chill
193193
self._feels_like = utils.WeatherFunctions.getFeelsLike(self, self._temperature, self._wind_chill, self._heat_index)
194194
ds.feels_like = self._feels_like
195+
elif jsondata['type'] == 'obs_st':
196+
# RAPID WIND
197+
ds.wind_bearing_rapid = self._wind_bearing_rapid
198+
ds.wind_speed_rapid = self._wind_speed_rapid
199+
# SKY
200+
self._illuminance = ds.illuminance
201+
self._uv = ds.uv
202+
self._wind_bearing = ds.wind_bearing
203+
self._wind_speed = ds.wind_speed
204+
self._wind_lull = ds.wind_lull
205+
self._wind_gust = ds.wind_gust
206+
self._wind_direction = ds.wind_direction
207+
self._solar_radiation = ds.solar_radiation
208+
self._skybattery = ds.skybattery
209+
self._precipitation_rate_raw = ds.precipitation_rate
210+
self._precipitation_rate = round(self._precipitation_rate_raw * 60,2)
211+
# AIR
212+
self._airbattery = ds.airbattery
213+
self._temperature = ds.temperature
214+
self._pressure = ds.pressure
215+
self._humidity = ds.humidity
216+
self._lightning_count = ds.lightning_count
217+
self._lightning_distance = ds.lightning_distance
218+
self._lightning_time = ds.lightning_time
219+
self._dewpoint = ds.dewpoint
220+
self._heat_index = ds.heat_index
221+
# Calculated Values
222+
self._wind_chill = utils.WeatherFunctions.getWindChill(self, self._wind_speed, ds.temperature)
223+
ds.wind_chill = self._wind_chill
224+
self._feels_like = utils.WeatherFunctions.getFeelsLike(self, self._temperature, self._wind_chill, self._heat_index)
225+
ds.feels_like = self._feels_like
195226
else:
196227
ds = None
197228

pysmartweatherudp/utils.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,47 @@ def getDataSet(data, units, ignore_errors=False):
1515
return SkyOberservation(jsondata['obs'][0], units)
1616
elif jsondata['type'] == 'obs_air':
1717
return AirOberservation(jsondata['obs'][0], units)
18+
elif jsondata['type'] == 'obs_st':
19+
return StObservation(jsondata['obs'][0], units)
1820
else:
1921
return None
2022
except:
2123
if not ignore_errors:
2224
raise
2325

26+
class StObservation:
27+
""" Return the Combined Station data Structure. """
28+
def __init__(self, data, units):
29+
# Rapid Wind Data
30+
self.type = 'st'
31+
self.timestamp = data[0]
32+
self.illuminance = data[9]
33+
self.uv = data[10]
34+
self.precipitation_rate = UnitConversion.volume(self, data[12], units)
35+
self.wind_speed = UnitConversion.speed(self, data[2], units)
36+
self.wind_bearing = data[4]
37+
self.wind_lull = UnitConversion.speed(self, data[1], units)
38+
self.wind_gust = UnitConversion.speed(self, data[2], units)
39+
self.skybattery = data[16]
40+
self.solar_radiation = data[11]
41+
self.wind_direction = UnitConversion.wind_direction(self, data[4])
42+
# Air Data
43+
self.pressure = UnitConversion.pressure(self, data[6], units)
44+
self.temperature = round(data[7],1)
45+
self.humidity = data[8]
46+
self.lightning_count = data[15]
47+
self.lightning_distance = UnitConversion.distance(self, data[14], units)
48+
self.lightning_time = datetime.datetime.today().strftime('%Y-%m-%d') if data[15] > 0 else None
49+
self.airbattery = data[16]
50+
self.dewpoint = WeatherFunctions.getDewPoint(self, data[7], data[8])
51+
self.heat_index = WeatherFunctions.getHeatIndex(self, data[7], data[8])
52+
# Rapid Wind Data
53+
self.wind_speed_rapid = 0
54+
self.wind_bearing_rapid = 0
55+
# Calculated Values
56+
self.wind_chill = 0
57+
self.feels_like = 0
58+
2459
class RapidWind:
2560
""" Return the Rapid Wind data Structure. """
2661
def __init__(self, data, units):
@@ -119,7 +154,7 @@ def __init__(self, data, units):
119154
# Calculated Values
120155
self.wind_chill = 0
121156
self.feels_like = 0
122-
157+
123158
class UnitConversion:
124159
"""
125160
Conversion Class to convert between different units.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# Versions should comply with PEP440. For a discussion on single-sourcing
1717
# the version across setup.py and the project code, see
1818
# https://packaging.python.org/en/latest/single_source_version.html
19-
version='0.1.6',
19+
version='0.1.7',
2020

2121
description='Receive data from Smart Weather via UDP',
2222
long_description=" ".join(

0 commit comments

Comments
 (0)