1
mirror of https://github.com/home-assistant/core synced 2024-09-28 03:04:04 +02:00

Migrate zamg to native_* (#74034)

This commit is contained in:
Erik Montnemery 2022-06-28 11:02:13 +02:00 committed by GitHub
parent f66fc65d0b
commit 37e8f113d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,7 +14,14 @@ from homeassistant.components.weather import (
PLATFORM_SCHEMA,
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.helpers import config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -80,6 +87,12 @@ def setup_platform(
class ZamgWeather(WeatherEntity):
"""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):
"""Initialise the platform with a data instance and station name."""
self.zamg_data = zamg_data
@ -104,17 +117,12 @@ class ZamgWeather(WeatherEntity):
return ATTRIBUTION
@property
def temperature(self):
def native_temperature(self):
"""Return the platform temperature."""
return self.zamg_data.get_data(ATTR_WEATHER_TEMPERATURE)
@property
def temperature_unit(self):
"""Return the unit of measurement."""
return TEMP_CELSIUS
@property
def pressure(self):
def native_pressure(self):
"""Return the 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)
@property
def wind_speed(self):
def native_wind_speed(self):
"""Return the wind speed."""
return self.zamg_data.get_data(ATTR_WEATHER_WIND_SPEED)