mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Add Charging sensor to Tessie (#108205)
This commit is contained in:
parent
90ec361fc9
commit
e328d3ec5e
@ -41,6 +41,7 @@ DESCRIPTIONS: tuple[TessieBinarySensorEntityDescription, ...] = (
|
||||
key="charge_state_charging_state",
|
||||
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||
is_on=lambda x: x == "Charging",
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
TessieBinarySensorEntityDescription(
|
||||
key="charge_state_preconditioning_enabled",
|
||||
|
@ -68,3 +68,13 @@ class TessieChargeCableLockStates(StrEnum):
|
||||
|
||||
ENGAGED = "Engaged"
|
||||
DISENGAGED = "Disengaged"
|
||||
|
||||
|
||||
TessieChargeStates = {
|
||||
"Starting": "starting",
|
||||
"Charging": "charging",
|
||||
"Stopped": "stopped",
|
||||
"Complete": "complete",
|
||||
"Disconnected": "disconnected",
|
||||
"NoPower": "no_power",
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ from homeassistant.helpers.typing import StateType
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.variance import ignore_variance
|
||||
|
||||
from .const import DOMAIN
|
||||
from .const import DOMAIN, TessieChargeStates
|
||||
from .coordinator import TessieStateUpdateCoordinator
|
||||
from .entity import TessieEntity
|
||||
|
||||
@ -54,6 +54,13 @@ class TessieSensorEntityDescription(SensorEntityDescription):
|
||||
|
||||
|
||||
DESCRIPTIONS: tuple[TessieSensorEntityDescription, ...] = (
|
||||
TessieSensorEntityDescription(
|
||||
key="charge_state_charging_state",
|
||||
icon="mdi:ev-station",
|
||||
options=list(TessieChargeStates.values()),
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
value_fn=lambda value: TessieChargeStates[cast(str, value)],
|
||||
),
|
||||
TessieSensorEntityDescription(
|
||||
key="charge_state_usable_battery_level",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -67,6 +67,17 @@
|
||||
}
|
||||
},
|
||||
"sensor": {
|
||||
"charge_state_charging_state": {
|
||||
"name": "Charging",
|
||||
"state": {
|
||||
"starting": "Starting",
|
||||
"charging": "Charging",
|
||||
"disconnected": "Disconnected",
|
||||
"stopped": "Stopped",
|
||||
"complete": "Complete",
|
||||
"no_power": "No power"
|
||||
}
|
||||
},
|
||||
"charge_state_usable_battery_level": {
|
||||
"name": "Battery level"
|
||||
},
|
||||
|
@ -347,6 +347,68 @@
|
||||
'state': '224',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[sensor.test_charging-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'options': list([
|
||||
'starting',
|
||||
'charging',
|
||||
'stopped',
|
||||
'complete',
|
||||
'disconnected',
|
||||
'no_power',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.test_charging',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.ENUM: 'enum'>,
|
||||
'original_icon': 'mdi:ev-station',
|
||||
'original_name': 'Charging',
|
||||
'platform': 'tessie',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'charge_state_charging_state',
|
||||
'unique_id': 'VINVINVIN-charge_state_charging_state',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[sensor.test_charging-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'enum',
|
||||
'friendly_name': 'Test Charging',
|
||||
'icon': 'mdi:ev-station',
|
||||
'options': list([
|
||||
'starting',
|
||||
'charging',
|
||||
'stopped',
|
||||
'complete',
|
||||
'disconnected',
|
||||
'no_power',
|
||||
]),
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.test_charging',
|
||||
'last_changed': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'charging',
|
||||
})
|
||||
# ---
|
||||
# name: test_sensors[sensor.test_destination-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Test the Tessie binary sensor platform."""
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
@ -8,6 +9,7 @@ from homeassistant.helpers import entity_registry as er
|
||||
from .common import assert_entities, setup_platform
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_binary_sensors(
|
||||
hass: HomeAssistant, snapshot: SnapshotAssertion, entity_registry: er.EntityRegistry
|
||||
) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user