mirror of
https://github.com/home-assistant/core.git
synced 2025-04-27 18:57:57 +00:00
New BMW sensor for climate activity (#110287)
* add sensor with climate activity status * Update strings.json * use icon translation and is_available for sensor * use enum with translations * Return None if value is UNKNOWN * fix getting the value: x.value * fix getting the value: x instead of x.value * Fix tests and pre-commit --------- Co-authored-by: Richard <rikroe@users.noreply.github.com>
This commit is contained in:
parent
c5c407b3bb
commit
a99ecb024e
@ -28,3 +28,10 @@ SCAN_INTERVALS = {
|
|||||||
"north_america": 600,
|
"north_america": 600,
|
||||||
"rest_of_world": 300,
|
"rest_of_world": 300,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLIMATE_ACTIVITY_STATE: list[str] = [
|
||||||
|
"cooling",
|
||||||
|
"heating",
|
||||||
|
"inactive",
|
||||||
|
"standby",
|
||||||
|
]
|
||||||
|
@ -85,6 +85,9 @@
|
|||||||
},
|
},
|
||||||
"remaining_fuel_percent": {
|
"remaining_fuel_percent": {
|
||||||
"default": "mdi:gas-station"
|
"default": "mdi:gas-station"
|
||||||
|
},
|
||||||
|
"climate_status": {
|
||||||
|
"default": "mdi:fan"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
|
@ -23,7 +23,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from . import BMWBaseEntity
|
from . import BMWBaseEntity
|
||||||
from .const import DOMAIN, UNIT_MAP
|
from .const import CLIMATE_ACTIVITY_STATE, DOMAIN, UNIT_MAP
|
||||||
from .coordinator import BMWDataUpdateCoordinator
|
from .coordinator import BMWDataUpdateCoordinator
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -153,6 +153,15 @@ SENSOR_TYPES: list[BMWSensorEntityDescription] = [
|
|||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
is_available=lambda v: v.is_lsc_enabled and v.has_combustion_drivetrain,
|
is_available=lambda v: v.is_lsc_enabled and v.has_combustion_drivetrain,
|
||||||
),
|
),
|
||||||
|
BMWSensorEntityDescription(
|
||||||
|
key="activity",
|
||||||
|
translation_key="climate_status",
|
||||||
|
key_class="climate",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=CLIMATE_ACTIVITY_STATE,
|
||||||
|
value=lambda x, _: x.lower() if x != "UNKNOWN" else None,
|
||||||
|
is_available=lambda v: v.is_remote_climate_stop_enabled,
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,6 +122,15 @@
|
|||||||
},
|
},
|
||||||
"remaining_fuel_percent": {
|
"remaining_fuel_percent": {
|
||||||
"name": "Remaining fuel percent"
|
"name": "Remaining fuel percent"
|
||||||
|
},
|
||||||
|
"climate_status": {
|
||||||
|
"name": "Climate status",
|
||||||
|
"state": {
|
||||||
|
"cooling": "Cooling",
|
||||||
|
"heating": "Heating",
|
||||||
|
"inactive": "Inactive",
|
||||||
|
"standby": "Standby"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"switch": {
|
"switch": {
|
||||||
|
@ -96,6 +96,25 @@
|
|||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '340',
|
'state': '340',
|
||||||
}),
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'device_class': 'enum',
|
||||||
|
'friendly_name': 'iX xDrive50 Climate status',
|
||||||
|
'options': list([
|
||||||
|
'cooling',
|
||||||
|
'heating',
|
||||||
|
'inactive',
|
||||||
|
'standby',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.ix_xdrive50_climate_status',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'inactive',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
@ -191,6 +210,25 @@
|
|||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '472',
|
'state': '472',
|
||||||
}),
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'device_class': 'enum',
|
||||||
|
'friendly_name': 'i4 eDrive40 Climate status',
|
||||||
|
'options': list([
|
||||||
|
'cooling',
|
||||||
|
'heating',
|
||||||
|
'inactive',
|
||||||
|
'standby',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.i4_edrive40_climate_status',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'heating',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
@ -261,6 +299,25 @@
|
|||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '80',
|
'state': '80',
|
||||||
}),
|
}),
|
||||||
|
StateSnapshot({
|
||||||
|
'attributes': ReadOnlyDict({
|
||||||
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
'device_class': 'enum',
|
||||||
|
'friendly_name': 'M340i xDrive Climate status',
|
||||||
|
'options': list([
|
||||||
|
'cooling',
|
||||||
|
'heating',
|
||||||
|
'inactive',
|
||||||
|
'standby',
|
||||||
|
]),
|
||||||
|
}),
|
||||||
|
'context': <ANY>,
|
||||||
|
'entity_id': 'sensor.m340i_xdrive_climate_status',
|
||||||
|
'last_changed': <ANY>,
|
||||||
|
'last_reported': <ANY>,
|
||||||
|
'last_updated': <ANY>,
|
||||||
|
'state': 'inactive',
|
||||||
|
}),
|
||||||
StateSnapshot({
|
StateSnapshot({
|
||||||
'attributes': ReadOnlyDict({
|
'attributes': ReadOnlyDict({
|
||||||
'attribution': 'Data provided by MyBMW',
|
'attribution': 'Data provided by MyBMW',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user