Skip to content

Commit

Permalink
v0.8.3
Browse files Browse the repository at this point in the history
merge PR cytech#100 Add sensor for wind direction as friendly name
  • Loading branch information
dave_albright committed Nov 14, 2022
1 parent 169afe7 commit 1050516
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 127 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Home Assistant custom component sensor for Weather Underground personal weather

:+1: If you find this product useful, feel free to buy me a beer: https://paypal.me/cytecheng

UPGRADE NOTE v0.8.3: Requires Home Assistant v 2022.11 or later

UPGRADE NOTE v0.8.X: Requires Home Assistant v 2021.8 or later

UPGRADE NOTE: numeric_precision must be added to your exisiting configuration.yaml for this sensor.
Expand Down Expand Up @@ -107,6 +109,8 @@ Description of terms and variables
description: Current levels of UV radiation. See [here](https://www.wunderground.com/resources/health/uvindex.asp) for explanation.
winddir:
description: Wind degrees
windDirectionName:
description: Wind cardinal direction (N,S,E,W, etc)
humidity:
description: Relative humidity
dewpt:
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.8.3
merge PR #100 Add sensor for wind direction as friendly name

v0.8.2
2022-11-03
fix for HASS 2023.1 deprecation is_metric

v0.8.1
2021-12-16
fixes for 2022.X deprecations:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/wundergroundpws/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "wundergroundpws",
"name": "Wundergroundpws",
"version": "0.8.2",
"version": "0.8.3",
"documentation": "https://github.com/cytech/Home-Assistant-wundergroundpws",
"issue_tracker": "https://github.com/cytech/Home-Assistant-wundergroundpws/issues/",
"requirements": [],
Expand Down
42 changes: 42 additions & 0 deletions custom_components/wundergroundpws/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ def __init__(self, friendly_name, period, field,
value=lambda wu: int(wu.data['observations'][0]['winddir'] or 0),
unit_of_measurement='\u00b0',
icon="mdi:weather-windy"),
'windDirectionName': WUSensorConfig(
'Wind Direction', 'observations',
value=lambda wu: wind_direction_to_friendly_name(int(wu.data['observations'][0]['winddir'] or -1)),
unit_of_measurement='',
icon="mdi:weather-windy"),
'today_summary': WUSensorConfig(
'Today Summary', 'observations',
value=lambda wu: str(wu.data['narrative'][0]),
Expand Down Expand Up @@ -319,6 +324,43 @@ def __init__(self, friendly_name, period, field,
"mdi:umbrella"),
}

def wind_direction_to_friendly_name(argument):
if (argument < 0):
return ""
if 348.75 <= argument or 11.25 > argument:
return "N"
if 11.25 <= argument < 33.75:
return "NNE"
if 33.75 <= argument < 56.25:
return "NE"
if 56.25 <= argument < 78.75:
return "ENE"
if 78.75 <= argument < 101.25:
return "E"
if 101.25 <= argument < 123.75:
return "ESE"
if 123.75 <= argument < 146.25:
return "SE"
if 146.25 <= argument < 168.75:
return "SSE"
if 168.75 <= argument < 191.25:
return "S"
if 191.25 <= argument < 213.75:
return "SSW"
if 213.75 <= argument < 236.25:
return "SW"
if 236.25 <= argument < 258.75:
return "WSW"
if 258.75 <= argument < 281.25:
return "W"
if 281.25 <= argument < 303.75:
return "WNW"
if 303.75 <= argument < 326.25:
return "NW"
if 326.25 <= argument < 348.75:
return "NNW"
return ""

# Language Supported Codes
LANG_CODES = [
'ar-AE', 'az-AZ', 'bg-BG', 'bn-BD', 'bn-IN', 'bs-BA', 'ca-ES', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-GB', 'en-IN',
Expand Down
217 changes: 91 additions & 126 deletions custom_components/wundergroundpws/sensor.wundergroundpws.markdown
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
---
layout: page
title: "Weather UndergroundPWS (WUndergroundPWS)"
description: "Instructions on how to integrate Weather Underground (WUnderground) Personal Weather Station within Home Assistant."
date: 2019-03-19
sidebar: true
comments: false
sharing: true
footer: true
logo: wunderground.png
ha_category: Weather
ha_release: 0.89
ha_iot_class: "Cloud Polling"
---

The `wundergroundpws` platform uses [Weather Underground](http://www.wunderground.com) as a source for current weather information.

<p class='note warning'>
Free API keys are only issued to registered and active Weather Underground personal weather station users.

To use this sensor, you need to enter your personal weather station API key and Station ID in configuration.yaml.
Expand All @@ -37,9 +22,8 @@ Please consider this when using the following information.
Current conditions are generated from the wundergroundpws configured pws_id.

Forecast is generated from the HA configured latitude/longitude.
</p>

{% linkable_title Configuration %}


To add Wunderground to your installation, add the following to your `configuration.yaml` file:

Expand All @@ -49,110 +33,109 @@ sensor:
- platform: wundergroundpws
api_key: YOUR_API_KEY
pws_id: YOUR_STATION_ID
numeric_precision: none
monitored_conditions:
- temp
- dewpt
- heatIndex
```
Description of terms and variables
```yaml
api_key:
description: The API key for Weather Underground. See above for details.
required: true
type: string
pws_id:
description: "You must enter a Personal Weather Station ID. The station id will be used to display current weather conditions."
required: true
type: string
numeric_precision:
description: Required - Show PWS data as integer or decimal
required: true - Value of 'none' or 'decimal'
type: string
lang:
description: Specify the language that the API returns. The current list of all Wunderground language codes is available at https://docs.google.com/document/d/13HTLgJDpsb39deFzk_YCQ5GoGoZCO_cRYzIxbwvgJLI/edit#). If not specified, it defaults to English (en-US).
required: false
type: string
default: en-US
latitude:
description: Latitude coordinate for weather forecast (required if **longitude** is specified).
required: false
type: string
default: Coordinates defined in your `configuration.yaml`
longitude:
description: Longitude coordinate for weather forecast (required if **latitude** is specified).
required: false
type: string
default: Coordinates defined in your `configuration.yaml`
monitored_conditions:
description: Conditions to display in the frontend. The following conditions can be monitored.
required: true
type: list
default: symbol
keys:
(generated from PWS)
stationID:
description: Your personal weather station (PWS) ID
solarRadiation:
description: Current levels of solar radiation
neighborhood:
description: WU PWS reference name
obsTimeLocal:
description: Text summary of local observation time
uv:
description: Current levels of UV radiation. See [here](https://www.wunderground.com/resources/health/uvindex.asp) for explanation.
winddir:
description: Wind degrees
windDirectionName:
description: Wind cardinal direction (N,S,E,W, etc)
humidity:
description: Relative humidity
dewpt:
description: Temperature below which water droplets begin to condense and dew can form
heatIndex:
description: Heat index (combined effects of the temperature and humidity of the air)
windChill:
description: Wind Chill (combined effects of the temperature and wind)
elev:
description: Elevation
precipTotal:
description: Today Total precipitation
precipRate:
description: Rain intensity
pressure:
description: Atmospheric air pressure
temp:
description: Current temperature
windGust:
description: Wind gusts speed
windSpeed:
description: Current wind speed
(generated from lat/lon forecast)
precip_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted precipitation intensity"
precip_chance_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted precipitation probability in %"
temp_high_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted high temperature"
temp_low_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted low temperature"
wind_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted wind speed"
weather_1d:
description: "[<sup>[12h]</sup>](#12h): A human-readable weather forecast of Day"
weather_1n:
description: "[<sup>[12h]</sup>](#12h): A human-readable weather forecast of Night"
```
{% configuration %}
api_key:
description: The API key for Weather Underground. See above for details.
required: true
type: string
pws_id:
description: "You must enter a Personal Weather Station ID. The station id will be used to display current weather conditions."
required: true
type: string
lang:
description: Specify the language that the API returns. The current list of all Wunderground language codes is available [here](https://docs.google.com/document/d/13HTLgJDpsb39deFzk_YCQ5GoGoZCO_cRYzIxbwvgJLI/edit#). If not specified, it defaults to English (en-US).
required: false
type: string
default: en-US
latitude:
description: Latitude coordinate for weather forecast (required if **longitude** is specified).
required: false
type: string
default: Coordinates defined in your `configuration.yaml`
longitude:
description: Longitude coordinate for weather forecast (required if **latitude** is specified).
required: false
type: string
default: Coordinates defined in your `configuration.yaml`
monitored_conditions:
description: Conditions to display in the frontend. The following conditions can be monitored.
required: true
type: list
default: symbol
keys:
(generated from PWS)
stationID:
description: Your personal weather station (PWS) ID
solarRadiation:
description: Current levels of solar radiation
neighborhood:
description: WU PWS reference name
obsTimeLocal:
description: Text summary of local observation time
UV:
description: Current levels of UV radiation. See [here](https://www.wunderground.com/resources/health/uvindex.asp) for explanation.
winddir:
description: Wind degrees
humidity:
description: Relative humidity
dewpt:
description: Temperature below which water droplets begin to condense and dew can form
heatIndex:
description: Heat index (combined effects of the temperature and humidity of the air)
windChill:
description: Wind Chill (combined effects of the temperature and wind)
elev:
description: Elevation
precipTotal:
description: Today Total precipitation
precipRate:
description: Rain intensity
pressure:
description: Atmospheric air pressure
temp:
description: Current temperature
windGust:
description: Wind gusts speed
windSpeed:
description: Current wind speed
(generated from lat/lon forecast)
precip_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted precipitation intensity"
precip_chance_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted precipitation probability in %"
temp_high_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted high temperature"
temp_low_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted low temperature"
wind_1d:
description: "[<sup>[1d]</sup>](#1d): Forecasted wind speed"
weather_1d:
description: "[<sup>[12h]</sup>](#12h): A human-readable weather forecast of Day"
weather_1n:
description: "[<sup>[12h]</sup>](#12h): A human-readable weather forecast of Night"
{% endconfiguration %}

All the conditions listed above will be updated every 5 minutes.
## {% linkable_title Forecasts %}

### {% linkable_title Daily forecasts %}

Conditions above marked with <a name="1d">[1d]</a> are daily forecasts. To get forecast for different day, replace the number
in `_1d_` part of the sensor name. Valid values are from `1` to `5`.

Conditions above marked with <a name="1n">[1n]</a> are nightly forecasts. To get forecast for different night, replace the number
in `_1n_` part of the sensor name. Valid values are from `1` to `5`.

## {% linkable_title Additional examples %}

### {% linkable_title Daily forecast %}

```yaml
sensor:
- platform: wunderground
Expand All @@ -167,32 +150,14 @@ sensor:
- weather_3n
- weather_4d
- weather_4n
group:
daily_forecast:
name: Daily Forecast
entities:
- sensor.pws_weather_1d
- sensor.pws_weather_1n
- sensor.pws_weather_2d
- sensor.pws_weather_2n
- sensor.pws_weather_3d
- sensor.pws_weather_3n
- sensor.pws_weather_4d
- sensor.pws_weather_4n
```


### {% linkable_title Weather overview %}

<p class='note warning'>
Note: While the platform is called “wundergroundpws” the sensors will show up in Home Assistant as “WUPWS” (eg: sensor.wupws_weather_1d).
</p>

Note that the Weather Underground sensor is added to the entity_registry, so second and subsequent Personal Weather Station ID (pws_id) will have their monitored conditions suffixed with an index number e.g.

```yaml
- sensor.wupws_weather_1d_metric_2
- sensor.wupws_weather_1d_metric_2
```

Additional details about the API are available [here](https://docs.google.com/document/d/1eKCnKXI9xnoMGRRzOL1xPCBihNV2rOet08qpE_gArAY/edit).

0 comments on commit 1050516

Please sign in to comment.