Skip to content

Commit

Permalink
Merge pull request #6 from briis/V0.1.7
Browse files Browse the repository at this point in the history
v0.1.7
  • Loading branch information
LuckyJayDIY authored Jun 10, 2020
2 parents 733ac61 + aef0d01 commit 115cad5
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 7 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ Python 2 and 3 module to interact via UDP with a Smart Weather station from Weat

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

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:
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:
* **AIR** - This unit measures Temperature, Humidity, Pressure and Lightning Strikes
* **SKY** - This unit measures Precipitation, Wind, Illuminance and UV
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.
* **Tempest** - This unit combines the air and sky units into a single device.

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.

There are several broadcasts being sent depending on the station. This module processes four of the broadcasts:

There are several broadcasts being send by the system, and currently this module only uses three of them:
* *rapid_wind* - This contains current wind speed and bearing, and is updated every 3 seconds
* *air_obs* - Here we get Temperature, Humidity, Pressure and Lightning Strikes. This sends out data every minute
* *sky_obs* - This is where we get Precipitation, Wind, Illuminance and UV. Also broadcasts every minute.
* *obs_air* - Here we get Temperature, Humidity, Pressure and Lightning Strikes. This sends out data every minute
* *obs_sky* - This is where we get Precipitation, Wind, Illuminance and UV. Also broadcasts every minute.
* *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>
Note: The Tempest unit will return the battery voltage in both the skybattery and airbattery sensors.

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.

Expand Down
31 changes: 31 additions & 0 deletions pysmartweatherudp/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,37 @@ def run(self):
ds.wind_chill = self._wind_chill
self._feels_like = utils.WeatherFunctions.getFeelsLike(self, self._temperature, self._wind_chill, self._heat_index)
ds.feels_like = self._feels_like
elif jsondata['type'] == 'obs_st':
# RAPID WIND
ds.wind_bearing_rapid = self._wind_bearing_rapid
ds.wind_speed_rapid = self._wind_speed_rapid
# SKY
self._illuminance = ds.illuminance
self._uv = ds.uv
self._wind_bearing = ds.wind_bearing
self._wind_speed = ds.wind_speed
self._wind_lull = ds.wind_lull
self._wind_gust = ds.wind_gust
self._wind_direction = ds.wind_direction
self._solar_radiation = ds.solar_radiation
self._skybattery = ds.skybattery
self._precipitation_rate_raw = ds.precipitation_rate
self._precipitation_rate = round(self._precipitation_rate_raw * 60,2)
# AIR
self._airbattery = ds.airbattery
self._temperature = ds.temperature
self._pressure = ds.pressure
self._humidity = ds.humidity
self._lightning_count = ds.lightning_count
self._lightning_distance = ds.lightning_distance
self._lightning_time = ds.lightning_time
self._dewpoint = ds.dewpoint
self._heat_index = ds.heat_index
# Calculated Values
self._wind_chill = utils.WeatherFunctions.getWindChill(self, self._wind_speed, ds.temperature)
ds.wind_chill = self._wind_chill
self._feels_like = utils.WeatherFunctions.getFeelsLike(self, self._temperature, self._wind_chill, self._heat_index)
ds.feels_like = self._feels_like
else:
ds = None

Expand Down
37 changes: 36 additions & 1 deletion pysmartweatherudp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,47 @@ def getDataSet(data, units, ignore_errors=False):
return SkyOberservation(jsondata['obs'][0], units)
elif jsondata['type'] == 'obs_air':
return AirOberservation(jsondata['obs'][0], units)
elif jsondata['type'] == 'obs_st':
return StObservation(jsondata['obs'][0], units)
else:
return None
except:
if not ignore_errors:
raise

class StObservation:
""" Return the Combined Station data Structure. """
def __init__(self, data, units):
# Rapid Wind Data
self.type = 'st'
self.timestamp = data[0]
self.illuminance = data[9]
self.uv = data[10]
self.precipitation_rate = UnitConversion.volume(self, data[12], units)
self.wind_speed = UnitConversion.speed(self, data[2], units)
self.wind_bearing = data[4]
self.wind_lull = UnitConversion.speed(self, data[1], units)
self.wind_gust = UnitConversion.speed(self, data[2], units)
self.skybattery = data[16]
self.solar_radiation = data[11]
self.wind_direction = UnitConversion.wind_direction(self, data[4])
# Air Data
self.pressure = UnitConversion.pressure(self, data[6], units)
self.temperature = round(data[7],1)
self.humidity = data[8]
self.lightning_count = data[15]
self.lightning_distance = UnitConversion.distance(self, data[14], units)
self.lightning_time = datetime.datetime.today().strftime('%Y-%m-%d') if data[15] > 0 else None
self.airbattery = data[16]
self.dewpoint = WeatherFunctions.getDewPoint(self, data[7], data[8])
self.heat_index = WeatherFunctions.getHeatIndex(self, data[7], data[8])
# Rapid Wind Data
self.wind_speed_rapid = 0
self.wind_bearing_rapid = 0
# Calculated Values
self.wind_chill = 0
self.feels_like = 0

class RapidWind:
""" Return the Rapid Wind data Structure. """
def __init__(self, data, units):
Expand Down Expand Up @@ -119,7 +154,7 @@ def __init__(self, data, units):
# Calculated Values
self.wind_chill = 0
self.feels_like = 0

class UnitConversion:
"""
Conversion Class to convert between different units.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.1.6',
version='0.1.7',

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

0 comments on commit 115cad5

Please sign in to comment.