mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Use enum device class in Netatmo wind direction (#115413)
* Use enum device class in Netatmo wind direction * Use enum device class in Netatmo wind direction --------- Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
fb5fc136e8
commit
6cc2b1e10a
@ -67,6 +67,17 @@ from .helper import NetatmoArea
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DIRECTION_OPTIONS = [
|
||||
"n",
|
||||
"ne",
|
||||
"e",
|
||||
"se",
|
||||
"s",
|
||||
"sw",
|
||||
"w",
|
||||
"nw",
|
||||
]
|
||||
|
||||
|
||||
def process_health(health: StateType) -> str | None:
|
||||
"""Process health index and return string for display."""
|
||||
@ -199,6 +210,9 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
|
||||
NetatmoSensorEntityDescription(
|
||||
key="windangle",
|
||||
netatmo_name="wind_direction",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=DIRECTION_OPTIONS,
|
||||
value_fn=lambda x: x.lower() if isinstance(x, str) else None,
|
||||
),
|
||||
NetatmoSensorEntityDescription(
|
||||
key="windangle_value",
|
||||
@ -218,6 +232,9 @@ SENSOR_TYPES: tuple[NetatmoSensorEntityDescription, ...] = (
|
||||
key="gustangle",
|
||||
netatmo_name="gust_direction",
|
||||
entity_registry_enabled_default=False,
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=DIRECTION_OPTIONS,
|
||||
value_fn=lambda x: x.lower() if isinstance(x, str) else None,
|
||||
),
|
||||
NetatmoSensorEntityDescription(
|
||||
key="gustangle_value",
|
||||
|
@ -185,13 +185,33 @@
|
||||
"name": "Precipitation today"
|
||||
},
|
||||
"wind_direction": {
|
||||
"name": "Wind direction"
|
||||
"name": "Wind direction",
|
||||
"state": {
|
||||
"n": "North",
|
||||
"ne": "North-east",
|
||||
"e": "East",
|
||||
"se": "South-east",
|
||||
"s": "South",
|
||||
"sw": "South-west",
|
||||
"w": "West",
|
||||
"nw": "North-west"
|
||||
}
|
||||
},
|
||||
"wind_angle": {
|
||||
"name": "Wind angle"
|
||||
},
|
||||
"gust_direction": {
|
||||
"name": "Gust direction"
|
||||
"name": "Gust direction",
|
||||
"state": {
|
||||
"n": "[%key:component::netatmo::entity::sensor::wind_direction::state::n%]",
|
||||
"ne": "[%key:component::netatmo::entity::sensor::wind_direction::state::ne%]",
|
||||
"e": "[%key:component::netatmo::entity::sensor::wind_direction::state::e%]",
|
||||
"se": "[%key:component::netatmo::entity::sensor::wind_direction::state::se%]",
|
||||
"s": "[%key:component::netatmo::entity::sensor::wind_direction::state::s%]",
|
||||
"sw": "[%key:component::netatmo::entity::sensor::wind_direction::state::sw%]",
|
||||
"w": "[%key:component::netatmo::entity::sensor::wind_direction::state::w%]",
|
||||
"nw": "[%key:component::netatmo::entity::sensor::wind_direction::state::nw%]"
|
||||
}
|
||||
},
|
||||
"gust_angle": {
|
||||
"name": "Gust angle"
|
||||
|
@ -6073,7 +6073,18 @@
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'n',
|
||||
'ne',
|
||||
'e',
|
||||
'se',
|
||||
's',
|
||||
'sw',
|
||||
'w',
|
||||
'nw',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
@ -6090,7 +6101,7 @@
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Gust direction',
|
||||
'platform': 'netatmo',
|
||||
@ -6105,14 +6116,25 @@
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Netatmo',
|
||||
'device_class': 'enum',
|
||||
'friendly_name': 'Villa Garden Gust direction',
|
||||
'options': list([
|
||||
'n',
|
||||
'ne',
|
||||
'e',
|
||||
'se',
|
||||
's',
|
||||
'sw',
|
||||
'w',
|
||||
'nw',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.villa_garden_gust_direction',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'S',
|
||||
'state': 's',
|
||||
})
|
||||
# ---
|
||||
# name: test_entity[sensor.villa_garden_gust_strength-entry]
|
||||
@ -6317,7 +6339,18 @@
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'n',
|
||||
'ne',
|
||||
'e',
|
||||
'se',
|
||||
's',
|
||||
'sw',
|
||||
'w',
|
||||
'nw',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
@ -6334,7 +6367,7 @@
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Wind direction',
|
||||
'platform': 'netatmo',
|
||||
@ -6349,14 +6382,25 @@
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by Netatmo',
|
||||
'device_class': 'enum',
|
||||
'friendly_name': 'Villa Garden Wind direction',
|
||||
'options': list([
|
||||
'n',
|
||||
'ne',
|
||||
'e',
|
||||
'se',
|
||||
's',
|
||||
'sw',
|
||||
'w',
|
||||
'nw',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.villa_garden_wind_direction',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'SW',
|
||||
'state': 'sw',
|
||||
})
|
||||
# ---
|
||||
# name: test_entity[sensor.villa_garden_wind_speed-entry]
|
||||
|
@ -165,17 +165,17 @@ async def test_process_health(health: int, expected: str) -> None:
|
||||
),
|
||||
("12:34:56:80:c1:ea-sum_rain_1", "villa_rain_rain_last_hour", "0"),
|
||||
("12:34:56:80:c1:ea-sum_rain_24", "villa_rain_rain_today", "6.9"),
|
||||
("12:34:56:03:1b:e4-windangle", "netatmoindoor_garden_direction", "SW"),
|
||||
("12:34:56:03:1b:e4-windangle", "netatmoindoor_garden_direction", "sw"),
|
||||
(
|
||||
"12:34:56:03:1b:e4-windangle_value",
|
||||
"netatmoindoor_garden_angle",
|
||||
"217",
|
||||
),
|
||||
("12:34:56:03:1b:e4-gustangle", "mystation_garden_gust_direction", "S"),
|
||||
("12:34:56:03:1b:e4-gustangle", "mystation_garden_gust_direction", "s"),
|
||||
(
|
||||
"12:34:56:03:1b:e4-gustangle",
|
||||
"netatmoindoor_garden_gust_direction",
|
||||
"S",
|
||||
"s",
|
||||
),
|
||||
(
|
||||
"12:34:56:03:1b:e4-gustangle_value",
|
||||
|
Loading…
x
Reference in New Issue
Block a user