re-add unit
This commit is contained in:
parent
fe600b7877
commit
e971a01acd
1 changed files with 6 additions and 4 deletions
|
@ -115,11 +115,11 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
class OpenWeatherMapSensor(Entity):
|
class OpenWeatherMapSensor(Entity):
|
||||||
""" Implements an OpenWeatherMap sensor. """
|
""" Implements an OpenWeatherMap sensor. """
|
||||||
|
|
||||||
def __init__(self, weather_data, sensor_type, unit):
|
def __init__(self, weather_data, sensor_type, temp_unit):
|
||||||
self.client_name = 'Weather'
|
self.client_name = 'Weather'
|
||||||
self._name = SENSOR_TYPES[sensor_type][0]
|
self._name = SENSOR_TYPES[sensor_type][0]
|
||||||
self.owa_client = weather_data
|
self.owa_client = weather_data
|
||||||
self._unit = unit
|
self.temp_unit = temp_unit
|
||||||
self.type = sensor_type
|
self.type = sensor_type
|
||||||
self._state = None
|
self._state = None
|
||||||
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
|
self._unit_of_measurement = SENSOR_TYPES[sensor_type][1]
|
||||||
|
@ -150,10 +150,10 @@ class OpenWeatherMapSensor(Entity):
|
||||||
if self.type == 'weather':
|
if self.type == 'weather':
|
||||||
self._state = data.get_detailed_status()
|
self._state = data.get_detailed_status()
|
||||||
elif self.type == 'temperature':
|
elif self.type == 'temperature':
|
||||||
if self._unit == TEMP_CELCIUS:
|
if self.temp_unit == TEMP_CELCIUS:
|
||||||
self._state = round(data.get_temperature('celsius')['temp'],
|
self._state = round(data.get_temperature('celsius')['temp'],
|
||||||
1)
|
1)
|
||||||
elif self._unit == TEMP_FAHRENHEIT:
|
elif self.temp_unit == TEMP_FAHRENHEIT:
|
||||||
self._state = round(data.get_temperature('fahrenheit')['temp'],
|
self._state = round(data.get_temperature('fahrenheit')['temp'],
|
||||||
1)
|
1)
|
||||||
else:
|
else:
|
||||||
|
@ -169,12 +169,14 @@ class OpenWeatherMapSensor(Entity):
|
||||||
elif self.type == 'rain':
|
elif self.type == 'rain':
|
||||||
if data.get_rain():
|
if data.get_rain():
|
||||||
self._state = round(data.get_rain()['3h'], 0)
|
self._state = round(data.get_rain()['3h'], 0)
|
||||||
|
self._unit_of_measurement = 'mm'
|
||||||
else:
|
else:
|
||||||
self._state = 'not raining'
|
self._state = 'not raining'
|
||||||
self._unit_of_measurement = ''
|
self._unit_of_measurement = ''
|
||||||
elif self.type == 'snow':
|
elif self.type == 'snow':
|
||||||
if data.get_snow():
|
if data.get_snow():
|
||||||
self._state = round(data.get_snow(), 0)
|
self._state = round(data.get_snow(), 0)
|
||||||
|
self._unit_of_measurement = 'mm'
|
||||||
else:
|
else:
|
||||||
self._state = 'not snowing'
|
self._state = 'not snowing'
|
||||||
self._unit_of_measurement = ''
|
self._unit_of_measurement = ''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue