Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove km from visibility, add visibility_distance #8454

Merged
merged 5 commits into from
Jul 14, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 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,12 @@ def name(self):
@property
def state(self):
"""Return the state of the sensor."""
"""
Special case for added visibility_distance which is just a lookup on visibility code,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (96 > 79 characters)

not retrieved from the dp call directly.
"""
if self._condition == "visibility_distance" and 'visibility' in self.data.data.__dict__.keys():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (103 > 79 characters)

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