Skip to content

Commit 9c08f55

Browse files
authored
Merge pull request #26 from golles/202207_support_unit_conversions
2022.07 Support unit conversions
2 parents 3b39a8d + 51b24f2 commit 9c08f55

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

custom_components/knmi/weather.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
)
1515
from homeassistant.const import (
1616
CONF_NAME,
17-
TEMP_CELSIUS,
1817
)
1918

2019
from .const import CONDITIONS_MAP, DEFAULT_NAME, DOMAIN, WIND_DIRECTION_MAP
@@ -39,57 +38,54 @@ def name(self):
3938
"""Return the name of the sensor."""
4039
return f"{DEFAULT_NAME} {self.entry_name}"
4140

42-
@property
43-
def state(self):
44-
"""Return the state of the sensor."""
45-
return self.condition
46-
4741
@property
4842
def condition(self):
4943
"""Return the current condition."""
5044
if super().getData("d0weer") is not None:
5145
return CONDITIONS_MAP[super().getData("d0weer")]
46+
return None
5247

5348
@property
54-
def temperature(self):
49+
def native_temperature(self):
5550
"""Return the temperature."""
5651
if super().getData("temp") is not None:
5752
return float(super().getData("temp"))
53+
return None
5854

5955
@property
60-
def temperature_unit(self):
61-
"""Return the unit of measurement."""
62-
return TEMP_CELSIUS
63-
64-
@property
65-
def pressure(self):
56+
def native_pressure(self):
6657
"""Return the pressure."""
6758
if super().getData("luchtd") is not None:
6859
return float(super().getData("luchtd"))
60+
return None
6961

7062
@property
71-
def humidity(self):
63+
def native_humidity(self):
7264
"""Return the humidity."""
7365
if super().getData("lv") is not None:
7466
return float(super().getData("lv"))
67+
return None
7568

7669
@property
77-
def wind_speed(self):
70+
def native_wind_speed(self):
7871
"""Return the wind speed."""
7972
if super().getData("windkmh") is not None:
8073
return float(super().getData("windkmh"))
74+
return None
8175

8276
@property
8377
def wind_bearing(self):
8478
"""Return the wind direction."""
8579
if super().getData("windr") is not None:
8680
return WIND_DIRECTION_MAP[super().getData("windr")]
81+
return None
8782

8883
@property
89-
def visibility(self):
84+
def native_visibility(self):
9085
"""Return the wind direction."""
9186
if super().getData("zicht") is not None:
92-
return float(super().getData("zicht")) / 10
87+
return float(super().getData("zicht"))
88+
return None
9389

9490
@property
9591
def forecast(self):

hacs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "knmi",
3-
"homeassistant": "2022.2.0",
3+
"homeassistant": "2022.7.0",
44
"render_readme": true
55
}

0 commit comments

Comments
 (0)