Skip to content
This repository has been archived by the owner on May 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from briis/development
Browse files Browse the repository at this point in the history
V1.2.0
  • Loading branch information
briis committed Jan 28, 2020
2 parents c1bad4f + b6013d0 commit 3c56691
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Default: All Sensors are displayed
* **in_temperature** - Temperature meassured by the Meteobridge Logger (indoor)
* **in_humidity** - Humidity meassured by the Meteobridge Logger (indoor)
* **condition** - Current condition state. Only supplies data if the `weather` component is activated.
* **precip_probability** - Precipitation probability for the day. Only supplies data if the `weather` component is activated.
* **forecast** - A string with the current weather forecast, delivered by the local Weather Station. **Note:** Not all Weather Station will deliver this. I only know of the Davis Weather Stations for now.

### Weather
Expand Down
10 changes: 10 additions & 0 deletions custom_components/mbweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
ATTR_WEATHER_WIND_SPEED = "wind_speed"
ATTR_WEATHER_RAINTODAY = "rain_today"
ATTR_WEATHER_RAINRATE = "rain_rate"
ATTR_WEATHER_PRECIP_PPROBABILIY = "precip_probability"

DOMAIN = 'mbweather'
MBDATA = DOMAIN
Expand Down Expand Up @@ -143,6 +144,11 @@ def rain_rate(self):
"""Return the current Precipitation rate."""
return None

@property
def precip_probability(self):
"""Return the Precipitation Probability."""
return None

@property
def forecast(self):
"""Return the forecast."""
Expand Down Expand Up @@ -174,6 +180,10 @@ def state_attributes(self):
if ozone is not None:
data[ATTR_WEATHER_OZONE] = ozone

precip_probability = self.precip_probability
if precip_probability is not None:
data[ATTR_WEATHER_PRECIP_PPROBABILIY] = precip_probability

pressure = self.pressure
if pressure is not None:
data[ATTR_WEATHER_PRESSURE] = pressure
Expand Down
12 changes: 11 additions & 1 deletion custom_components/mbweather/meteobridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def _get_sensor_data(self):
self._isfreezing = True if float(self._outtemp) < 0 else False
self._israining = True if float(self._rainrate) > 0 else False
self._islowbat = True if float(self._lowbat) > 0 else False

if "condition" in self.sensor_data:
if self.sensor_data["condition"] is not None:
self._condition = self.sensor_data["condition"]
Expand All @@ -84,6 +85,14 @@ def _get_sensor_data(self):
else:
self._condition = None

if "precip_probability" in self.sensor_data:
if self.sensor_data["precip_probability"] is not None:
self._precip_probability = self.sensor_data["precip_probability"]
else:
self._precip_probability = None
else:
self._precip_probability = None

item = {
"in_temperature": self._intemp,
"in_humidity": self._inhum,
Expand All @@ -108,7 +117,8 @@ def _get_sensor_data(self):
"freezing": self._isfreezing,
"forecast": self._fc,
"time": self._timestamp.strftime("%d-%m-%Y %H:%M:%S"),
"condition": self._condition
"condition": self._condition,
"precip_probability": self._precip_probability
}
self.sensor_data.update(item)

Expand Down
1 change: 1 addition & 0 deletions custom_components/mbweather/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
'in_humidity': ['Indoor Hum', '%', 'mdi:water-percent', DEVICE_CLASS_HUMIDITY, None],
'pressure': ['Pressure', 'hPa', 'mdi:gauge', DEVICE_CLASS_PRESSURE, 'inHg'],
'condition': ['Condition', '', 'mdi:text-short', None, None],
'precip_probability': ['Precip Probability', '%', 'mdi:water-percent', None, None],
'forecast': ['Forecast', '', 'mdi:text-short', None, None]
}

Expand Down
7 changes: 7 additions & 0 deletions custom_components/mbweather/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def rain_rate(self):
"""Return the current rain rate."""
return float(self._curdata['rainrate'])

@property
def precip_probability(self):
"""Return the Precipitation Probability."""
precip_prob = int(float(self._ds_currently.get("precipProbability"))*100)
self._curdata['precip_probability'] = precip_prob
return precip_prob

@property
def ozone(self):
"""Return the ozone level."""
Expand Down

0 comments on commit 3c56691

Please sign in to comment.