mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Migrate zamg to native_* (#74034)
This commit is contained in:
parent
f66fc65d0b
commit
37e8f113d4
@ -14,7 +14,14 @@ from homeassistant.components.weather import (
|
|||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
WeatherEntity,
|
WeatherEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.const import CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME, TEMP_CELSIUS
|
from homeassistant.const import (
|
||||||
|
CONF_LATITUDE,
|
||||||
|
CONF_LONGITUDE,
|
||||||
|
CONF_NAME,
|
||||||
|
LENGTH_MILLIMETERS,
|
||||||
|
SPEED_KILOMETERS_PER_HOUR,
|
||||||
|
TEMP_CELSIUS,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -80,6 +87,12 @@ def setup_platform(
|
|||||||
class ZamgWeather(WeatherEntity):
|
class ZamgWeather(WeatherEntity):
|
||||||
"""Representation of a weather condition."""
|
"""Representation of a weather condition."""
|
||||||
|
|
||||||
|
_attr_native_pressure_unit = (
|
||||||
|
LENGTH_MILLIMETERS # API reports l/m², equivalent to mm
|
||||||
|
)
|
||||||
|
_attr_native_temperature_unit = TEMP_CELSIUS
|
||||||
|
_attr_native_wind_speed_unit = SPEED_KILOMETERS_PER_HOUR
|
||||||
|
|
||||||
def __init__(self, zamg_data, stationname=None):
|
def __init__(self, zamg_data, stationname=None):
|
||||||
"""Initialise the platform with a data instance and station name."""
|
"""Initialise the platform with a data instance and station name."""
|
||||||
self.zamg_data = zamg_data
|
self.zamg_data = zamg_data
|
||||||
@ -104,17 +117,12 @@ class ZamgWeather(WeatherEntity):
|
|||||||
return ATTRIBUTION
|
return ATTRIBUTION
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature(self):
|
def native_temperature(self):
|
||||||
"""Return the platform temperature."""
|
"""Return the platform temperature."""
|
||||||
return self.zamg_data.get_data(ATTR_WEATHER_TEMPERATURE)
|
return self.zamg_data.get_data(ATTR_WEATHER_TEMPERATURE)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def temperature_unit(self):
|
def native_pressure(self):
|
||||||
"""Return the unit of measurement."""
|
|
||||||
return TEMP_CELSIUS
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pressure(self):
|
|
||||||
"""Return the pressure."""
|
"""Return the pressure."""
|
||||||
return self.zamg_data.get_data(ATTR_WEATHER_PRESSURE)
|
return self.zamg_data.get_data(ATTR_WEATHER_PRESSURE)
|
||||||
|
|
||||||
@ -124,7 +132,7 @@ class ZamgWeather(WeatherEntity):
|
|||||||
return self.zamg_data.get_data(ATTR_WEATHER_HUMIDITY)
|
return self.zamg_data.get_data(ATTR_WEATHER_HUMIDITY)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wind_speed(self):
|
def native_wind_speed(self):
|
||||||
"""Return the wind speed."""
|
"""Return the wind speed."""
|
||||||
return self.zamg_data.get_data(ATTR_WEATHER_WIND_SPEED)
|
return self.zamg_data.get_data(ATTR_WEATHER_WIND_SPEED)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user