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
5 changed files with 86 additions and 1 deletions
|
@ -28,3 +28,10 @@ SCAN_INTERVALS = {
|
|||
"north_america": 600,
|
||||
"rest_of_world": 300,
|
||||
}
|
||||
|
||||
CLIMATE_ACTIVITY_STATE: list[str] = [
|
||||
"cooling",
|
||||
"heating",
|
||||
"inactive",
|
||||
"standby",
|
||||
]
|
||||
|
|
|
@ -85,6 +85,9 @@
|
|||
},
|
||||
"remaining_fuel_percent": {
|
||||
"default": "mdi:gas-station"
|
||||
},
|
||||
"climate_status": {
|
||||
"default": "mdi:fan"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
|
|
|
@ -23,7 +23,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||
from homeassistant.helpers.typing import StateType
|
||||
|
||||
from . import BMWBaseEntity
|
||||
from .const import DOMAIN, UNIT_MAP
|
||||
from .const import CLIMATE_ACTIVITY_STATE, DOMAIN, UNIT_MAP
|
||||
from .coordinator import BMWDataUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
@ -153,6 +153,15 @@ SENSOR_TYPES: list[BMWSensorEntityDescription] = [
|
|||
state_class=SensorStateClass.MEASUREMENT,
|
||||
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": {
|
||||
"name": "Remaining fuel percent"
|
||||
},
|
||||
"climate_status": {
|
||||
"name": "Climate status",
|
||||
"state": {
|
||||
"cooling": "Cooling",
|
||||
"heating": "Heating",
|
||||
"inactive": "Inactive",
|
||||
"standby": "Standby"
|
||||
}
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
|
|
|
@ -96,6 +96,25 @@
|
|||
'last_updated': <ANY>,
|
||||
'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({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by MyBMW',
|
||||
|
@ -191,6 +210,25 @@
|
|||
'last_updated': <ANY>,
|
||||
'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({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by MyBMW',
|
||||
|
@ -261,6 +299,25 @@
|
|||
'last_updated': <ANY>,
|
||||
'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({
|
||||
'attributes': ReadOnlyDict({
|
||||
'attribution': 'Data provided by MyBMW',
|
||||
|
|
Loading…
Add table
Reference in a new issue