Skip to content

Commit

Permalink
Remove km from visibility, add visibility_distance (#8454)
Browse files Browse the repository at this point in the history
* Remove km from visibility, add visibility_distance

* Fix line length

* Fix trailing space and line break indentation

* Indentation

* More whitespace
  • Loading branch information
gollo authored and balloob committed Jul 14, 2017
1 parent 9373d5e commit d473f34
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion homeassistant/components/sensor/metoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@
'exceptional': [],
}

VISIBILTY_CLASSES = {
'VP': '<1',
'PO': '1-4',
'MO': '4-10',
'GO': '10-20',
'VG': '20-40',
'EX': '>40'
}

SCAN_INTERVAL = timedelta(minutes=35)

# Sensor types are defined like: Name, units
Expand All @@ -51,7 +60,8 @@
'wind_speed': ['Wind Speed', 'm/s'],
'wind_direction': ['Wind Direction', None],
'wind_gust': ['Wind Gust', 'm/s'],
'visibility': ['Visibility', 'km'],
'visibility': ['Visibility', None],
'visibility_distance': ['Visibility Distance', 'km'],
'uv': ['UV', None],
'precipitation': ['Probability of Precipitation', '%'],
'humidity': ['Humidity', '%']
Expand Down Expand Up @@ -119,6 +129,9 @@ def name(self):
@property
def state(self):
"""Return the state of the sensor."""
if (self._condition == 'visibility_distance' and
'visibility' in self.data.data.__dict__.keys()):
return VISIBILTY_CLASSES.get(self.data.data.visibility.value)
if self._condition in self.data.data.__dict__.keys():
variable = getattr(self.data.data, self._condition)
if self._condition == "weather":
Expand Down

0 comments on commit d473f34

Please sign in to comment.