From 2e2faeb612142f0203fee4a7e634c38a03e98079 Mon Sep 17 00:00:00 2001 From: Brett Adams Date: Tue, 22 Apr 2025 21:16:29 +1000 Subject: [PATCH] Add remaining Binary Sensor entities to Teslemetry (#143384) --- .../components/teslemetry/binary_sensor.py | 45 ++ .../components/teslemetry/icons.json | 42 ++ .../components/teslemetry/strings.json | 24 + .../snapshots/test_binary_sensor.ambr | 482 ++++++++++++++++++ 4 files changed, 593 insertions(+) diff --git a/homeassistant/components/teslemetry/binary_sensor.py b/homeassistant/components/teslemetry/binary_sensor.py index a5ea30e014d..3918484ea97 100644 --- a/homeassistant/components/teslemetry/binary_sensor.py +++ b/homeassistant/components/teslemetry/binary_sensor.py @@ -367,6 +367,51 @@ VEHICLE_DESCRIPTIONS: tuple[TeslemetryBinarySensorEntityDescription, ...] = ( streaming_firmware="2024.44.32", entity_registry_enabled_default=False, ), + TeslemetryBinarySensorEntityDescription( + key="charge_enable_request", + streaming_listener=lambda x, y: x.listen_ChargeEnableRequest(y), + entity_registry_enabled_default=False, + ), + TeslemetryBinarySensorEntityDescription( + key="defrost_for_preconditioning", + streaming_listener=lambda x, y: x.listen_DefrostForPreconditioning(y), + entity_registry_enabled_default=False, + streaming_firmware="2024.44.25", + ), + TeslemetryBinarySensorEntityDescription( + key="lights_high_beams", + streaming_listener=lambda x, y: x.listen_LightsHighBeams(y), + entity_registry_enabled_default=False, + streaming_firmware="2025.2.6", + ), + TeslemetryBinarySensorEntityDescription( + key="seat_vent_enabled", + streaming_listener=lambda x, y: x.listen_SeatVentEnabled(y), + entity_registry_enabled_default=False, + streaming_firmware="2025.2.6", + ), + TeslemetryBinarySensorEntityDescription( + key="speed_limit_mode", + streaming_listener=lambda x, y: x.listen_SpeedLimitMode(y), + entity_registry_enabled_default=False, + ), + TeslemetryBinarySensorEntityDescription( + key="remote_start_enabled", + streaming_listener=lambda x, y: x.listen_RemoteStartEnabled(y), + entity_registry_enabled_default=False, + ), + TeslemetryBinarySensorEntityDescription( + key="hvil", + streaming_listener=lambda x, y: x.listen_Hvil(lambda z: y(z == "Fault")), + device_class=BinarySensorDeviceClass.PROBLEM, + entity_registry_enabled_default=False, + entity_category=EntityCategory.DIAGNOSTIC, + ), + TeslemetryBinarySensorEntityDescription( + key="hvac_auto_mode", + streaming_listener=lambda x, y: x.listen_HvacAutoMode(lambda z: y(z == "On")), + entity_registry_enabled_default=False, + ), ) diff --git a/homeassistant/components/teslemetry/icons.json b/homeassistant/components/teslemetry/icons.json index 9996a508177..e03ac8eb41a 100644 --- a/homeassistant/components/teslemetry/icons.json +++ b/homeassistant/components/teslemetry/icons.json @@ -42,6 +42,48 @@ "off": "mdi:tire", "on": "mdi:car-tire-alert" } + }, + "charge_enable_request": { + "state": { + "off": "mdi:battery-off-outline", + "on": "mdi:battery-charging-outline" + } + }, + "defrost_for_preconditioning": { + "state": { + "off": "mdi:snowflake-off", + "on": "mdi:snowflake-melt" + } + }, + "lights_high_beams": { + "state": { + "off": "mdi:car-light-dimmed", + "on": "mdi:car-light-high" + } + }, + "seat_vent_enabled": { + "state": { + "off": "mdi:car-seat", + "on": "mdi:fan" + } + }, + "speed_limit_mode": { + "state": { + "off": "mdi:speedometer", + "on": "mdi:car-speed-limiter" + } + }, + "remote_start_enabled": { + "state": { + "off": "mdi:remote-off", + "on": "mdi:remote" + } + }, + "hvac_auto_mode": { + "state": { + "off": "mdi:hvac-off", + "on": "mdi:hvac" + } } }, "button": { diff --git a/homeassistant/components/teslemetry/strings.json b/homeassistant/components/teslemetry/strings.json index 99a4b538639..0115ed0eac8 100644 --- a/homeassistant/components/teslemetry/strings.json +++ b/homeassistant/components/teslemetry/strings.json @@ -190,6 +190,30 @@ }, "located_at_favorite": { "name": "Located at favorite" + }, + "charge_enable_request": { + "name": "Charge enable request" + }, + "defrost_for_preconditioning": { + "name": "Defrost for preconditioning" + }, + "lights_high_beams": { + "name": "High beams" + }, + "seat_vent_enabled": { + "name": "Seat vent enabled" + }, + "speed_limit_mode": { + "name": "Speed limited" + }, + "remote_start_enabled": { + "name": "Remote start" + }, + "hvil": { + "name": "High voltage interlock loop fault" + }, + "hvac_auto_mode": { + "name": "HVAC auto mode" } }, "button": { diff --git a/tests/components/teslemetry/snapshots/test_binary_sensor.ambr b/tests/components/teslemetry/snapshots/test_binary_sensor.ambr index 9521b313a2d..1558004b1e9 100644 --- a/tests/components/teslemetry/snapshots/test_binary_sensor.ambr +++ b/tests/components/teslemetry/snapshots/test_binary_sensor.ambr @@ -566,6 +566,53 @@ 'state': 'on', }) # --- +# name: test_binary_sensor[binary_sensor.test_charge_enable_request-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_charge_enable_request', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Charge enable request', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'charge_enable_request', + 'unique_id': 'LRW3F7EK4NC700000-charge_enable_request', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_charge_enable_request-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Charge enable request', + }), + 'context': , + 'entity_id': 'binary_sensor.test_charge_enable_request', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor[binary_sensor.test_charge_port_cold_weather_mode-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -755,6 +802,53 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor[binary_sensor.test_defrost_for_preconditioning-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_defrost_for_preconditioning', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Defrost for preconditioning', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'defrost_for_preconditioning', + 'unique_id': 'LRW3F7EK4NC700000-defrost_for_preconditioning', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_defrost_for_preconditioning-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Defrost for preconditioning', + }), + 'context': , + 'entity_id': 'binary_sensor.test_defrost_for_preconditioning', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor[binary_sensor.test_drive_rail-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -1324,6 +1418,101 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor[binary_sensor.test_high_beams-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_high_beams', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'High beams', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'lights_high_beams', + 'unique_id': 'LRW3F7EK4NC700000-lights_high_beams', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_high_beams-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test High beams', + }), + 'context': , + 'entity_id': 'binary_sensor.test_high_beams', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_binary_sensor[binary_sensor.test_high_voltage_interlock_loop_fault-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_high_voltage_interlock_loop_fault', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'High voltage interlock loop fault', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'hvil', + 'unique_id': 'LRW3F7EK4NC700000-hvil', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_high_voltage_interlock_loop_fault-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test High voltage interlock loop fault', + }), + 'context': , + 'entity_id': 'binary_sensor.test_high_voltage_interlock_loop_fault', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor[binary_sensor.test_homelink_nearby-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -1371,6 +1560,53 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor[binary_sensor.test_hvac_auto_mode-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_hvac_auto_mode', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'HVAC auto mode', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'hvac_auto_mode', + 'unique_id': 'LRW3F7EK4NC700000-hvac_auto_mode', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_hvac_auto_mode-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test HVAC auto mode', + }), + 'context': , + 'entity_id': 'binary_sensor.test_hvac_auto_mode', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor[binary_sensor.test_located_at_favorite-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -1986,6 +2222,53 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor[binary_sensor.test_remote_start-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_remote_start', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Remote start', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'remote_start_enabled', + 'unique_id': 'LRW3F7EK4NC700000-remote_start_enabled', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_remote_start-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Remote start', + }), + 'context': , + 'entity_id': 'binary_sensor.test_remote_start', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor[binary_sensor.test_right_hand_drive-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -2080,6 +2363,53 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor[binary_sensor.test_seat_vent_enabled-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_seat_vent_enabled', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Seat vent enabled', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'seat_vent_enabled', + 'unique_id': 'LRW3F7EK4NC700000-seat_vent_enabled', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_seat_vent_enabled-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Seat vent enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.test_seat_vent_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor[binary_sensor.test_service_mode-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -2127,6 +2457,53 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor[binary_sensor.test_speed_limited-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_speed_limited', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Speed limited', + 'platform': 'teslemetry', + 'previous_unique_id': None, + 'supported_features': 0, + 'translation_key': 'speed_limit_mode', + 'unique_id': 'LRW3F7EK4NC700000-speed_limit_mode', + 'unit_of_measurement': None, + }) +# --- +# name: test_binary_sensor[binary_sensor.test_speed_limited-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Speed limited', + }), + 'context': , + 'entity_id': 'binary_sensor.test_speed_limited', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor[binary_sensor.test_status-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ @@ -2715,6 +3092,19 @@ 'state': 'on', }) # --- +# name: test_binary_sensor_refresh[binary_sensor.test_charge_enable_request-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Charge enable request', + }), + 'context': , + 'entity_id': 'binary_sensor.test_charge_enable_request', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor_refresh[binary_sensor.test_charge_port_cold_weather_mode-statealt] StateSnapshot({ 'attributes': ReadOnlyDict({ @@ -2768,6 +3158,19 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor_refresh[binary_sensor.test_defrost_for_preconditioning-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Defrost for preconditioning', + }), + 'context': , + 'entity_id': 'binary_sensor.test_defrost_for_preconditioning', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor_refresh[binary_sensor.test_drive_rail-statealt] StateSnapshot({ 'attributes': ReadOnlyDict({ @@ -2929,6 +3332,33 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor_refresh[binary_sensor.test_high_beams-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test High beams', + }), + 'context': , + 'entity_id': 'binary_sensor.test_high_beams', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- +# name: test_binary_sensor_refresh[binary_sensor.test_high_voltage_interlock_loop_fault-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test High voltage interlock loop fault', + }), + 'context': , + 'entity_id': 'binary_sensor.test_high_voltage_interlock_loop_fault', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor_refresh[binary_sensor.test_homelink_nearby-statealt] StateSnapshot({ 'attributes': ReadOnlyDict({ @@ -2942,6 +3372,19 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor_refresh[binary_sensor.test_hvac_auto_mode-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test HVAC auto mode', + }), + 'context': , + 'entity_id': 'binary_sensor.test_hvac_auto_mode', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor_refresh[binary_sensor.test_located_at_favorite-statealt] StateSnapshot({ 'attributes': ReadOnlyDict({ @@ -3115,6 +3558,19 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor_refresh[binary_sensor.test_remote_start-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Remote start', + }), + 'context': , + 'entity_id': 'binary_sensor.test_remote_start', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor_refresh[binary_sensor.test_right_hand_drive-statealt] StateSnapshot({ 'attributes': ReadOnlyDict({ @@ -3141,6 +3597,19 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor_refresh[binary_sensor.test_seat_vent_enabled-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Seat vent enabled', + }), + 'context': , + 'entity_id': 'binary_sensor.test_seat_vent_enabled', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor_refresh[binary_sensor.test_service_mode-statealt] StateSnapshot({ 'attributes': ReadOnlyDict({ @@ -3154,6 +3623,19 @@ 'state': 'unknown', }) # --- +# name: test_binary_sensor_refresh[binary_sensor.test_speed_limited-statealt] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Speed limited', + }), + 'context': , + 'entity_id': 'binary_sensor.test_speed_limited', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'unknown', + }) +# --- # name: test_binary_sensor_refresh[binary_sensor.test_status-statealt] StateSnapshot({ 'attributes': ReadOnlyDict({