mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove km from visibility, add visibility_distance (#8454)
* Remove km from visibility, add visibility_distance * Fix line length * Fix trailing space and line break indentation * Indentation * More whitespace
This commit is contained in:
parent
9373d5e901
commit
d473f3407b
@ -40,6 +40,15 @@ CONDITION_CLASSES = {
|
||||
'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
|
||||
@ -51,7 +60,8 @@ SENSOR_TYPES = {
|
||||
'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', '%']
|
||||
@ -119,6 +129,9 @@ class MetOfficeCurrentSensor(Entity):
|
||||
@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":
|
||||
|
Loading…
x
Reference in New Issue
Block a user