init home-assistant

This commit is contained in:
2026-11-19 15:15:32 -05:00
parent 2e81d9d300
commit feec6ef9fb
19230 changed files with 3335526 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
"""Tests for the Teslemetry integration."""
from unittest.mock import patch
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.teslemetry.const import DOMAIN
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from .const import CONFIG
from tests.common import MockConfigEntry
async def setup_platform(hass: HomeAssistant, platforms: list[Platform] | None = None):
"""Set up the Teslemetry platform."""
mock_entry = MockConfigEntry(
domain=DOMAIN, data=CONFIG, minor_version=2, unique_id="abc-123"
)
mock_entry.add_to_hass(hass)
if platforms is None:
await hass.config_entries.async_setup(mock_entry.entry_id)
else:
with patch("homeassistant.components.teslemetry.PLATFORMS", platforms):
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
return mock_entry
def assert_entities(
hass: HomeAssistant,
entry_id: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test that all entities match their snapshot."""
entity_entries = er.async_entries_for_config_entry(entity_registry, entry_id)
assert entity_entries
for entity_entry in entity_entries:
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
assert (state := hass.states.get(entity_entry.entity_id))
assert state == snapshot(name=f"{entity_entry.entity_id}-state")
def assert_entities_alt(
hass: HomeAssistant,
entry_id: str,
entity_registry: er.EntityRegistry,
snapshot: SnapshotAssertion,
) -> None:
"""Test that all entities match their alt snapshot."""
entity_entries = er.async_entries_for_config_entry(entity_registry, entry_id)
assert entity_entries
for entity_entry in entity_entries:
assert (state := hass.states.get(entity_entry.entity_id))
assert state == snapshot(name=f"{entity_entry.entity_id}-statealt")

View File

@@ -0,0 +1,117 @@
"""Fixtures for Teslemetry."""
from __future__ import annotations
from collections.abc import Generator
from copy import deepcopy
from unittest.mock import AsyncMock, patch
import pytest
from .const import (
COMMAND_OK,
ENERGY_HISTORY,
LIVE_STATUS,
METADATA,
PRODUCTS,
SITE_INFO,
VEHICLE_DATA,
WAKE_UP_ONLINE,
)
@pytest.fixture(autouse=True)
def mock_metadata():
"""Mock Tesla Fleet Api metadata method."""
with patch(
"homeassistant.components.teslemetry.Teslemetry.metadata", return_value=METADATA
) as mock_products:
yield mock_products
@pytest.fixture(autouse=True)
def mock_products():
"""Mock Tesla Fleet Api products method."""
with patch(
"homeassistant.components.teslemetry.Teslemetry.products", return_value=PRODUCTS
) as mock_products:
yield mock_products
@pytest.fixture(autouse=True)
def mock_vehicle_data() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle_data method."""
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.vehicle_data",
return_value=VEHICLE_DATA,
) as mock_vehicle_data:
yield mock_vehicle_data
@pytest.fixture(autouse=True)
def mock_wake_up():
"""Mock Tesla Fleet API Vehicle Specific wake_up method."""
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.wake_up",
return_value=WAKE_UP_ONLINE,
) as mock_wake_up:
yield mock_wake_up
@pytest.fixture(autouse=True)
def mock_vehicle() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle method."""
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.vehicle",
return_value=WAKE_UP_ONLINE,
) as mock_vehicle:
yield mock_vehicle
@pytest.fixture(autouse=True)
def mock_request():
"""Mock Tesla Fleet API Vehicle Specific class."""
with patch(
"homeassistant.components.teslemetry.Teslemetry._request",
return_value=COMMAND_OK,
) as mock_request:
yield mock_request
@pytest.fixture(autouse=True)
def mock_live_status():
"""Mock Teslemetry Energy Specific live_status method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.live_status",
side_effect=lambda: deepcopy(LIVE_STATUS),
) as mock_live_status:
yield mock_live_status
@pytest.fixture(autouse=True)
def mock_site_info():
"""Mock Teslemetry Energy Specific site_info method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.site_info",
side_effect=lambda: deepcopy(SITE_INFO),
) as mock_live_status:
yield mock_live_status
@pytest.fixture(autouse=True)
def mock_energy_history():
"""Mock Teslemetry Energy Specific site_info method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.energy_history",
return_value=ENERGY_HISTORY,
) as mock_live_status:
yield mock_live_status
@pytest.fixture(autouse=True)
def mock_listen():
"""Mock Teslemetry Stream listen method."""
with patch(
"homeassistant.components.teslemetry.TeslemetryStream.listen",
) as mock_listen:
yield mock_listen

View File

@@ -0,0 +1,70 @@
"""Constants for the teslemetry tests."""
from homeassistant.components.teslemetry.const import DOMAIN, TeslemetryState
from homeassistant.const import CONF_ACCESS_TOKEN
from tests.common import load_json_object_fixture
CONFIG = {CONF_ACCESS_TOKEN: "1234567890"}
WAKE_UP_ONLINE = {"response": {"state": TeslemetryState.ONLINE}, "error": None}
WAKE_UP_ASLEEP = {"response": {"state": TeslemetryState.ASLEEP}, "error": None}
PRODUCTS = load_json_object_fixture("products.json", DOMAIN)
VEHICLE_DATA = load_json_object_fixture("vehicle_data.json", DOMAIN)
VEHICLE_DATA_ASLEEP = load_json_object_fixture("vehicle_data.json", DOMAIN)
VEHICLE_DATA_ASLEEP["response"]["state"] = TeslemetryState.OFFLINE
VEHICLE_DATA_ALT = load_json_object_fixture("vehicle_data_alt.json", DOMAIN)
LIVE_STATUS = load_json_object_fixture("live_status.json", DOMAIN)
SITE_INFO = load_json_object_fixture("site_info.json", DOMAIN)
ENERGY_HISTORY = load_json_object_fixture("energy_history.json", DOMAIN)
COMMAND_OK = {"response": {"result": True, "reason": ""}}
COMMAND_REASON = {"response": {"result": False, "reason": "already closed"}}
COMMAND_IGNORED_REASON = {"response": {"result": False, "reason": "already_set"}}
COMMAND_NOREASON = {"response": {"result": False}} # Unexpected
COMMAND_ERROR = {
"response": None,
"error": "vehicle unavailable: vehicle is offline or asleep",
"error_description": "",
}
COMMAND_NOERROR = {"answer": 42}
COMMAND_ERRORS = (COMMAND_REASON, COMMAND_NOREASON, COMMAND_ERROR, COMMAND_NOERROR)
RESPONSE_OK = {"response": {}, "error": None}
METADATA = {
"uid": "abc-123",
"region": "NA",
"scopes": [
"openid",
"offline_access",
"user_data",
"vehicle_device_data",
"vehicle_cmds",
"vehicle_charging_cmds",
"energy_device_data",
"energy_cmds",
],
"vehicles": {
"LRW3F7EK4NC700000": {
"proxy": False,
"access": True,
"polling": True,
"firmware": "2024.44.25",
}
},
}
METADATA_NOSCOPE = {
"uid": "abc-123",
"region": "NA",
"scopes": ["openid", "offline_access", "vehicle_device_data"],
"vehicles": {
"LRW3F7EK4NC700000": {
"proxy": False,
"access": True,
"polling": True,
"firmware": "2024.44.25",
}
},
}

View File

@@ -0,0 +1,55 @@
{
"response": {
"serial_number": "xxxxxx",
"period": "day",
"installation_time_zone": "Australia/Brisbane",
"time_series": [
{
"timestamp": "2024-09-18T00:00:00+10:00",
"solar_energy_exported": 0,
"generator_energy_exported": 0,
"grid_energy_imported": 0,
"grid_services_energy_imported": 0,
"grid_services_energy_exported": 0,
"grid_energy_exported_from_solar": 0,
"grid_energy_exported_from_generator": 0,
"grid_energy_exported_from_battery": 0,
"battery_energy_exported": 36,
"battery_energy_imported_from_grid": 0,
"battery_energy_imported_from_solar": 0,
"battery_energy_imported_from_generator": 0,
"consumer_energy_imported_from_grid": 0,
"consumer_energy_imported_from_solar": 0,
"consumer_energy_imported_from_battery": 36,
"consumer_energy_imported_from_generator": 0,
"raw_timestamp": "2024-09-18T00:00:00+10:00",
"total_home_usage": 36,
"total_battery_discharge": 36
},
{
"timestamp": "2024-09-18T08:45:00+10:00",
"solar_energy_exported": 724,
"generator_energy_exported": 0,
"grid_energy_imported": 0,
"grid_services_energy_imported": 0,
"grid_services_energy_exported": 0,
"grid_energy_exported_from_solar": 2,
"grid_energy_exported_from_generator": 0,
"grid_energy_exported_from_battery": 0,
"battery_energy_exported": 0,
"battery_energy_imported_from_grid": 0,
"battery_energy_imported_from_solar": 684,
"battery_energy_imported_from_generator": 0,
"consumer_energy_imported_from_grid": 0,
"consumer_energy_imported_from_solar": 38,
"consumer_energy_imported_from_battery": 0,
"consumer_energy_imported_from_generator": 0,
"raw_timestamp": "2024-09-18T08:45:00+10:00",
"total_home_usage": 38,
"total_solar_generation": 724,
"total_battery_charge": 684,
"total_grid_energy_exported": 2
}
]
}
}

View File

@@ -0,0 +1,33 @@
{
"response": {
"solar_power": 1185,
"energy_left": 38896.47368421053,
"total_pack_energy": 40727,
"percentage_charged": 95.50537403739663,
"backup_capable": true,
"battery_power": 5060,
"load_power": 6245,
"grid_status": "Active",
"grid_services_active": false,
"grid_power": 0,
"grid_services_power": 0,
"generator_power": 0,
"island_status": "on_grid",
"storm_mode_active": false,
"timestamp": "2024-01-01T00:00:00+00:00",
"wall_connectors": [
{
"din": "abd-123",
"wall_connector_state": 2,
"wall_connector_fault_state": 2,
"wall_connector_power": 0
},
{
"din": "bcd-234",
"wall_connector_state": 2,
"wall_connector_fault_state": 2,
"wall_connector_power": 0
}
]
}
}

View File

@@ -0,0 +1,131 @@
{
"response": [
{
"id": 1234,
"user_id": 1234,
"vehicle_id": 1234,
"vin": "LRW3F7EK4NC700000",
"color": null,
"access_type": "OWNER",
"display_name": "Test",
"option_codes": null,
"cached_data": null,
"granular_access": { "hide_private": false },
"tokens": ["abc", "def"],
"state": "asleep",
"in_service": false,
"id_s": "1234",
"calendar_enabled": true,
"api_version": 71,
"backseat_token": null,
"backseat_token_updated_at": null,
"ble_autopair_enrolled": false,
"vehicle_config": {
"aux_park_lamps": "Eu",
"badge_version": 1,
"can_accept_navigation_requests": true,
"can_actuate_trunks": true,
"car_special_type": "base",
"car_type": "model3",
"charge_port_type": "CCS",
"cop_user_set_temp_supported": false,
"dashcam_clip_save_supported": true,
"default_charge_to_max": false,
"driver_assist": "TeslaAP3",
"ece_restrictions": false,
"efficiency_package": "M32021",
"eu_vehicle": true,
"exterior_color": "DeepBlue",
"exterior_trim": "Black",
"exterior_trim_override": "",
"has_air_suspension": false,
"has_ludicrous_mode": false,
"has_seat_cooling": false,
"headlamp_type": "Global",
"interior_trim_type": "White2",
"key_version": 2,
"motorized_charge_port": true,
"paint_color_override": "0,9,25,0.7,0.04",
"performance_package": "Base",
"plg": true,
"pws": true,
"rear_drive_unit": "PM216MOSFET",
"rear_seat_heaters": 1,
"rear_seat_type": 0,
"rhd": true,
"roof_color": "RoofColorGlass",
"seat_type": null,
"spoiler_type": "None",
"sun_roof_installed": null,
"supports_qr_pairing": false,
"third_row_seats": "None",
"timestamp": 1705701487912,
"trim_badging": "74d",
"use_range_badging": true,
"utc_offset": 36000,
"webcam_selfie_supported": true,
"webcam_supported": true,
"wheel_type": "Pinwheel18CapKit"
},
"command_signing": "allowed",
"release_notes_supported": true
},
{
"energy_site_id": 123456,
"resource_type": "battery",
"site_name": "Energy Site",
"id": "ABC123",
"gateway_id": "ABC123",
"asset_site_id": "c0ffee",
"warp_site_number": "GA123456",
"energy_left": 23286.105263157893,
"total_pack_energy": 40804,
"percentage_charged": 57.068192488868476,
"battery_type": "ac_powerwall",
"backup_capable": true,
"battery_power": 14990,
"go_off_grid_test_banner_enabled": null,
"storm_mode_enabled": true,
"powerwall_onboarding_settings_set": true,
"powerwall_tesla_electric_interested_in": null,
"vpp_tour_enabled": null,
"sync_grid_alert_enabled": true,
"breaker_alert_enabled": true,
"components": {
"battery": true,
"battery_type": "ac_powerwall",
"solar": true,
"solar_type": "pv_panel",
"grid": true,
"load_meter": true,
"market_type": "residential",
"wall_connectors": [
{
"device_id": "abc-123",
"din": "123-abc",
"is_active": true
},
{
"device_id": "bcd-234",
"din": "234-bcd",
"is_active": true
}
]
},
"features": {
"rate_plan_manager_no_pricing_constraint": true
}
},
{
"energy_site_id": 98765,
"components": {
"battery": false,
"solar": false,
"grid": false,
"load_meter": false,
"market_type": "residential"
}
}
],
"count": 3
}

View File

@@ -0,0 +1,127 @@
{
"response": {
"id": "1233-abcd",
"site_name": "Site",
"backup_reserve_percent": 0,
"default_real_mode": "self_consumption",
"installation_date": "2022-01-01T00:00:00+00:00",
"user_settings": {
"go_off_grid_test_banner_enabled": false,
"storm_mode_enabled": true,
"powerwall_onboarding_settings_set": true,
"powerwall_tesla_electric_interested_in": false,
"vpp_tour_enabled": true,
"sync_grid_alert_enabled": true,
"breaker_alert_enabled": false
},
"components": {
"solar": true,
"solar_type": "pv_panel",
"battery": true,
"grid": true,
"backup": true,
"gateway": "teg",
"load_meter": true,
"tou_capable": true,
"storm_mode_capable": true,
"flex_energy_request_capable": false,
"car_charging_data_supported": false,
"off_grid_vehicle_charging_reserve_supported": true,
"vehicle_charging_performance_view_enabled": false,
"vehicle_charging_solar_offset_view_enabled": false,
"battery_solar_offset_view_enabled": true,
"solar_value_enabled": true,
"energy_value_header": "Energy Value",
"energy_value_subheader": "Estimated Value",
"energy_service_self_scheduling_enabled": true,
"show_grid_import_battery_source_cards": true,
"set_islanding_mode_enabled": true,
"wifi_commissioning_enabled": true,
"backup_time_remaining_enabled": true,
"battery_type": "ac_powerwall",
"configurable": true,
"grid_services_enabled": false,
"gateways": [
{
"device_id": "gateway-id",
"din": "gateway-din",
"serial_number": "CN00000000J50D",
"part_number": "1152100-14-J",
"part_type": 10,
"part_name": "Tesla Backup Gateway 2",
"is_active": true,
"site_id": "1234-abcd",
"firmware_version": "24.4.0 0fe780c9",
"updated_datetime": "2024-05-14T00:00:00.000Z"
}
],
"batteries": [
{
"device_id": "battery-1-id",
"din": "battery-1-din",
"serial_number": "TG000000001DA5",
"part_number": "3012170-10-B",
"part_type": 2,
"part_name": "Powerwall 2",
"nameplate_max_charge_power": 5000,
"nameplate_max_discharge_power": 5000,
"nameplate_energy": 13500
},
{
"device_id": "battery-2-id",
"din": "battery-2-din",
"serial_number": "TG000000002DA5",
"part_number": "3012170-05-C",
"part_type": 2,
"part_name": "Powerwall 2",
"nameplate_max_charge_power": 5000,
"nameplate_max_discharge_power": 5000,
"nameplate_energy": 13500
}
],
"wall_connectors": [
{
"device_id": "123abc",
"din": "abd-123",
"part_name": "Gen 3 Wall Connector",
"is_active": true
},
{
"device_id": "234bcd",
"din": "bcd-234",
"part_name": "Gen 3 Wall Connector",
"is_active": true
}
],
"disallow_charge_from_grid_with_solar_installed": true,
"customer_preferred_export_rule": "pv_only",
"net_meter_mode": "battery_ok",
"system_alerts_enabled": true
},
"version": "23.44.0 eb113390",
"battery_count": 2,
"tou_settings": {
"optimization_strategy": "economics",
"schedule": [
{
"target": "off_peak",
"week_days": [1, 0],
"start_seconds": 0,
"end_seconds": 3600
},
{
"target": "peak",
"week_days": [1, 0],
"start_seconds": 3600,
"end_seconds": 0
}
]
},
"nameplate_power": 15000,
"nameplate_energy": 40500,
"installation_time_zone": "",
"max_site_meter_power_ac": 1000000000,
"min_site_meter_power_ac": -1000000000,
"vpp_backup_reserve_percent": 0
}
}

View File

@@ -0,0 +1,283 @@
{
"response": {
"id": 1234,
"user_id": 1234,
"vehicle_id": 1234,
"vin": "LRW3F7EK4NC700000",
"color": null,
"access_type": "OWNER",
"granular_access": {
"hide_private": false
},
"tokens": ["abc", "def"],
"state": "online",
"in_service": false,
"id_s": "1234",
"calendar_enabled": true,
"api_version": 71,
"backseat_token": null,
"backseat_token_updated_at": null,
"ble_autopair_enrolled": false,
"charge_state": {
"battery_heater_on": false,
"battery_level": 77,
"battery_range": 266.87,
"charge_amps": 16,
"charge_current_request": 16,
"charge_current_request_max": 16,
"charge_enable_request": true,
"charge_energy_added": 0,
"charge_limit_soc": 80,
"charge_limit_soc_max": 100,
"charge_limit_soc_min": 50,
"charge_limit_soc_std": 80,
"charge_miles_added_ideal": 0,
"charge_miles_added_rated": 0,
"charge_port_cold_weather_mode": false,
"charge_port_color": "<invalid>",
"charge_port_door_open": true,
"charge_port_latch": "Engaged",
"charge_rate": 0,
"charger_actual_current": 0,
"charger_phases": null,
"charger_pilot_current": 16,
"charger_power": 0,
"charger_voltage": 2,
"charging_state": "Stopped",
"conn_charge_cable": "IEC",
"est_battery_range": 275.04,
"fast_charger_brand": "<invalid>",
"fast_charger_present": false,
"fast_charger_type": "ACSingleWireCAN",
"ideal_battery_range": 266.87,
"max_range_charge_counter": 0,
"minutes_to_full_charge": 0,
"not_enough_power_to_heat": null,
"off_peak_charging_enabled": false,
"off_peak_charging_times": "all_week",
"off_peak_hours_end_time": 900,
"preconditioning_enabled": false,
"preconditioning_times": "all_week",
"scheduled_charging_mode": "Off",
"scheduled_charging_pending": false,
"scheduled_charging_start_time": null,
"scheduled_charging_start_time_app": 600,
"scheduled_departure_time": 1704837600,
"scheduled_departure_time_minutes": 480,
"supercharger_session_trip_planner": false,
"time_to_full_charge": 0,
"timestamp": 1705707520649,
"trip_charging": false,
"usable_battery_level": 77,
"user_charge_enable_request": null
},
"climate_state": {
"allow_cabin_overheat_protection": true,
"auto_seat_climate_left": true,
"auto_seat_climate_right": true,
"auto_steering_wheel_heat": false,
"battery_heater": false,
"battery_heater_no_power": null,
"cabin_overheat_protection": "On",
"cabin_overheat_protection_actively_cooling": false,
"climate_keeper_mode": "keep",
"cop_activation_temperature": "High",
"defrost_mode": 0,
"driver_temp_setting": 22,
"fan_status": 0,
"hvac_auto_request": "On",
"inside_temp": 29.8,
"is_auto_conditioning_on": false,
"is_climate_on": true,
"is_front_defroster_on": false,
"is_preconditioning": false,
"is_rear_defroster_on": false,
"left_temp_direction": 251,
"max_avail_temp": 28,
"min_avail_temp": 15,
"outside_temp": 30,
"passenger_temp_setting": 22,
"remote_heater_control_enabled": false,
"right_temp_direction": 251,
"seat_heater_left": 0,
"seat_heater_rear_center": 0,
"seat_heater_rear_left": 0,
"seat_heater_rear_right": 0,
"seat_heater_right": 0,
"side_mirror_heaters": false,
"steering_wheel_heat_level": 0,
"steering_wheel_heater": false,
"supports_fan_only_cabin_overheat_protection": true,
"timestamp": 1705707520649,
"wiper_blade_heater": false
},
"drive_state": {
"active_route_destination": "Home",
"active_route_latitude": 30.2226265,
"active_route_longitude": -97.6236871,
"active_route_miles_to_arrival": 0.039491,
"active_route_minutes_to_arrival": 0.103577,
"active_route_traffic_minutes_delay": 0,
"gps_as_of": 1701129612,
"heading": 185,
"latitude": -30.222626,
"longitude": -97.6236871,
"native_latitude": -30.222626,
"native_location_supported": 1,
"native_longitude": -97.6236871,
"native_type": "wgs",
"power": -7,
"shift_state": null,
"speed": null,
"timestamp": 1705707520649
},
"gui_settings": {
"gui_24_hour_time": false,
"gui_charge_rate_units": "kW",
"gui_distance_units": "km/hr",
"gui_range_display": "Rated",
"gui_temperature_units": "C",
"gui_tirepressure_units": "Psi",
"show_range_units": false,
"timestamp": 1705707520649
},
"vehicle_config": {
"aux_park_lamps": "Eu",
"badge_version": 1,
"can_accept_navigation_requests": true,
"can_actuate_trunks": true,
"car_special_type": "base",
"car_type": "model3",
"charge_port_type": "CCS",
"cop_user_set_temp_supported": true,
"dashcam_clip_save_supported": true,
"default_charge_to_max": false,
"driver_assist": "TeslaAP3",
"ece_restrictions": false,
"efficiency_package": "M32021",
"eu_vehicle": true,
"exterior_color": "DeepBlue",
"exterior_trim": "Black",
"exterior_trim_override": "",
"has_air_suspension": false,
"has_ludicrous_mode": false,
"has_seat_cooling": false,
"headlamp_type": "Global",
"interior_trim_type": "White2",
"key_version": 2,
"motorized_charge_port": true,
"paint_color_override": "0,9,25,0.7,0.04",
"performance_package": "Base",
"plg": true,
"pws": true,
"rear_drive_unit": "PM216MOSFET",
"rear_seat_heaters": 1,
"rear_seat_type": 0,
"rhd": true,
"roof_color": "RoofColorGlass",
"seat_type": null,
"spoiler_type": "None",
"sun_roof_installed": true,
"supports_qr_pairing": false,
"third_row_seats": "None",
"timestamp": 1705707520649,
"trim_badging": "74d",
"use_range_badging": true,
"utc_offset": 36000,
"webcam_selfie_supported": true,
"webcam_supported": true,
"wheel_type": "Pinwheel18CapKit"
},
"vehicle_state": {
"api_version": 71,
"autopark_state_v2": "unavailable",
"calendar_supported": true,
"car_version": "2023.44.30.8 06f534d46010",
"center_display_state": 0,
"dashcam_clip_save_available": true,
"dashcam_state": "Recording",
"df": 0,
"dr": 0,
"fd_window": 0,
"feature_bitmask": "fbdffbff,187f",
"fp_window": 0,
"ft": 0,
"is_user_present": false,
"locked": false,
"media_info": {
"a2dp_source_name": "Pixel 8 Pro",
"audio_volume": 1.6667,
"audio_volume_increment": 0.333333,
"audio_volume_max": 10.333333,
"media_playback_status": "Playing",
"now_playing_album": "Elon Musk",
"now_playing_artist": "Walter Isaacson",
"now_playing_duration": 651000,
"now_playing_elapsed": 1000,
"now_playing_source": "Audible",
"now_playing_station": "Elon Musk",
"now_playing_title": "Chapter 51: Cybertruck: Tesla, 2018–2019"
},
"media_state": {
"remote_control_enabled": true
},
"notifications_supported": true,
"odometer": 6481.019282,
"parsed_calendar_supported": true,
"pf": 0,
"pr": 0,
"rd_window": 0,
"remote_start": false,
"remote_start_enabled": true,
"remote_start_supported": true,
"rp_window": 0,
"rt": 0,
"santa_mode": 0,
"sentry_mode": false,
"sentry_mode_available": true,
"service_mode": false,
"service_mode_plus": false,
"software_update": {
"download_perc": 100,
"expected_duration_sec": 2700,
"install_perc": 1,
"status": "available",
"version": "2024.12.0.0"
},
"speed_limit_mode": {
"active": false,
"current_limit_mph": 69,
"max_limit_mph": 120,
"min_limit_mph": 50,
"pin_code_set": true
},
"sun_roof_state": "open",
"vehicle_state_sun_roof_percent_open": 20,
"timestamp": 1705707520649,
"tpms_hard_warning_fl": false,
"tpms_hard_warning_fr": false,
"tpms_hard_warning_rl": false,
"tpms_hard_warning_rr": false,
"tpms_last_seen_pressure_time_fl": 1705700812,
"tpms_last_seen_pressure_time_fr": 1705700793,
"tpms_last_seen_pressure_time_rl": 1705700794,
"tpms_last_seen_pressure_time_rr": 1705700823,
"tpms_pressure_fl": 2.775,
"tpms_pressure_fr": 2.8,
"tpms_pressure_rl": 2.775,
"tpms_pressure_rr": 2.775,
"tpms_rcp_front_value": 2.9,
"tpms_rcp_rear_value": 2.9,
"tpms_soft_warning_fl": false,
"tpms_soft_warning_fr": false,
"tpms_soft_warning_rl": false,
"tpms_soft_warning_rr": false,
"valet_mode": false,
"valet_pin_needed": false,
"vehicle_name": "Test",
"vehicle_self_test_progress": 0,
"vehicle_self_test_requested": false,
"webcam_available": true
}
}
}

View File

@@ -0,0 +1,278 @@
{
"response": {
"id": 1234,
"user_id": 1234,
"vehicle_id": 1234,
"vin": "LRW3F7EK4NC700000",
"color": null,
"access_type": "OWNER",
"granular_access": {
"hide_private": false
},
"tokens": ["abc", "def"],
"state": "online",
"in_service": false,
"id_s": "1234",
"calendar_enabled": true,
"api_version": 71,
"backseat_token": null,
"backseat_token_updated_at": null,
"ble_autopair_enrolled": false,
"charge_state": {
"battery_heater_on": true,
"battery_level": 77,
"battery_range": 266.87,
"charge_amps": 16,
"charge_current_request": 16,
"charge_enable_request": true,
"charge_energy_added": 0,
"charge_limit_soc": 80,
"charge_limit_soc_max": 100,
"charge_limit_soc_min": 50,
"charge_limit_soc_std": 80,
"charge_miles_added_ideal": 0,
"charge_miles_added_rated": 0,
"charge_port_cold_weather_mode": false,
"charge_port_color": "<invalid>",
"charge_port_door_open": true,
"charge_port_latch": "Engaged",
"charge_rate": 0,
"charger_actual_current": 0,
"charger_phases": null,
"charger_pilot_current": 16,
"charger_power": 0,
"charger_voltage": 2,
"charging_state": "Stopped",
"conn_charge_cable": "IEC",
"est_battery_range": 275.04,
"fast_charger_brand": "<invalid>",
"fast_charger_present": false,
"fast_charger_type": "ACSingleWireCAN",
"ideal_battery_range": 266.87,
"max_range_charge_counter": 0,
"minutes_to_full_charge": "bad value",
"not_enough_power_to_heat": null,
"off_peak_charging_enabled": false,
"off_peak_charging_times": "all_week",
"off_peak_hours_end_time": 900,
"preconditioning_enabled": false,
"preconditioning_times": "all_week",
"scheduled_charging_mode": "Off",
"scheduled_charging_pending": false,
"scheduled_charging_start_time": null,
"scheduled_charging_start_time_app": 600,
"scheduled_departure_time": 1704837600,
"scheduled_departure_time_minutes": 480,
"supercharger_session_trip_planner": false,
"time_to_full_charge": null,
"timestamp": null,
"trip_charging": false,
"usable_battery_level": 77,
"user_charge_enable_request": true
},
"climate_state": {
"allow_cabin_overheat_protection": null,
"auto_seat_climate_left": false,
"auto_seat_climate_right": false,
"auto_steering_wheel_heat": false,
"battery_heater": true,
"battery_heater_no_power": null,
"cabin_overheat_protection": null,
"cabin_overheat_protection_actively_cooling": false,
"climate_keeper_mode": "off",
"cop_activation_temperature": null,
"defrost_mode": 0,
"driver_temp_setting": 22,
"fan_status": 0,
"hvac_auto_request": "On",
"inside_temp": 29.8,
"is_auto_conditioning_on": false,
"is_climate_on": false,
"is_front_defroster_on": false,
"is_preconditioning": false,
"is_rear_defroster_on": false,
"left_temp_direction": 251,
"max_avail_temp": 28,
"min_avail_temp": 15,
"outside_temp": 30,
"passenger_temp_setting": 22,
"remote_heater_control_enabled": false,
"right_temp_direction": 251,
"seat_heater_left": 0,
"seat_heater_rear_center": 0,
"seat_heater_rear_left": 0,
"seat_heater_rear_right": 0,
"seat_heater_right": 0,
"side_mirror_heaters": false,
"steering_wheel_heat_level": 0,
"steering_wheel_heater": true,
"supports_fan_only_cabin_overheat_protection": true,
"timestamp": 1705707520649,
"wiper_blade_heater": false
},
"drive_state": {
"active_route_latitude": 30.2226265,
"active_route_longitude": -97.6236871,
"active_route_miles_to_arrival": 0,
"active_route_minutes_to_arrival": 0,
"active_route_traffic_minutes_delay": 0,
"gps_as_of": 1701129612,
"heading": 185,
"latitude": -30.222626,
"longitude": -97.6236871,
"native_latitude": -30.222626,
"native_location_supported": 1,
"native_longitude": -97.6236871,
"native_type": "wgs",
"power": -7,
"shift_state": null,
"speed": null,
"timestamp": 1705707520649
},
"gui_settings": {
"gui_24_hour_time": false,
"gui_charge_rate_units": "kW",
"gui_distance_units": "km/hr",
"gui_range_display": "Rated",
"gui_temperature_units": "C",
"gui_tirepressure_units": "Psi",
"show_range_units": false,
"timestamp": 1705707520649
},
"vehicle_config": {
"aux_park_lamps": "Eu",
"badge_version": 1,
"can_accept_navigation_requests": true,
"can_actuate_trunks": true,
"car_special_type": "base",
"car_type": "model3",
"charge_port_type": "CCS",
"cop_user_set_temp_supported": false,
"dashcam_clip_save_supported": true,
"default_charge_to_max": false,
"driver_assist": "TeslaAP3",
"ece_restrictions": false,
"efficiency_package": "M32021",
"eu_vehicle": true,
"exterior_color": "DeepBlue",
"exterior_trim": "Black",
"exterior_trim_override": "",
"has_air_suspension": false,
"has_ludicrous_mode": false,
"has_seat_cooling": false,
"headlamp_type": "Global",
"interior_trim_type": "White2",
"key_version": 2,
"motorized_charge_port": true,
"paint_color_override": "0,9,25,0.7,0.04",
"performance_package": "Base",
"plg": true,
"pws": true,
"rear_drive_unit": "PM216MOSFET",
"rear_seat_heaters": 1,
"rear_seat_type": 0,
"rhd": true,
"roof_color": "RoofColorGlass",
"seat_type": null,
"spoiler_type": "None",
"sun_roof_installed": null,
"supports_qr_pairing": false,
"third_row_seats": "None",
"timestamp": 1705707520649,
"trim_badging": "74d",
"use_range_badging": true,
"utc_offset": 36000,
"webcam_selfie_supported": true,
"webcam_supported": true,
"wheel_type": "Pinwheel18CapKit"
},
"vehicle_state": {
"api_version": 71,
"autopark_state_v2": "unavailable",
"calendar_supported": true,
"car_version": "2023.44.30.8 06f534d46010",
"center_display_state": 0,
"dashcam_clip_save_available": true,
"dashcam_state": "Recording",
"df": 0,
"dr": 0,
"fd_window": 1,
"feature_bitmask": "fbdffbff,187f",
"fp_window": 1,
"ft": 1,
"is_user_present": true,
"locked": false,
"media_info": {
"audio_volume": null,
"audio_volume_increment": null,
"audio_volume_max": null,
"media_playback_status": "Stopped",
"now_playing_album": "",
"now_playing_artist": "",
"now_playing_duration": 0,
"now_playing_elapsed": 0,
"now_playing_source": "Spotify",
"now_playing_station": "",
"now_playing_title": ""
},
"media_state": {
"remote_control_enabled": true
},
"notifications_supported": true,
"odometer": 6481.019282,
"parsed_calendar_supported": true,
"pf": 0,
"pr": 0,
"rd_window": 1,
"remote_start": false,
"remote_start_enabled": true,
"remote_start_supported": true,
"rp_window": 1,
"rt": 1,
"santa_mode": 0,
"sentry_mode": false,
"sentry_mode_available": true,
"service_mode": false,
"service_mode_plus": false,
"software_update": {
"download_perc": 0,
"expected_duration_sec": 2700,
"install_perc": 1,
"status": "",
"version": " "
},
"speed_limit_mode": {
"active": false,
"current_limit_mph": 69,
"max_limit_mph": 120,
"min_limit_mph": 50,
"pin_code_set": true
},
"timestamp": 1705707520649,
"tpms_hard_warning_fl": false,
"tpms_hard_warning_fr": false,
"tpms_hard_warning_rl": false,
"tpms_hard_warning_rr": false,
"tpms_last_seen_pressure_time_fl": 1705700812,
"tpms_last_seen_pressure_time_fr": 1705700793,
"tpms_last_seen_pressure_time_rl": 1705700794,
"tpms_last_seen_pressure_time_rr": 1705700823,
"tpms_pressure_fl": 2.775,
"tpms_pressure_fr": 2.8,
"tpms_pressure_rl": 2.775,
"tpms_pressure_rr": 2.775,
"tpms_rcp_front_value": 2.9,
"tpms_rcp_rear_value": 2.9,
"tpms_soft_warning_fl": false,
"tpms_soft_warning_fr": false,
"tpms_soft_warning_rl": false,
"tpms_soft_warning_rr": false,
"valet_mode": false,
"valet_pin_needed": false,
"vehicle_name": "Test",
"vehicle_self_test_progress": 0,
"vehicle_self_test_requested": false,
"webcam_available": true
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,277 @@
# serializer version: 1
# name: test_button[button.test_flash_lights-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': None,
'entity_id': 'button.test_flash_lights',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Flash lights',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'flash_lights',
'unique_id': 'LRW3F7EK4NC700000-flash_lights',
'unit_of_measurement': None,
})
# ---
# name: test_button[button.test_flash_lights-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Flash lights',
}),
'context': <ANY>,
'entity_id': 'button.test_flash_lights',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_button[button.test_homelink-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': None,
'entity_id': 'button.test_homelink',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Homelink',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'homelink',
'unique_id': 'LRW3F7EK4NC700000-homelink',
'unit_of_measurement': None,
})
# ---
# name: test_button[button.test_homelink-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Homelink',
}),
'context': <ANY>,
'entity_id': 'button.test_homelink',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_button[button.test_honk_horn-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': None,
'entity_id': 'button.test_honk_horn',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Honk horn',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'honk',
'unique_id': 'LRW3F7EK4NC700000-honk',
'unit_of_measurement': None,
})
# ---
# name: test_button[button.test_honk_horn-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Honk horn',
}),
'context': <ANY>,
'entity_id': 'button.test_honk_horn',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_button[button.test_keyless_driving-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': None,
'entity_id': 'button.test_keyless_driving',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Keyless driving',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'enable_keyless_driving',
'unique_id': 'LRW3F7EK4NC700000-enable_keyless_driving',
'unit_of_measurement': None,
})
# ---
# name: test_button[button.test_keyless_driving-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Keyless driving',
}),
'context': <ANY>,
'entity_id': 'button.test_keyless_driving',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_button[button.test_play_fart-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': None,
'entity_id': 'button.test_play_fart',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Play fart',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'boombox',
'unique_id': 'LRW3F7EK4NC700000-boombox',
'unit_of_measurement': None,
})
# ---
# name: test_button[button.test_play_fart-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Play fart',
}),
'context': <ANY>,
'entity_id': 'button.test_play_fart',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_button[button.test_wake-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'button',
'entity_category': None,
'entity_id': 'button.test_wake',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Wake',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'wake',
'unique_id': 'LRW3F7EK4NC700000-wake',
'unit_of_measurement': None,
})
# ---
# name: test_button[button.test_wake-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Wake',
}),
'context': <ANY>,
'entity_id': 'button.test_wake',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---

View File

@@ -0,0 +1,370 @@
# serializer version: 1
# name: test_asleep_or_offline[HomeAssistantError]
'Timed out trying to wake up vehicle'
# ---
# name: test_asleep_or_offline[InvalidCommand]
'Failed to wake up vehicle: The data request or command is unknown.'
# ---
# name: test_climate[climate.test_cabin_overheat_protection-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.COOL: 'cool'>,
<HVACMode.FAN_ONLY: 'fan_only'>,
]),
'max_temp': 40,
'min_temp': 30,
'target_temp_step': 5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.test_cabin_overheat_protection',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Cabin overheat protection',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 385>,
'translation_key': 'climate_state_cabin_overheat_protection',
'unique_id': 'LRW3F7EK4NC700000-climate_state_cabin_overheat_protection',
'unit_of_measurement': None,
})
# ---
# name: test_climate[climate.test_cabin_overheat_protection-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 30,
'friendly_name': 'Test Cabin overheat protection',
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.COOL: 'cool'>,
<HVACMode.FAN_ONLY: 'fan_only'>,
]),
'max_temp': 40,
'min_temp': 30,
'supported_features': <ClimateEntityFeature: 385>,
'target_temp_step': 5,
'temperature': 40,
}),
'context': <ANY>,
'entity_id': 'climate.test_cabin_overheat_protection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'cool',
})
# ---
# name: test_climate[climate.test_climate-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.HEAT_COOL: 'heat_cool'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 28.0,
'min_temp': 15.0,
'preset_modes': list([
'off',
'keep',
'dog',
'camp',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.test_climate',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Climate',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 401>,
'translation_key': <TeslemetryClimateSide.DRIVER: 'driver_temp'>,
'unique_id': 'LRW3F7EK4NC700000-driver_temp',
'unit_of_measurement': None,
})
# ---
# name: test_climate[climate.test_climate-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 30.0,
'friendly_name': 'Test Climate',
'hvac_modes': list([
<HVACMode.HEAT_COOL: 'heat_cool'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 28.0,
'min_temp': 15.0,
'preset_mode': 'keep',
'preset_modes': list([
'off',
'keep',
'dog',
'camp',
]),
'supported_features': <ClimateEntityFeature: 401>,
'temperature': 22.0,
}),
'context': <ANY>,
'entity_id': 'climate.test_climate',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'heat_cool',
})
# ---
# name: test_climate_alt[climate.test_cabin_overheat_protection-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.COOL: 'cool'>,
<HVACMode.FAN_ONLY: 'fan_only'>,
]),
'max_temp': 40,
'min_temp': 30,
'target_temp_step': 5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.test_cabin_overheat_protection',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Cabin overheat protection',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 384>,
'translation_key': 'climate_state_cabin_overheat_protection',
'unique_id': 'LRW3F7EK4NC700000-climate_state_cabin_overheat_protection',
'unit_of_measurement': None,
})
# ---
# name: test_climate_alt[climate.test_cabin_overheat_protection-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 30,
'friendly_name': 'Test Cabin overheat protection',
'hvac_modes': list([
<HVACMode.OFF: 'off'>,
<HVACMode.COOL: 'cool'>,
<HVACMode.FAN_ONLY: 'fan_only'>,
]),
'max_temp': 40,
'min_temp': 30,
'supported_features': <ClimateEntityFeature: 384>,
'target_temp_step': 5,
}),
'context': <ANY>,
'entity_id': 'climate.test_cabin_overheat_protection',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_climate_alt[climate.test_climate-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.HEAT_COOL: 'heat_cool'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 28.0,
'min_temp': 15.0,
'preset_modes': list([
'off',
'keep',
'dog',
'camp',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.test_climate',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Climate',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <ClimateEntityFeature: 401>,
'translation_key': <TeslemetryClimateSide.DRIVER: 'driver_temp'>,
'unique_id': 'LRW3F7EK4NC700000-driver_temp',
'unit_of_measurement': None,
})
# ---
# name: test_climate_alt[climate.test_climate-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': 30.0,
'friendly_name': 'Test Climate',
'hvac_modes': list([
<HVACMode.HEAT_COOL: 'heat_cool'>,
<HVACMode.OFF: 'off'>,
]),
'max_temp': 28.0,
'min_temp': 15.0,
'preset_mode': 'off',
'preset_modes': list([
'off',
'keep',
'dog',
'camp',
]),
'supported_features': <ClimateEntityFeature: 401>,
'temperature': 22.0,
}),
'context': <ANY>,
'entity_id': 'climate.test_climate',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_climate_noscope[climate.test_cabin_overheat_protection-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.COOL: 'cool'>,
]),
'max_temp': 40,
'min_temp': 30,
'target_temp_step': 5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': <RegistryEntryDisabler.INTEGRATION: 'integration'>,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.test_cabin_overheat_protection',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Cabin overheat protection',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_cabin_overheat_protection',
'unique_id': 'LRW3F7EK4NC700000-climate_state_cabin_overheat_protection',
'unit_of_measurement': None,
})
# ---
# name: test_climate_noscope[climate.test_climate-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'hvac_modes': list([
<HVACMode.HEAT_COOL: 'heat_cool'>,
]),
'max_temp': 28.0,
'min_temp': 15.0,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.test_climate',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Climate',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': <TeslemetryClimateSide.DRIVER: 'driver_temp'>,
'unique_id': 'LRW3F7EK4NC700000-driver_temp',
'unit_of_measurement': None,
})
# ---
# name: test_invalid_error[error]
'Command returned exception: The data request or command is unknown.'
# ---

View File

@@ -0,0 +1,721 @@
# serializer version: 1
# name: test_cover[cover.test_charge_port_door-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_charge_port_door',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Charge port door',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 3>,
'translation_key': 'charge_state_charge_port_door_open',
'unique_id': 'LRW3F7EK4NC700000-charge_state_charge_port_door_open',
'unit_of_measurement': None,
})
# ---
# name: test_cover[cover.test_charge_port_door-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Charge port door',
'supported_features': <CoverEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'cover.test_charge_port_door',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover[cover.test_frunk-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_frunk',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Frunk',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 1>,
'translation_key': 'vehicle_state_ft',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_ft',
'unit_of_measurement': None,
})
# ---
# name: test_cover[cover.test_frunk-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Frunk',
'supported_features': <CoverEntityFeature: 1>,
}),
'context': <ANY>,
'entity_id': 'cover.test_frunk',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'closed',
})
# ---
# name: test_cover[cover.test_sunroof-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_sunroof',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.WINDOW: 'window'>,
'original_icon': None,
'original_name': 'Sunroof',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 11>,
'translation_key': 'vehicle_state_sun_roof_state',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_sun_roof_state',
'unit_of_measurement': None,
})
# ---
# name: test_cover[cover.test_sunroof-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'window',
'friendly_name': 'Test Sunroof',
'supported_features': <CoverEntityFeature: 11>,
}),
'context': <ANY>,
'entity_id': 'cover.test_sunroof',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover[cover.test_trunk-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_trunk',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Trunk',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 3>,
'translation_key': 'vehicle_state_rt',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_rt',
'unit_of_measurement': None,
})
# ---
# name: test_cover[cover.test_trunk-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Trunk',
'supported_features': <CoverEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'cover.test_trunk',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'closed',
})
# ---
# name: test_cover[cover.test_windows-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_windows',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.WINDOW: 'window'>,
'original_icon': None,
'original_name': 'Windows',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 3>,
'translation_key': 'windows',
'unique_id': 'LRW3F7EK4NC700000-windows',
'unit_of_measurement': None,
})
# ---
# name: test_cover[cover.test_windows-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'window',
'friendly_name': 'Test Windows',
'supported_features': <CoverEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'cover.test_windows',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'closed',
})
# ---
# name: test_cover_alt[cover.test_charge_port_door-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_charge_port_door',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Charge port door',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 3>,
'translation_key': 'charge_state_charge_port_door_open',
'unique_id': 'LRW3F7EK4NC700000-charge_state_charge_port_door_open',
'unit_of_measurement': None,
})
# ---
# name: test_cover_alt[cover.test_charge_port_door-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Charge port door',
'supported_features': <CoverEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'cover.test_charge_port_door',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover_alt[cover.test_frunk-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_frunk',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Frunk',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 1>,
'translation_key': 'vehicle_state_ft',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_ft',
'unit_of_measurement': None,
})
# ---
# name: test_cover_alt[cover.test_frunk-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Frunk',
'supported_features': <CoverEntityFeature: 1>,
}),
'context': <ANY>,
'entity_id': 'cover.test_frunk',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover_alt[cover.test_sunroof-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_sunroof',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.WINDOW: 'window'>,
'original_icon': None,
'original_name': 'Sunroof',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 11>,
'translation_key': 'vehicle_state_sun_roof_state',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_sun_roof_state',
'unit_of_measurement': None,
})
# ---
# name: test_cover_alt[cover.test_sunroof-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'window',
'friendly_name': 'Test Sunroof',
'supported_features': <CoverEntityFeature: 11>,
}),
'context': <ANY>,
'entity_id': 'cover.test_sunroof',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_cover_alt[cover.test_trunk-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_trunk',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Trunk',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 3>,
'translation_key': 'vehicle_state_rt',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_rt',
'unit_of_measurement': None,
})
# ---
# name: test_cover_alt[cover.test_trunk-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Trunk',
'supported_features': <CoverEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'cover.test_trunk',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover_alt[cover.test_windows-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_windows',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.WINDOW: 'window'>,
'original_icon': None,
'original_name': 'Windows',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <CoverEntityFeature: 3>,
'translation_key': 'windows',
'unique_id': 'LRW3F7EK4NC700000-windows',
'unit_of_measurement': None,
})
# ---
# name: test_cover_alt[cover.test_windows-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'window',
'friendly_name': 'Test Windows',
'supported_features': <CoverEntityFeature: 3>,
}),
'context': <ANY>,
'entity_id': 'cover.test_windows',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover_noscope[cover.test_charge_port_door-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_charge_port_door',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Charge port door',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_state_charge_port_door_open',
'unique_id': 'LRW3F7EK4NC700000-charge_state_charge_port_door_open',
'unit_of_measurement': None,
})
# ---
# name: test_cover_noscope[cover.test_charge_port_door-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Charge port door',
'supported_features': <CoverEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'cover.test_charge_port_door',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover_noscope[cover.test_frunk-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_frunk',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Frunk',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'vehicle_state_ft',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_ft',
'unit_of_measurement': None,
})
# ---
# name: test_cover_noscope[cover.test_frunk-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Frunk',
'supported_features': <CoverEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'cover.test_frunk',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'closed',
})
# ---
# name: test_cover_noscope[cover.test_sunroof-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_sunroof',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.WINDOW: 'window'>,
'original_icon': None,
'original_name': 'Sunroof',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'vehicle_state_sun_roof_state',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_sun_roof_state',
'unit_of_measurement': None,
})
# ---
# name: test_cover_noscope[cover.test_sunroof-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'window',
'friendly_name': 'Test Sunroof',
'supported_features': <CoverEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'cover.test_sunroof',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_cover_noscope[cover.test_trunk-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_trunk',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.DOOR: 'door'>,
'original_icon': None,
'original_name': 'Trunk',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'vehicle_state_rt',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_rt',
'unit_of_measurement': None,
})
# ---
# name: test_cover_noscope[cover.test_trunk-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'door',
'friendly_name': 'Test Trunk',
'supported_features': <CoverEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'cover.test_trunk',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'closed',
})
# ---
# name: test_cover_noscope[cover.test_windows-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.test_windows',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <CoverDeviceClass.WINDOW: 'window'>,
'original_icon': None,
'original_name': 'Windows',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'windows',
'unique_id': 'LRW3F7EK4NC700000-windows',
'unit_of_measurement': None,
})
# ---
# name: test_cover_noscope[cover.test_windows-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'window',
'friendly_name': 'Test Windows',
'supported_features': <CoverEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'cover.test_windows',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'closed',
})
# ---

View File

@@ -0,0 +1,135 @@
# serializer version: 1
# name: test_device_tracker[device_tracker.test_location-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.test_location',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Location',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'location',
'unique_id': 'LRW3F7EK4NC700000-location',
'unit_of_measurement': None,
})
# ---
# name: test_device_tracker[device_tracker.test_location-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Location',
'gps_accuracy': 0,
'latitude': -30.222626,
'longitude': -97.6236871,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.test_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
})
# ---
# name: test_device_tracker[device_tracker.test_route-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'device_tracker',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'device_tracker.test_route',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Route',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'route',
'unique_id': 'LRW3F7EK4NC700000-route',
'unit_of_measurement': None,
})
# ---
# name: test_device_tracker[device_tracker.test_route-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Route',
'gps_accuracy': 0,
'latitude': 30.2226265,
'longitude': -97.6236871,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.test_route',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'home',
})
# ---
# name: test_device_tracker_alt[device_tracker.test_location-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Location',
'gps_accuracy': 0,
'latitude': -30.222626,
'longitude': -97.6236871,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.test_location',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
})
# ---
# name: test_device_tracker_alt[device_tracker.test_route-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Route',
'gps_accuracy': 0,
'latitude': 30.2226265,
'longitude': -97.6236871,
'source_type': <SourceType.GPS: 'gps'>,
}),
'context': <ANY>,
'entity_id': 'device_tracker.test_route',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'not_home',
})
# ---

View File

@@ -0,0 +1,438 @@
# serializer version: 1
# name: test_diagnostics
dict({
'energysites': list([
dict({
'info': dict({
'backup_reserve_percent': 0,
'battery_count': 2,
'components_backup': True,
'components_backup_time_remaining_enabled': True,
'components_batteries': list([
dict({
'device_id': 'battery-1-id',
'din': 'battery-1-din',
'nameplate_energy': 13500,
'nameplate_max_charge_power': 5000,
'nameplate_max_discharge_power': 5000,
'part_name': 'Powerwall 2',
'part_number': '3012170-10-B',
'part_type': 2,
'serial_number': 'TG000000001DA5',
}),
dict({
'device_id': 'battery-2-id',
'din': 'battery-2-din',
'nameplate_energy': 13500,
'nameplate_max_charge_power': 5000,
'nameplate_max_discharge_power': 5000,
'part_name': 'Powerwall 2',
'part_number': '3012170-05-C',
'part_type': 2,
'serial_number': 'TG000000002DA5',
}),
]),
'components_battery': True,
'components_battery_solar_offset_view_enabled': True,
'components_battery_type': 'ac_powerwall',
'components_car_charging_data_supported': False,
'components_configurable': True,
'components_customer_preferred_export_rule': 'pv_only',
'components_disallow_charge_from_grid_with_solar_installed': True,
'components_energy_service_self_scheduling_enabled': True,
'components_energy_value_header': 'Energy Value',
'components_energy_value_subheader': 'Estimated Value',
'components_flex_energy_request_capable': False,
'components_gateway': 'teg',
'components_gateways': list([
dict({
'device_id': 'gateway-id',
'din': 'gateway-din',
'firmware_version': '24.4.0 0fe780c9',
'is_active': True,
'part_name': 'Tesla Backup Gateway 2',
'part_number': '1152100-14-J',
'part_type': 10,
'serial_number': 'CN00000000J50D',
'site_id': '1234-abcd',
'updated_datetime': '2024-05-14T00:00:00.000Z',
}),
]),
'components_grid': True,
'components_grid_services_enabled': False,
'components_load_meter': True,
'components_net_meter_mode': 'battery_ok',
'components_off_grid_vehicle_charging_reserve_supported': True,
'components_set_islanding_mode_enabled': True,
'components_show_grid_import_battery_source_cards': True,
'components_solar': True,
'components_solar_type': 'pv_panel',
'components_solar_value_enabled': True,
'components_storm_mode_capable': True,
'components_system_alerts_enabled': True,
'components_tou_capable': True,
'components_vehicle_charging_performance_view_enabled': False,
'components_vehicle_charging_solar_offset_view_enabled': False,
'components_wall_connectors': list([
dict({
'device_id': '123abc',
'din': 'abd-123',
'is_active': True,
'part_name': 'Gen 3 Wall Connector',
}),
dict({
'device_id': '234bcd',
'din': 'bcd-234',
'is_active': True,
'part_name': 'Gen 3 Wall Connector',
}),
]),
'components_wifi_commissioning_enabled': True,
'default_real_mode': 'self_consumption',
'id': '1233-abcd',
'installation_date': '**REDACTED**',
'installation_time_zone': '',
'max_site_meter_power_ac': 1000000000,
'min_site_meter_power_ac': -1000000000,
'nameplate_energy': 40500,
'nameplate_power': 15000,
'site_name': 'Site',
'tou_settings_optimization_strategy': 'economics',
'tou_settings_schedule': list([
dict({
'end_seconds': 3600,
'start_seconds': 0,
'target': 'off_peak',
'week_days': list([
1,
0,
]),
}),
dict({
'end_seconds': 0,
'start_seconds': 3600,
'target': 'peak',
'week_days': list([
1,
0,
]),
}),
]),
'user_settings_breaker_alert_enabled': False,
'user_settings_go_off_grid_test_banner_enabled': False,
'user_settings_powerwall_onboarding_settings_set': True,
'user_settings_powerwall_tesla_electric_interested_in': False,
'user_settings_storm_mode_enabled': True,
'user_settings_sync_grid_alert_enabled': True,
'user_settings_vpp_tour_enabled': True,
'version': '23.44.0 eb113390',
'vpp_backup_reserve_percent': 0,
}),
'live': dict({
'backup_capable': True,
'battery_power': 5060,
'energy_left': 38896.47368421053,
'generator_power': 0,
'grid_power': 0,
'grid_services_active': False,
'grid_services_power': 0,
'grid_status': 'Active',
'island_status': 'on_grid',
'load_power': 6245,
'percentage_charged': 95.50537403739663,
'solar_power': 1185,
'storm_mode_active': False,
'timestamp': '2024-01-01T00:00:00+00:00',
'total_pack_energy': 40727,
'wall_connectors': dict({
'abd-123': dict({
'din': 'abd-123',
'wall_connector_fault_state': 2,
'wall_connector_power': 0,
'wall_connector_state': 2,
}),
'bcd-234': dict({
'din': 'bcd-234',
'wall_connector_fault_state': 2,
'wall_connector_power': 0,
'wall_connector_state': 2,
}),
}),
}),
}),
]),
'scopes': list([
'openid',
'offline_access',
'user_data',
'vehicle_device_data',
'vehicle_cmds',
'vehicle_charging_cmds',
'energy_device_data',
'energy_cmds',
]),
'vehicles': list([
dict({
'data': dict({
'access_type': 'OWNER',
'api_version': 71,
'backseat_token': None,
'backseat_token_updated_at': None,
'ble_autopair_enrolled': False,
'calendar_enabled': True,
'charge_state_battery_heater_on': False,
'charge_state_battery_level': 77,
'charge_state_battery_range': 266.87,
'charge_state_charge_amps': 16,
'charge_state_charge_current_request': 16,
'charge_state_charge_current_request_max': 16,
'charge_state_charge_enable_request': True,
'charge_state_charge_energy_added': 0,
'charge_state_charge_limit_soc': 80,
'charge_state_charge_limit_soc_max': 100,
'charge_state_charge_limit_soc_min': 50,
'charge_state_charge_limit_soc_std': 80,
'charge_state_charge_miles_added_ideal': 0,
'charge_state_charge_miles_added_rated': 0,
'charge_state_charge_port_cold_weather_mode': False,
'charge_state_charge_port_color': '<invalid>',
'charge_state_charge_port_door_open': True,
'charge_state_charge_port_latch': 'Engaged',
'charge_state_charge_rate': 0,
'charge_state_charger_actual_current': 0,
'charge_state_charger_phases': None,
'charge_state_charger_pilot_current': 16,
'charge_state_charger_power': 0,
'charge_state_charger_voltage': 2,
'charge_state_charging_state': 'Stopped',
'charge_state_conn_charge_cable': 'IEC',
'charge_state_est_battery_range': 275.04,
'charge_state_fast_charger_brand': '<invalid>',
'charge_state_fast_charger_present': False,
'charge_state_fast_charger_type': 'ACSingleWireCAN',
'charge_state_ideal_battery_range': 266.87,
'charge_state_max_range_charge_counter': 0,
'charge_state_minutes_to_full_charge': 0,
'charge_state_not_enough_power_to_heat': None,
'charge_state_off_peak_charging_enabled': False,
'charge_state_off_peak_charging_times': 'all_week',
'charge_state_off_peak_hours_end_time': 900,
'charge_state_preconditioning_enabled': False,
'charge_state_preconditioning_times': 'all_week',
'charge_state_scheduled_charging_mode': 'Off',
'charge_state_scheduled_charging_pending': False,
'charge_state_scheduled_charging_start_time': None,
'charge_state_scheduled_charging_start_time_app': 600,
'charge_state_scheduled_departure_time': 1704837600,
'charge_state_scheduled_departure_time_minutes': 480,
'charge_state_supercharger_session_trip_planner': False,
'charge_state_time_to_full_charge': 0,
'charge_state_timestamp': 1705707520649,
'charge_state_trip_charging': False,
'charge_state_usable_battery_level': 77,
'charge_state_user_charge_enable_request': None,
'climate_state_allow_cabin_overheat_protection': True,
'climate_state_auto_seat_climate_left': True,
'climate_state_auto_seat_climate_right': True,
'climate_state_auto_steering_wheel_heat': False,
'climate_state_battery_heater': False,
'climate_state_battery_heater_no_power': None,
'climate_state_cabin_overheat_protection': 'On',
'climate_state_cabin_overheat_protection_actively_cooling': False,
'climate_state_climate_keeper_mode': 'keep',
'climate_state_cop_activation_temperature': 'High',
'climate_state_defrost_mode': 0,
'climate_state_driver_temp_setting': 22,
'climate_state_fan_status': 0,
'climate_state_hvac_auto_request': 'On',
'climate_state_inside_temp': 29.8,
'climate_state_is_auto_conditioning_on': False,
'climate_state_is_climate_on': True,
'climate_state_is_front_defroster_on': False,
'climate_state_is_preconditioning': False,
'climate_state_is_rear_defroster_on': False,
'climate_state_left_temp_direction': 251,
'climate_state_max_avail_temp': 28,
'climate_state_min_avail_temp': 15,
'climate_state_outside_temp': 30,
'climate_state_passenger_temp_setting': 22,
'climate_state_remote_heater_control_enabled': False,
'climate_state_right_temp_direction': 251,
'climate_state_seat_heater_left': 0,
'climate_state_seat_heater_rear_center': 0,
'climate_state_seat_heater_rear_left': 0,
'climate_state_seat_heater_rear_right': 0,
'climate_state_seat_heater_right': 0,
'climate_state_side_mirror_heaters': False,
'climate_state_steering_wheel_heat_level': 0,
'climate_state_steering_wheel_heater': False,
'climate_state_supports_fan_only_cabin_overheat_protection': True,
'climate_state_timestamp': 1705707520649,
'climate_state_wiper_blade_heater': False,
'color': None,
'drive_state_active_route_destination': 'Home',
'drive_state_active_route_latitude': '**REDACTED**',
'drive_state_active_route_longitude': '**REDACTED**',
'drive_state_active_route_miles_to_arrival': 0.039491,
'drive_state_active_route_minutes_to_arrival': 0.103577,
'drive_state_active_route_traffic_minutes_delay': 0,
'drive_state_gps_as_of': 1701129612,
'drive_state_heading': 185,
'drive_state_latitude': '**REDACTED**',
'drive_state_longitude': '**REDACTED**',
'drive_state_native_latitude': '**REDACTED**',
'drive_state_native_location_supported': 1,
'drive_state_native_longitude': '**REDACTED**',
'drive_state_native_type': 'wgs',
'drive_state_power': -7,
'drive_state_shift_state': None,
'drive_state_speed': None,
'drive_state_timestamp': 1705707520649,
'granular_access_hide_private': False,
'gui_settings_gui_24_hour_time': False,
'gui_settings_gui_charge_rate_units': 'kW',
'gui_settings_gui_distance_units': 'km/hr',
'gui_settings_gui_range_display': 'Rated',
'gui_settings_gui_temperature_units': 'C',
'gui_settings_gui_tirepressure_units': 'Psi',
'gui_settings_show_range_units': False,
'gui_settings_timestamp': 1705707520649,
'id': '**REDACTED**',
'id_s': '**REDACTED**',
'in_service': False,
'state': 'online',
'tokens': '**REDACTED**',
'user_id': '**REDACTED**',
'vehicle_config_aux_park_lamps': 'Eu',
'vehicle_config_badge_version': 1,
'vehicle_config_can_accept_navigation_requests': True,
'vehicle_config_can_actuate_trunks': True,
'vehicle_config_car_special_type': 'base',
'vehicle_config_car_type': 'model3',
'vehicle_config_charge_port_type': 'CCS',
'vehicle_config_cop_user_set_temp_supported': True,
'vehicle_config_dashcam_clip_save_supported': True,
'vehicle_config_default_charge_to_max': False,
'vehicle_config_driver_assist': 'TeslaAP3',
'vehicle_config_ece_restrictions': False,
'vehicle_config_efficiency_package': 'M32021',
'vehicle_config_eu_vehicle': True,
'vehicle_config_exterior_color': 'DeepBlue',
'vehicle_config_exterior_trim': 'Black',
'vehicle_config_exterior_trim_override': '',
'vehicle_config_has_air_suspension': False,
'vehicle_config_has_ludicrous_mode': False,
'vehicle_config_has_seat_cooling': False,
'vehicle_config_headlamp_type': 'Global',
'vehicle_config_interior_trim_type': 'White2',
'vehicle_config_key_version': 2,
'vehicle_config_motorized_charge_port': True,
'vehicle_config_paint_color_override': '0,9,25,0.7,0.04',
'vehicle_config_performance_package': 'Base',
'vehicle_config_plg': True,
'vehicle_config_pws': True,
'vehicle_config_rear_drive_unit': 'PM216MOSFET',
'vehicle_config_rear_seat_heaters': 1,
'vehicle_config_rear_seat_type': 0,
'vehicle_config_rhd': True,
'vehicle_config_roof_color': 'RoofColorGlass',
'vehicle_config_seat_type': None,
'vehicle_config_spoiler_type': 'None',
'vehicle_config_sun_roof_installed': True,
'vehicle_config_supports_qr_pairing': False,
'vehicle_config_third_row_seats': 'None',
'vehicle_config_timestamp': 1705707520649,
'vehicle_config_trim_badging': '74d',
'vehicle_config_use_range_badging': True,
'vehicle_config_utc_offset': 36000,
'vehicle_config_webcam_selfie_supported': True,
'vehicle_config_webcam_supported': True,
'vehicle_config_wheel_type': 'Pinwheel18CapKit',
'vehicle_id': '**REDACTED**',
'vehicle_state_api_version': 71,
'vehicle_state_autopark_state_v2': 'unavailable',
'vehicle_state_calendar_supported': True,
'vehicle_state_car_version': '2023.44.30.8 06f534d46010',
'vehicle_state_center_display_state': 0,
'vehicle_state_dashcam_clip_save_available': True,
'vehicle_state_dashcam_state': 'Recording',
'vehicle_state_df': 0,
'vehicle_state_dr': 0,
'vehicle_state_fd_window': 0,
'vehicle_state_feature_bitmask': 'fbdffbff,187f',
'vehicle_state_fp_window': 0,
'vehicle_state_ft': 0,
'vehicle_state_is_user_present': False,
'vehicle_state_locked': False,
'vehicle_state_media_info_a2dp_source_name': 'Pixel 8 Pro',
'vehicle_state_media_info_audio_volume': 1.6667,
'vehicle_state_media_info_audio_volume_increment': 0.333333,
'vehicle_state_media_info_audio_volume_max': 10.333333,
'vehicle_state_media_info_media_playback_status': 'Playing',
'vehicle_state_media_info_now_playing_album': 'Elon Musk',
'vehicle_state_media_info_now_playing_artist': 'Walter Isaacson',
'vehicle_state_media_info_now_playing_duration': 651000,
'vehicle_state_media_info_now_playing_elapsed': 1000,
'vehicle_state_media_info_now_playing_source': 'Audible',
'vehicle_state_media_info_now_playing_station': 'Elon Musk',
'vehicle_state_media_info_now_playing_title': 'Chapter 51: Cybertruck: Tesla, 2018–2019',
'vehicle_state_media_state_remote_control_enabled': True,
'vehicle_state_notifications_supported': True,
'vehicle_state_odometer': 6481.019282,
'vehicle_state_parsed_calendar_supported': True,
'vehicle_state_pf': 0,
'vehicle_state_pr': 0,
'vehicle_state_rd_window': 0,
'vehicle_state_remote_start': False,
'vehicle_state_remote_start_enabled': True,
'vehicle_state_remote_start_supported': True,
'vehicle_state_rp_window': 0,
'vehicle_state_rt': 0,
'vehicle_state_santa_mode': 0,
'vehicle_state_sentry_mode': False,
'vehicle_state_sentry_mode_available': True,
'vehicle_state_service_mode': False,
'vehicle_state_service_mode_plus': False,
'vehicle_state_software_update_download_perc': 100,
'vehicle_state_software_update_expected_duration_sec': 2700,
'vehicle_state_software_update_install_perc': 1,
'vehicle_state_software_update_status': 'available',
'vehicle_state_software_update_version': '2024.12.0.0',
'vehicle_state_speed_limit_mode_active': False,
'vehicle_state_speed_limit_mode_current_limit_mph': 69,
'vehicle_state_speed_limit_mode_max_limit_mph': 120,
'vehicle_state_speed_limit_mode_min_limit_mph': 50,
'vehicle_state_speed_limit_mode_pin_code_set': True,
'vehicle_state_sun_roof_state': 'open',
'vehicle_state_timestamp': 1705707520649,
'vehicle_state_tpms_hard_warning_fl': False,
'vehicle_state_tpms_hard_warning_fr': False,
'vehicle_state_tpms_hard_warning_rl': False,
'vehicle_state_tpms_hard_warning_rr': False,
'vehicle_state_tpms_last_seen_pressure_time_fl': 1705700812,
'vehicle_state_tpms_last_seen_pressure_time_fr': 1705700793,
'vehicle_state_tpms_last_seen_pressure_time_rl': 1705700794,
'vehicle_state_tpms_last_seen_pressure_time_rr': 1705700823,
'vehicle_state_tpms_pressure_fl': 2.775,
'vehicle_state_tpms_pressure_fr': 2.8,
'vehicle_state_tpms_pressure_rl': 2.775,
'vehicle_state_tpms_pressure_rr': 2.775,
'vehicle_state_tpms_rcp_front_value': 2.9,
'vehicle_state_tpms_rcp_rear_value': 2.9,
'vehicle_state_tpms_soft_warning_fl': False,
'vehicle_state_tpms_soft_warning_fr': False,
'vehicle_state_tpms_soft_warning_rl': False,
'vehicle_state_tpms_soft_warning_rr': False,
'vehicle_state_valet_mode': False,
'vehicle_state_valet_pin_needed': False,
'vehicle_state_vehicle_name': 'Test',
'vehicle_state_vehicle_self_test_progress': 0,
'vehicle_state_vehicle_self_test_requested': False,
'vehicle_state_vehicle_state_sun_roof_percent_open': 20,
'vehicle_state_webcam_available': True,
'vin': '**REDACTED**',
}),
}),
]),
})
# ---

View File

@@ -0,0 +1,129 @@
# serializer version: 1
# name: test_devices[{('teslemetry', '123456')}]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': 'https://teslemetry.com/console',
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'teslemetry',
'123456',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'Tesla',
'model': 'Powerwall 2, Tesla Backup Gateway 2',
'model_id': None,
'name': 'Energy Site',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': '123456',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
})
# ---
# name: test_devices[{('teslemetry', 'LRW3F7EK4NC700000')}]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': 'https://teslemetry.com/console',
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'teslemetry',
'LRW3F7EK4NC700000',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'Tesla',
'model': 'Model 3',
'model_id': None,
'name': 'Test',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': 'LRW3F7EK4NC700000',
'suggested_area': None,
'sw_version': None,
'via_device_id': None,
})
# ---
# name: test_devices[{('teslemetry', 'abd-123')}]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': 'https://teslemetry.com/console',
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'teslemetry',
'abd-123',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'Tesla',
'model': 'Gen 3 Wall Connector',
'model_id': None,
'name': 'Wall Connector',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': '123',
'suggested_area': None,
'sw_version': None,
'via_device_id': <ANY>,
})
# ---
# name: test_devices[{('teslemetry', 'bcd-234')}]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'configuration_url': 'https://teslemetry.com/console',
'connections': set({
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'teslemetry',
'bcd-234',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'Tesla',
'model': 'Gen 3 Wall Connector',
'model_id': None,
'name': 'Wall Connector',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': '234',
'suggested_area': None,
'sw_version': None,
'via_device_id': <ANY>,
})
# ---

View File

@@ -0,0 +1,95 @@
# serializer version: 1
# name: test_lock[lock.test_charge_cable_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'lock',
'entity_category': None,
'entity_id': 'lock.test_charge_cable_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Charge cable lock',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_state_charge_port_latch',
'unique_id': 'LRW3F7EK4NC700000-charge_state_charge_port_latch',
'unit_of_measurement': None,
})
# ---
# name: test_lock[lock.test_charge_cable_lock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Charge cable lock',
'supported_features': <LockEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'lock.test_charge_cable_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'locked',
})
# ---
# name: test_lock[lock.test_lock-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'lock',
'entity_category': None,
'entity_id': 'lock.test_lock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Lock',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'vehicle_state_locked',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_locked',
'unit_of_measurement': None,
})
# ---
# name: test_lock[lock.test_lock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Lock',
'supported_features': <LockEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'lock.test_lock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unlocked',
})
# ---

View File

@@ -0,0 +1,135 @@
# serializer version: 1
# name: test_media_player[media_player.test_media_player-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'media_player',
'entity_category': None,
'entity_id': 'media_player.test_media_player',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <MediaPlayerDeviceClass.SPEAKER: 'speaker'>,
'original_icon': None,
'original_name': 'Media player',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <MediaPlayerEntityFeature: 16437>,
'translation_key': 'media',
'unique_id': 'LRW3F7EK4NC700000-media',
'unit_of_measurement': None,
})
# ---
# name: test_media_player[media_player.test_media_player-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'speaker',
'friendly_name': 'Test Media player',
'media_album_name': 'Elon Musk',
'media_artist': 'Walter Isaacson',
'media_duration': 651.0,
'media_playlist': 'Elon Musk',
'media_position': 1.0,
'media_title': 'Chapter 51: Cybertruck: Tesla, 2018–2019',
'source': 'Audible',
'supported_features': <MediaPlayerEntityFeature: 16437>,
'volume_level': 0.16129355359011466,
}),
'context': <ANY>,
'entity_id': 'media_player.test_media_player',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'playing',
})
# ---
# name: test_media_player_alt[media_player.test_media_player-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'speaker',
'friendly_name': 'Test Media player',
'media_album_name': '',
'media_artist': '',
'media_playlist': '',
'media_title': '',
'source': 'Spotify',
'supported_features': <MediaPlayerEntityFeature: 16437>,
}),
'context': <ANY>,
'entity_id': 'media_player.test_media_player',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'idle',
})
# ---
# name: test_media_player_noscope[media_player.test_media_player-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'media_player',
'entity_category': None,
'entity_id': 'media_player.test_media_player',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <MediaPlayerDeviceClass.SPEAKER: 'speaker'>,
'original_icon': None,
'original_name': 'Media player',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'media',
'unique_id': 'LRW3F7EK4NC700000-media',
'unit_of_measurement': None,
})
# ---
# name: test_media_player_noscope[media_player.test_media_player-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'speaker',
'friendly_name': 'Test Media player',
'media_album_name': 'Elon Musk',
'media_artist': 'Walter Isaacson',
'media_duration': 651.0,
'media_playlist': 'Elon Musk',
'media_position': 1.0,
'media_title': 'Chapter 51: Cybertruck: Tesla, 2018–2019',
'source': 'Audible',
'supported_features': <MediaPlayerEntityFeature: 0>,
'volume_level': 0.16129355359011466,
}),
'context': <ANY>,
'entity_id': 'media_player.test_media_player',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'playing',
})
# ---

View File

@@ -0,0 +1,231 @@
# serializer version: 1
# name: test_number[number.energy_site_backup_reserve-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 100,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': None,
'entity_id': 'number.energy_site_backup_reserve',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <NumberDeviceClass.BATTERY: 'battery'>,
'original_icon': 'mdi:battery-alert',
'original_name': 'Backup reserve',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'backup_reserve_percent',
'unique_id': '123456-backup_reserve_percent',
'unit_of_measurement': '%',
})
# ---
# name: test_number[number.energy_site_backup_reserve-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'battery',
'friendly_name': 'Energy Site Backup reserve',
'icon': 'mdi:battery-alert',
'max': 100,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'number.energy_site_backup_reserve',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '0',
})
# ---
# name: test_number[number.energy_site_off_grid_reserve-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 100,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': None,
'entity_id': 'number.energy_site_off_grid_reserve',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <NumberDeviceClass.BATTERY: 'battery'>,
'original_icon': 'mdi:battery-unknown',
'original_name': 'Off grid reserve',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'off_grid_vehicle_charging_reserve_percent',
'unique_id': '123456-off_grid_vehicle_charging_reserve_percent',
'unit_of_measurement': '%',
})
# ---
# name: test_number[number.energy_site_off_grid_reserve-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'battery',
'friendly_name': 'Energy Site Off grid reserve',
'icon': 'mdi:battery-unknown',
'max': 100,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'number.energy_site_off_grid_reserve',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_number[number.test_charge_current-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 16,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': None,
'entity_id': 'number.test_charge_current',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <NumberDeviceClass.CURRENT: 'current'>,
'original_icon': None,
'original_name': 'Charge current',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_state_charge_current_request',
'unique_id': 'LRW3F7EK4NC700000-charge_state_charge_current_request',
'unit_of_measurement': <UnitOfElectricCurrent.AMPERE: 'A'>,
})
# ---
# name: test_number[number.test_charge_current-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'current',
'friendly_name': 'Test Charge current',
'max': 16,
'min': 0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
'unit_of_measurement': <UnitOfElectricCurrent.AMPERE: 'A'>,
}),
'context': <ANY>,
'entity_id': 'number.test_charge_current',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '16',
})
# ---
# name: test_number[number.test_charge_limit-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 100,
'min': 50,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': None,
'entity_id': 'number.test_charge_limit',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <NumberDeviceClass.BATTERY: 'battery'>,
'original_icon': None,
'original_name': 'Charge limit',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_state_charge_limit_soc',
'unique_id': 'LRW3F7EK4NC700000-charge_state_charge_limit_soc',
'unit_of_measurement': '%',
})
# ---
# name: test_number[number.test_charge_limit-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'battery',
'friendly_name': 'Test Charge limit',
'max': 100,
'min': 50,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1,
'unit_of_measurement': '%',
}),
'context': <ANY>,
'entity_id': 'number.test_charge_limit',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '80',
})
# ---

View File

@@ -0,0 +1,410 @@
# serializer version: 1
# name: test_select[select.energy_site_allow_export-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
<EnergyExportMode.NEVER: 'never'>,
<EnergyExportMode.BATTERY_OK: 'battery_ok'>,
<EnergyExportMode.PV_ONLY: 'pv_only'>,
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.energy_site_allow_export',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Allow export',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'components_customer_preferred_export_rule',
'unique_id': '123456-components_customer_preferred_export_rule',
'unit_of_measurement': None,
})
# ---
# name: test_select[select.energy_site_allow_export-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Energy Site Allow export',
'options': list([
<EnergyExportMode.NEVER: 'never'>,
<EnergyExportMode.BATTERY_OK: 'battery_ok'>,
<EnergyExportMode.PV_ONLY: 'pv_only'>,
]),
}),
'context': <ANY>,
'entity_id': 'select.energy_site_allow_export',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'pv_only',
})
# ---
# name: test_select[select.energy_site_operation_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
<EnergyOperationMode.AUTONOMOUS: 'autonomous'>,
<EnergyOperationMode.BACKUP: 'backup'>,
<EnergyOperationMode.SELF_CONSUMPTION: 'self_consumption'>,
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.energy_site_operation_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Operation mode',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'default_real_mode',
'unique_id': '123456-default_real_mode',
'unit_of_measurement': None,
})
# ---
# name: test_select[select.energy_site_operation_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Energy Site Operation mode',
'options': list([
<EnergyOperationMode.AUTONOMOUS: 'autonomous'>,
<EnergyOperationMode.BACKUP: 'backup'>,
<EnergyOperationMode.SELF_CONSUMPTION: 'self_consumption'>,
]),
}),
'context': <ANY>,
'entity_id': 'select.energy_site_operation_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'self_consumption',
})
# ---
# name: test_select[select.test_seat_heater_front_left-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.test_seat_heater_front_left',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Seat heater front left',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_seat_heater_left',
'unique_id': 'LRW3F7EK4NC700000-climate_state_seat_heater_left',
'unit_of_measurement': None,
})
# ---
# name: test_select[select.test_seat_heater_front_left-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Seat heater front left',
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'context': <ANY>,
'entity_id': 'select.test_seat_heater_front_left',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_select[select.test_seat_heater_front_right-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.test_seat_heater_front_right',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Seat heater front right',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_seat_heater_right',
'unique_id': 'LRW3F7EK4NC700000-climate_state_seat_heater_right',
'unit_of_measurement': None,
})
# ---
# name: test_select[select.test_seat_heater_front_right-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Seat heater front right',
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'context': <ANY>,
'entity_id': 'select.test_seat_heater_front_right',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_select[select.test_seat_heater_rear_center-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.test_seat_heater_rear_center',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Seat heater rear center',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_seat_heater_rear_center',
'unique_id': 'LRW3F7EK4NC700000-climate_state_seat_heater_rear_center',
'unit_of_measurement': None,
})
# ---
# name: test_select[select.test_seat_heater_rear_center-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Seat heater rear center',
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'context': <ANY>,
'entity_id': 'select.test_seat_heater_rear_center',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_select[select.test_seat_heater_rear_left-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.test_seat_heater_rear_left',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Seat heater rear left',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_seat_heater_rear_left',
'unique_id': 'LRW3F7EK4NC700000-climate_state_seat_heater_rear_left',
'unit_of_measurement': None,
})
# ---
# name: test_select[select.test_seat_heater_rear_left-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Seat heater rear left',
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'context': <ANY>,
'entity_id': 'select.test_seat_heater_rear_left',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_select[select.test_seat_heater_rear_right-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'select',
'entity_category': None,
'entity_id': 'select.test_seat_heater_rear_right',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Seat heater rear right',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_seat_heater_rear_right',
'unique_id': 'LRW3F7EK4NC700000-climate_state_seat_heater_rear_right',
'unit_of_measurement': None,
})
# ---
# name: test_select[select.test_seat_heater_rear_right-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Test Seat heater rear right',
'options': list([
'off',
'low',
'medium',
'high',
]),
}),
'context': <ANY>,
'entity_id': 'select.test_seat_heater_rear_right',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,489 @@
# serializer version: 1
# name: test_switch[switch.energy_site_allow_charging_from_grid-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.energy_site_allow_charging_from_grid',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Allow charging from grid',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'components_disallow_charge_from_grid_with_solar_installed',
'unique_id': '123456-components_disallow_charge_from_grid_with_solar_installed',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.energy_site_allow_charging_from_grid-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Energy Site Allow charging from grid',
}),
'context': <ANY>,
'entity_id': 'switch.energy_site_allow_charging_from_grid',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch[switch.energy_site_storm_watch-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.energy_site_storm_watch',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Storm watch',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'user_settings_storm_mode_enabled',
'unique_id': '123456-user_settings_storm_mode_enabled',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.energy_site_storm_watch-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Energy Site Storm watch',
}),
'context': <ANY>,
'entity_id': 'switch.energy_site_storm_watch',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch[switch.test_auto_seat_climate_left-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_auto_seat_climate_left',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Auto seat climate left',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_auto_seat_climate_left',
'unique_id': 'LRW3F7EK4NC700000-climate_state_auto_seat_climate_left',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.test_auto_seat_climate_left-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Auto seat climate left',
}),
'context': <ANY>,
'entity_id': 'switch.test_auto_seat_climate_left',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch[switch.test_auto_seat_climate_right-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_auto_seat_climate_right',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Auto seat climate right',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_auto_seat_climate_right',
'unique_id': 'LRW3F7EK4NC700000-climate_state_auto_seat_climate_right',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.test_auto_seat_climate_right-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Auto seat climate right',
}),
'context': <ANY>,
'entity_id': 'switch.test_auto_seat_climate_right',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch[switch.test_auto_steering_wheel_heater-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_auto_steering_wheel_heater',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Auto steering wheel heater',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_auto_steering_wheel_heat',
'unique_id': 'LRW3F7EK4NC700000-climate_state_auto_steering_wheel_heat',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.test_auto_steering_wheel_heater-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Auto steering wheel heater',
}),
'context': <ANY>,
'entity_id': 'switch.test_auto_steering_wheel_heater',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch[switch.test_charge-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_charge',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Charge',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'charge_state_user_charge_enable_request',
'unique_id': 'LRW3F7EK4NC700000-charge_state_user_charge_enable_request',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.test_charge-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Charge',
}),
'context': <ANY>,
'entity_id': 'switch.test_charge',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch[switch.test_defrost-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_defrost',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Defrost',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'climate_state_defrost_mode',
'unique_id': 'LRW3F7EK4NC700000-climate_state_defrost_mode',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.test_defrost-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Defrost',
}),
'context': <ANY>,
'entity_id': 'switch.test_defrost',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch[switch.test_sentry_mode-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.test_sentry_mode',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
'original_icon': None,
'original_name': 'Sentry mode',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': 'vehicle_state_sentry_mode',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_sentry_mode',
'unit_of_measurement': None,
})
# ---
# name: test_switch[switch.test_sentry_mode-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Sentry mode',
}),
'context': <ANY>,
'entity_id': 'switch.test_sentry_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_alt[switch.energy_site_allow_charging_from_grid-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Energy Site Allow charging from grid',
}),
'context': <ANY>,
'entity_id': 'switch.energy_site_allow_charging_from_grid',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_alt[switch.energy_site_storm_watch-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Energy Site Storm watch',
}),
'context': <ANY>,
'entity_id': 'switch.energy_site_storm_watch',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch_alt[switch.test_auto_seat_climate_left-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Auto seat climate left',
}),
'context': <ANY>,
'entity_id': 'switch.test_auto_seat_climate_left',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_alt[switch.test_auto_seat_climate_right-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Auto seat climate right',
}),
'context': <ANY>,
'entity_id': 'switch.test_auto_seat_climate_right',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_alt[switch.test_auto_steering_wheel_heater-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Auto steering wheel heater',
}),
'context': <ANY>,
'entity_id': 'switch.test_auto_steering_wheel_heater',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_alt[switch.test_charge-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Charge',
}),
'context': <ANY>,
'entity_id': 'switch.test_charge',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_switch_alt[switch.test_defrost-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Defrost',
}),
'context': <ANY>,
'entity_id': 'switch.test_defrost',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_switch_alt[switch.test_sentry_mode-statealt]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'switch',
'friendly_name': 'Test Sentry mode',
}),
'context': <ANY>,
'entity_id': 'switch.test_sentry_mode',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---

View File

@@ -0,0 +1,117 @@
# serializer version: 1
# name: test_update[update.test_update-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'update',
'entity_category': <EntityCategory.CONFIG: 'config'>,
'entity_id': 'update.test_update',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Update',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <UpdateEntityFeature: 5>,
'translation_key': 'vehicle_state_software_update_status',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_software_update_status',
'unit_of_measurement': None,
})
# ---
# name: test_update[update.test_update-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'auto_update': False,
'display_precision': 0,
'entity_picture': 'https://brands.home-assistant.io/_/teslemetry/icon.png',
'friendly_name': 'Test Update',
'in_progress': False,
'installed_version': '2023.44.30.8',
'latest_version': '2024.12.0.0',
'release_summary': None,
'release_url': None,
'skipped_version': None,
'supported_features': <UpdateEntityFeature: 5>,
'title': None,
'update_percentage': None,
}),
'context': <ANY>,
'entity_id': 'update.test_update',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_update_alt[update.test_update-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': None,
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'update',
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
'entity_id': 'update.test_update',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Update',
'platform': 'teslemetry',
'previous_unique_id': None,
'supported_features': <UpdateEntityFeature: 4>,
'translation_key': 'vehicle_state_software_update_status',
'unique_id': 'LRW3F7EK4NC700000-vehicle_state_software_update_status',
'unit_of_measurement': None,
})
# ---
# name: test_update_alt[update.test_update-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'auto_update': False,
'display_precision': 0,
'entity_picture': 'https://brands.home-assistant.io/_/teslemetry/icon.png',
'friendly_name': 'Test Update',
'in_progress': False,
'installed_version': '2023.44.30.8',
'latest_version': '2023.44.30.8',
'release_summary': None,
'release_url': None,
'skipped_version': None,
'supported_features': <UpdateEntityFeature: 4>,
'title': None,
'update_percentage': None,
}),
'context': <ANY>,
'entity_id': 'update.test_update',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---

View File

@@ -0,0 +1,50 @@
"""Test the Teslemetry binary sensor platform."""
from unittest.mock import AsyncMock
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.teslemetry.coordinator import VEHICLE_INTERVAL
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, assert_entities_alt, setup_platform
from .const import VEHICLE_DATA_ALT
from tests.common import async_fire_time_changed
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensor(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the binary sensor entities are correct."""
entry = await setup_platform(hass, [Platform.BINARY_SENSOR])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_binary_sensor_refresh(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
freezer: FrozenDateTimeFactory,
) -> None:
"""Tests that the binary sensor entities are correct."""
entry = await setup_platform(hass, [Platform.BINARY_SENSOR])
# Refresh
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
freezer.tick(VEHICLE_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert_entities_alt(hass, entry.entry_id, entity_registry, snapshot)

View File

@@ -0,0 +1,53 @@
"""Test the Teslemetry button platform."""
from unittest.mock import patch
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, setup_platform
from .const import COMMAND_OK
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_button(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the button entities are correct."""
entry = await setup_platform(hass, [Platform.BUTTON])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
@pytest.mark.parametrize(
("name", "func"),
[
("flash_lights", "flash_lights"),
("honk_horn", "honk_horn"),
("keyless_driving", "remote_start_drive"),
("play_fart", "remote_boombox"),
("homelink", "trigger_homelink"),
],
)
async def test_press(hass: HomeAssistant, name: str, func: str) -> None:
"""Test pressing the API buttons."""
await setup_platform(hass, [Platform.BUTTON])
with patch(
f"homeassistant.components.teslemetry.VehicleSpecific.{func}",
return_value=COMMAND_OK,
) as command:
await hass.services.async_call(
BUTTON_DOMAIN,
SERVICE_PRESS,
{ATTR_ENTITY_ID: [f"button.test_{name}"]},
blocking=True,
)
command.assert_called_once()

View File

@@ -0,0 +1,365 @@
"""Test the Teslemetry climate platform."""
from unittest.mock import AsyncMock, patch
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from tesla_fleet_api.exceptions import InvalidCommand
from homeassistant.components.climate import (
ATTR_HVAC_MODE,
ATTR_PRESET_MODE,
ATTR_TEMPERATURE,
DOMAIN as CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
SERVICE_SET_PRESET_MODE,
SERVICE_SET_TEMPERATURE,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
HVACMode,
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.helpers import entity_registry as er
from . import assert_entities, setup_platform
from .const import (
COMMAND_ERRORS,
COMMAND_IGNORED_REASON,
METADATA_NOSCOPE,
VEHICLE_DATA_ALT,
VEHICLE_DATA_ASLEEP,
WAKE_UP_ASLEEP,
WAKE_UP_ONLINE,
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_climate(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the climate entity is correct."""
entry = await setup_platform(hass, [Platform.CLIMATE])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
entity_id = "climate.test_climate"
# Turn On and Set Temp
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: [entity_id],
ATTR_TEMPERATURE: 20,
ATTR_HVAC_MODE: HVACMode.HEAT_COOL,
},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_TEMPERATURE] == 20
assert state.state == HVACMode.HEAT_COOL
# Set Temp
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: [entity_id],
ATTR_TEMPERATURE: 21,
},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_TEMPERATURE] == 21
# Set Preset
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{ATTR_ENTITY_ID: [entity_id], ATTR_PRESET_MODE: "keep"},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_PRESET_MODE] == "keep"
# Set Preset
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_PRESET_MODE,
{ATTR_ENTITY_ID: [entity_id], ATTR_PRESET_MODE: "off"},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_PRESET_MODE] == "off"
# Turn Off
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: [entity_id], ATTR_HVAC_MODE: HVACMode.OFF},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == HVACMode.OFF
entity_id = "climate.test_cabin_overheat_protection"
# Turn On and Set Low
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: [entity_id],
ATTR_TEMPERATURE: 30,
ATTR_HVAC_MODE: HVACMode.FAN_ONLY,
},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_TEMPERATURE] == 30
assert state.state == HVACMode.FAN_ONLY
# Set Temp Medium
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: [entity_id],
ATTR_TEMPERATURE: 35,
},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_TEMPERATURE] == 35
# Set Temp High
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: [entity_id],
ATTR_TEMPERATURE: 40,
},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_TEMPERATURE] == 40
# Turn Off
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == HVACMode.OFF
# Turn On
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == HVACMode.COOL
state = hass.states.get(entity_id)
assert state.attributes[ATTR_TEMPERATURE] == 40
assert state.state == HVACMode.COOL
# pytest raises ServiceValidationError
with pytest.raises(
ServiceValidationError,
match="Cabin overheat protection does not support that temperature",
):
# Invalid Temp
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: [entity_id], ATTR_TEMPERATURE: 34},
blocking=True,
)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_climate_alt(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the climate entity is correct."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
entry = await setup_platform(hass, [Platform.CLIMATE])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_invalid_error(hass: HomeAssistant, snapshot: SnapshotAssertion) -> None:
"""Tests service error is handled."""
await setup_platform(hass, platforms=[Platform.CLIMATE])
entity_id = "climate.test_climate"
with (
patch(
"homeassistant.components.teslemetry.VehicleSpecific.auto_conditioning_start",
side_effect=InvalidCommand,
) as mock_on,
pytest.raises(HomeAssistantError) as error,
):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
mock_on.assert_called_once()
assert str(error.value) == snapshot(name="error")
@pytest.mark.parametrize("response", COMMAND_ERRORS)
async def test_errors(hass: HomeAssistant, response: str) -> None:
"""Tests service reason is handled."""
await setup_platform(hass, platforms=[Platform.CLIMATE])
entity_id = "climate.test_climate"
with (
patch(
"homeassistant.components.teslemetry.VehicleSpecific.auto_conditioning_start",
return_value=response,
) as mock_on,
pytest.raises(HomeAssistantError),
):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
mock_on.assert_called_once()
async def test_ignored_error(
hass: HomeAssistant,
) -> None:
"""Tests ignored error is handled."""
await setup_platform(hass, [Platform.CLIMATE])
entity_id = "climate.test_climate"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.auto_conditioning_start",
return_value=COMMAND_IGNORED_REASON,
) as mock_on:
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
mock_on.assert_called_once()
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_asleep_or_offline(
hass: HomeAssistant,
mock_vehicle_data: AsyncMock,
mock_wake_up: AsyncMock,
mock_vehicle: AsyncMock,
freezer: FrozenDateTimeFactory,
snapshot: SnapshotAssertion,
) -> None:
"""Tests asleep is handled."""
mock_vehicle_data.return_value = VEHICLE_DATA_ASLEEP
await setup_platform(hass, [Platform.CLIMATE])
entity_id = "climate.test_climate"
# Run a command but fail trying to wake up the vehicle
mock_wake_up.side_effect = InvalidCommand
with pytest.raises(HomeAssistantError) as error:
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
assert str(error.value) == snapshot(name="InvalidCommand")
mock_wake_up.assert_called_once()
mock_wake_up.side_effect = None
mock_wake_up.reset_mock()
# Run a command but timeout trying to wake up the vehicle
mock_wake_up.return_value = WAKE_UP_ASLEEP
mock_vehicle.return_value = WAKE_UP_ASLEEP
with (
patch("homeassistant.components.teslemetry.helpers.asyncio.sleep"),
pytest.raises(HomeAssistantError) as error,
):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
assert str(error.value) == snapshot(name="HomeAssistantError")
mock_wake_up.assert_called_once()
mock_vehicle.assert_called()
mock_wake_up.reset_mock()
mock_vehicle.reset_mock()
mock_wake_up.return_value = WAKE_UP_ONLINE
mock_vehicle.return_value = WAKE_UP_ONLINE
# Run a command and wake up the vehicle immediately
await hass.services.async_call(
CLIMATE_DOMAIN, SERVICE_TURN_ON, {ATTR_ENTITY_ID: [entity_id]}, blocking=True
)
await hass.async_block_till_done()
mock_wake_up.assert_called_once()
async def test_climate_noscope(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_metadata: AsyncMock,
) -> None:
"""Tests that the climate entity is correct."""
mock_metadata.return_value = METADATA_NOSCOPE
entry = await setup_platform(hass, [Platform.CLIMATE])
entity_entries = er.async_entries_for_config_entry(entity_registry, entry.entry_id)
assert entity_entries
for entity_entry in entity_entries:
assert entity_entry == snapshot(name=f"{entity_entry.entity_id}-entry")
entity_id = "climate.test_climate"
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: [entity_id], ATTR_HVAC_MODE: HVACMode.HEAT_COOL},
blocking=True,
)
with pytest.raises(HomeAssistantError):
await hass.services.async_call(
CLIMATE_DOMAIN,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: [entity_id], ATTR_TEMPERATURE: 20},
blocking=True,
)

View File

@@ -0,0 +1,251 @@
"""Test the Teslemetry config flow."""
from unittest.mock import AsyncMock, patch
from aiohttp import ClientConnectionError
import pytest
from tesla_fleet_api.exceptions import (
InvalidToken,
SubscriptionRequired,
TeslaFleetError,
)
from homeassistant import config_entries
from homeassistant.components.teslemetry.const import DOMAIN
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_ACCESS_TOKEN
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
from .const import CONFIG, METADATA
from tests.common import MockConfigEntry
BAD_CONFIG = {CONF_ACCESS_TOKEN: "bad_access_token"}
async def test_form(
hass: HomeAssistant,
) -> None:
"""Test we get the form."""
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result1["type"] is FlowResultType.FORM
assert not result1["errors"]
with patch(
"homeassistant.components.teslemetry.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result1["flow_id"],
CONFIG,
)
await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 1
assert result2["type"] is FlowResultType.CREATE_ENTRY
assert result2["data"] == CONFIG
@pytest.mark.parametrize(
("side_effect", "error"),
[
(InvalidToken, {CONF_ACCESS_TOKEN: "invalid_access_token"}),
(SubscriptionRequired, {"base": "subscription_required"}),
(ClientConnectionError, {"base": "cannot_connect"}),
(TeslaFleetError, {"base": "unknown"}),
],
)
async def test_form_errors(
hass: HomeAssistant,
side_effect: TeslaFleetError,
error: dict[str, str],
mock_metadata: AsyncMock,
) -> None:
"""Test errors are handled."""
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
mock_metadata.side_effect = side_effect
result2 = await hass.config_entries.flow.async_configure(
result1["flow_id"],
CONFIG,
)
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == error
# Complete the flow
mock_metadata.side_effect = None
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"],
CONFIG,
)
assert result3["type"] is FlowResultType.CREATE_ENTRY
async def test_reauth(hass: HomeAssistant, mock_metadata: AsyncMock) -> None:
"""Test reauth flow."""
mock_entry = MockConfigEntry(
domain=DOMAIN, data=BAD_CONFIG, minor_version=2, unique_id="abc-123"
)
mock_entry.add_to_hass(hass)
result1 = await mock_entry.start_reauth_flow(hass)
assert result1["type"] is FlowResultType.FORM
assert result1["step_id"] == "reauth_confirm"
assert not result1["errors"]
with patch(
"homeassistant.components.teslemetry.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result1["flow_id"],
CONFIG,
)
await hass.async_block_till_done()
assert len(mock_setup_entry.mock_calls) == 1
assert len(mock_metadata.mock_calls) == 1
assert result2["type"] is FlowResultType.ABORT
assert result2["reason"] == "reauth_successful"
assert mock_entry.data == CONFIG
@pytest.mark.parametrize(
("side_effect", "error"),
[
(InvalidToken, {CONF_ACCESS_TOKEN: "invalid_access_token"}),
(SubscriptionRequired, {"base": "subscription_required"}),
(ClientConnectionError, {"base": "cannot_connect"}),
(TeslaFleetError, {"base": "unknown"}),
],
)
async def test_reauth_errors(
hass: HomeAssistant,
mock_metadata: AsyncMock,
side_effect: TeslaFleetError,
error: dict[str, str],
) -> None:
"""Test reauth flows that fail."""
# Start the reauth
mock_entry = MockConfigEntry(
domain=DOMAIN, data=BAD_CONFIG, minor_version=2, unique_id="abc-123"
)
mock_entry.add_to_hass(hass)
result = await mock_entry.start_reauth_flow(hass)
mock_metadata.side_effect = side_effect
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
BAD_CONFIG,
)
await hass.async_block_till_done()
assert result2["type"] is FlowResultType.FORM
assert result2["errors"] == error
# Complete the flow
mock_metadata.side_effect = None
result3 = await hass.config_entries.flow.async_configure(
result2["flow_id"],
CONFIG,
)
assert "errors" not in result3
assert result3["type"] is FlowResultType.ABORT
assert result3["reason"] == "reauth_successful"
assert mock_entry.data == CONFIG
async def test_unique_id_abort(
hass: HomeAssistant,
) -> None:
"""Test duplicate unique ID in config."""
result1 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=CONFIG
)
assert result1["type"] is FlowResultType.CREATE_ENTRY
# Setup a duplicate
result2 = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=CONFIG
)
assert result2["type"] is FlowResultType.ABORT
async def test_migrate_from_1_1(hass: HomeAssistant, mock_metadata: AsyncMock) -> None:
"""Test config migration."""
mock_entry = MockConfigEntry(
domain=DOMAIN,
version=1,
minor_version=1,
unique_id=None,
data=CONFIG,
)
mock_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
entry = hass.config_entries.async_get_entry(mock_entry.entry_id)
assert entry.version == 1
assert entry.minor_version == 2
assert entry.unique_id == METADATA["uid"]
async def test_migrate_error_from_1_1(
hass: HomeAssistant, mock_metadata: AsyncMock
) -> None:
"""Test config migration handles errors."""
mock_metadata.side_effect = TeslaFleetError
mock_entry = MockConfigEntry(
domain=DOMAIN,
version=1,
minor_version=1,
unique_id=None,
data=CONFIG,
)
mock_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
entry = hass.config_entries.async_get_entry(mock_entry.entry_id)
assert entry.state is ConfigEntryState.MIGRATION_ERROR
async def test_migrate_error_from_future(
hass: HomeAssistant, mock_metadata: AsyncMock
) -> None:
"""Test a future version isn't migrated."""
mock_metadata.side_effect = TeslaFleetError
mock_entry = MockConfigEntry(
domain=DOMAIN,
version=2,
minor_version=1,
unique_id="abc-123",
data=CONFIG,
)
mock_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
entry = hass.config_entries.async_get_entry(mock_entry.entry_id)
assert entry.state is ConfigEntryState.MIGRATION_ERROR

View File

@@ -0,0 +1,217 @@
"""Test the Teslemetry cover platform."""
from unittest.mock import AsyncMock, patch
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.cover import (
DOMAIN as COVER_DOMAIN,
SERVICE_CLOSE_COVER,
SERVICE_OPEN_COVER,
SERVICE_STOP_COVER,
CoverState,
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, setup_platform
from .const import COMMAND_OK, METADATA_NOSCOPE, VEHICLE_DATA_ALT
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_cover(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the cover entities are correct."""
entry = await setup_platform(hass, [Platform.COVER])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_cover_alt(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the cover entities are correct with alternate values."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
entry = await setup_platform(hass, [Platform.COVER])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_cover_noscope(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_metadata: AsyncMock,
) -> None:
"""Tests that the cover entities are correct without scopes."""
mock_metadata.return_value = METADATA_NOSCOPE
entry = await setup_platform(hass, [Platform.COVER])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_cover_services(
hass: HomeAssistant,
) -> None:
"""Tests that the cover entities are correct."""
await setup_platform(hass, [Platform.COVER])
# Vent Windows
entity_id = "cover.test_windows"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.window_control",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_OPEN_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.OPEN
call.reset_mock()
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_CLOSE_COVER,
{ATTR_ENTITY_ID: ["cover.test_windows"]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.CLOSED
# Charge Port Door
entity_id = "cover.test_charge_port_door"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_open",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_OPEN_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.OPEN
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_close",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_CLOSE_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.CLOSED
# Frunk
entity_id = "cover.test_frunk"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.actuate_trunk",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_OPEN_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.OPEN
# Trunk
entity_id = "cover.test_trunk"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.actuate_trunk",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_OPEN_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.OPEN
call.reset_mock()
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_CLOSE_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.CLOSED
# Sunroof
entity_id = "cover.test_sunroof"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.sun_roof_control",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_OPEN_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.OPEN
call.reset_mock()
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_STOP_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.OPEN
call.reset_mock()
await hass.services.async_call(
COVER_DOMAIN,
SERVICE_CLOSE_COVER,
{ATTR_ENTITY_ID: [entity_id]},
blocking=True,
)
call.assert_called_once()
state = hass.states.get(entity_id)
assert state
assert state.state == CoverState.CLOSED

View File

@@ -0,0 +1,36 @@
"""Test the Teslemetry device tracker platform."""
from unittest.mock import AsyncMock
from syrupy.assertion import SnapshotAssertion
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, assert_entities_alt, setup_platform
from .const import VEHICLE_DATA_ALT
async def test_device_tracker(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the device tracker entities are correct."""
entry = await setup_platform(hass, [Platform.DEVICE_TRACKER])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_device_tracker_alt(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the device tracker entities are correct."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
entry = await setup_platform(hass, [Platform.DEVICE_TRACKER])
assert_entities_alt(hass, entry.entry_id, entity_registry, snapshot)

View File

@@ -0,0 +1,23 @@
"""Test the Telemetry Diagnostics."""
from syrupy.assertion import SnapshotAssertion
from homeassistant.core import HomeAssistant
from . import setup_platform
from tests.components.diagnostics import get_diagnostics_for_config_entry
from tests.typing import ClientSessionGenerator
async def test_diagnostics(
hass: HomeAssistant,
hass_client: ClientSessionGenerator,
snapshot: SnapshotAssertion,
) -> None:
"""Test diagnostics."""
entry = await setup_platform(hass)
diag = await get_diagnostics_for_config_entry(hass, hass_client, entry)
assert diag == snapshot

View File

@@ -0,0 +1,184 @@
"""Test the Teslemetry init."""
from unittest.mock import AsyncMock
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from tesla_fleet_api.exceptions import (
InvalidToken,
SubscriptionRequired,
TeslaFleetError,
VehicleOffline,
)
from homeassistant.components.teslemetry.coordinator import VEHICLE_INTERVAL
from homeassistant.components.teslemetry.models import TeslemetryData
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import STATE_OFF, STATE_ON, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr
from . import setup_platform
from .const import VEHICLE_DATA_ALT
from tests.common import async_fire_time_changed
ERRORS = [
(InvalidToken, ConfigEntryState.SETUP_ERROR),
(SubscriptionRequired, ConfigEntryState.SETUP_ERROR),
(TeslaFleetError, ConfigEntryState.SETUP_RETRY),
]
async def test_load_unload(hass: HomeAssistant) -> None:
"""Test load and unload."""
entry = await setup_platform(hass)
assert entry.state is ConfigEntryState.LOADED
assert isinstance(entry.runtime_data, TeslemetryData)
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async_block_till_done()
assert entry.state is ConfigEntryState.NOT_LOADED
assert not hasattr(entry, "runtime_data")
@pytest.mark.parametrize(("side_effect", "state"), ERRORS)
async def test_init_error(
hass: HomeAssistant,
mock_products: AsyncMock,
side_effect: TeslaFleetError,
state: ConfigEntryState,
) -> None:
"""Test init with errors."""
mock_products.side_effect = side_effect
entry = await setup_platform(hass)
assert entry.state is state
# Test devices
async def test_devices(
hass: HomeAssistant, device_registry: dr.DeviceRegistry, snapshot: SnapshotAssertion
) -> None:
"""Test device registry."""
entry = await setup_platform(hass)
devices = dr.async_entries_for_config_entry(device_registry, entry.entry_id)
for device in devices:
assert device == snapshot(name=f"{device.identifiers}")
async def test_vehicle_refresh_offline(
hass: HomeAssistant, mock_vehicle_data: AsyncMock, freezer: FrozenDateTimeFactory
) -> None:
"""Test coordinator refresh with an error."""
entry = await setup_platform(hass, [Platform.CLIMATE])
assert entry.state is ConfigEntryState.LOADED
mock_vehicle_data.assert_called_once()
mock_vehicle_data.reset_mock()
mock_vehicle_data.side_effect = VehicleOffline
freezer.tick(VEHICLE_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
mock_vehicle_data.assert_called_once()
@pytest.mark.parametrize(("side_effect", "state"), ERRORS)
async def test_vehicle_refresh_error(
hass: HomeAssistant,
mock_vehicle_data: AsyncMock,
side_effect: TeslaFleetError,
state: ConfigEntryState,
) -> None:
"""Test coordinator refresh with an error."""
mock_vehicle_data.side_effect = side_effect
entry = await setup_platform(hass)
assert entry.state is state
# Test Energy Live Coordinator
@pytest.mark.parametrize(("side_effect", "state"), ERRORS)
async def test_energy_live_refresh_error(
hass: HomeAssistant,
mock_live_status: AsyncMock,
side_effect: TeslaFleetError,
state: ConfigEntryState,
) -> None:
"""Test coordinator refresh with an error."""
mock_live_status.side_effect = side_effect
entry = await setup_platform(hass)
assert entry.state is state
# Test Energy Site Coordinator
@pytest.mark.parametrize(("side_effect", "state"), ERRORS)
async def test_energy_site_refresh_error(
hass: HomeAssistant,
mock_site_info: AsyncMock,
side_effect: TeslaFleetError,
state: ConfigEntryState,
) -> None:
"""Test coordinator refresh with an error."""
mock_site_info.side_effect = side_effect
entry = await setup_platform(hass)
assert entry.state is state
# Test Energy History Coordinator
@pytest.mark.parametrize(("side_effect", "state"), ERRORS)
async def test_energy_history_refresh_error(
hass: HomeAssistant,
mock_energy_history: AsyncMock,
side_effect: TeslaFleetError,
state: ConfigEntryState,
) -> None:
"""Test coordinator refresh with an error."""
mock_energy_history.side_effect = side_effect
entry = await setup_platform(hass)
assert entry.state is state
async def test_vehicle_stream(
hass: HomeAssistant,
mock_listen: AsyncMock,
snapshot: SnapshotAssertion,
) -> None:
"""Test vehicle stream events."""
entry = await setup_platform(hass, [Platform.BINARY_SENSOR])
mock_listen.assert_called_once()
state = hass.states.get("binary_sensor.test_status")
assert state.state == STATE_ON
state = hass.states.get("binary_sensor.test_user_present")
assert state.state == STATE_OFF
runtime_data: TeslemetryData = entry.runtime_data
for listener, _ in runtime_data.vehicles[0].stream._listeners.values():
listener(
{
"vin": VEHICLE_DATA_ALT["response"]["vin"],
"vehicle_data": VEHICLE_DATA_ALT["response"],
"createdAt": "2024-10-04T10:45:17.537Z",
}
)
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test_user_present")
assert state.state == STATE_ON
for listener, _ in runtime_data.vehicles[0].stream._listeners.values():
listener(
{
"vin": VEHICLE_DATA_ALT["response"]["vin"],
"state": "offline",
"createdAt": "2024-10-04T10:45:17.537Z",
}
)
await hass.async_block_till_done()
state = hass.states.get("binary_sensor.test_status")
assert state.state == STATE_OFF

View File

@@ -0,0 +1,93 @@
"""Test the Teslemetry lock platform."""
from unittest.mock import patch
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.lock import (
DOMAIN as LOCK_DOMAIN,
SERVICE_LOCK,
SERVICE_UNLOCK,
LockState,
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers import entity_registry as er
from . import assert_entities, setup_platform
from .const import COMMAND_OK
async def test_lock(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the lock entities are correct."""
entry = await setup_platform(hass, [Platform.LOCK])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_lock_services(
hass: HomeAssistant,
) -> None:
"""Tests that the lock services work."""
await setup_platform(hass, [Platform.LOCK])
entity_id = "lock.test_lock"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.door_lock",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
LOCK_DOMAIN,
SERVICE_LOCK,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == LockState.LOCKED
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.door_unlock",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
LOCK_DOMAIN,
SERVICE_UNLOCK,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == LockState.UNLOCKED
call.assert_called_once()
entity_id = "lock.test_charge_cable_lock"
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
LOCK_DOMAIN,
SERVICE_LOCK,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_open",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
LOCK_DOMAIN,
SERVICE_UNLOCK,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == LockState.UNLOCKED
call.assert_called_once()

View File

@@ -0,0 +1,139 @@
"""Test the Teslemetry media player platform."""
from unittest.mock import AsyncMock, patch
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.media_player import (
ATTR_MEDIA_VOLUME_LEVEL,
DOMAIN as MEDIA_PLAYER_DOMAIN,
SERVICE_MEDIA_NEXT_TRACK,
SERVICE_MEDIA_PAUSE,
SERVICE_MEDIA_PLAY,
SERVICE_MEDIA_PREVIOUS_TRACK,
SERVICE_VOLUME_SET,
MediaPlayerState,
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, assert_entities_alt, setup_platform
from .const import COMMAND_OK, METADATA_NOSCOPE, VEHICLE_DATA_ALT
async def test_media_player(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the media player entities are correct."""
entry = await setup_platform(hass, [Platform.MEDIA_PLAYER])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_media_player_alt(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the media player entities are correct."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
entry = await setup_platform(hass, [Platform.MEDIA_PLAYER])
assert_entities_alt(hass, entry.entry_id, entity_registry, snapshot)
async def test_media_player_noscope(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_metadata: AsyncMock,
) -> None:
"""Tests that the media player entities are correct without required scope."""
mock_metadata.return_value = METADATA_NOSCOPE
entry = await setup_platform(hass, [Platform.MEDIA_PLAYER])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_media_player_services(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
) -> None:
"""Tests that the media player services work."""
await setup_platform(hass, [Platform.MEDIA_PLAYER])
entity_id = "media_player.test_media_player"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.adjust_volume",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
MEDIA_PLAYER_DOMAIN,
SERVICE_VOLUME_SET,
{ATTR_ENTITY_ID: entity_id, ATTR_MEDIA_VOLUME_LEVEL: 0.5},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.attributes[ATTR_MEDIA_VOLUME_LEVEL] == 0.5
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_toggle_playback",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
MEDIA_PLAYER_DOMAIN,
SERVICE_MEDIA_PAUSE,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == MediaPlayerState.PAUSED
call.assert_called_once()
# This test will fail without the previous call to pause playback
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_toggle_playback",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
MEDIA_PLAYER_DOMAIN,
SERVICE_MEDIA_PLAY,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == MediaPlayerState.PLAYING
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_next_track",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
MEDIA_PLAYER_DOMAIN,
SERVICE_MEDIA_NEXT_TRACK,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_prev_track",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
MEDIA_PLAYER_DOMAIN,
SERVICE_MEDIA_PREVIOUS_TRACK,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
call.assert_called_once()

View File

@@ -0,0 +1,102 @@
"""Test the Teslemetry number platform."""
from unittest.mock import AsyncMock, patch
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.number import (
ATTR_VALUE,
DOMAIN as NUMBER_DOMAIN,
SERVICE_SET_VALUE,
)
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, setup_platform
from .const import COMMAND_OK, VEHICLE_DATA_ALT
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_number(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the number entities are correct."""
entry = await setup_platform(hass, [Platform.NUMBER])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_number_services(
hass: HomeAssistant, mock_vehicle_data: AsyncMock
) -> None:
"""Tests that the number services work."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
await setup_platform(hass, [Platform.NUMBER])
entity_id = "number.test_charge_current"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_charging_amps",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: 16},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == "16"
call.assert_called_once()
entity_id = "number.test_charge_limit"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_charge_limit",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: 60},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == "60"
call.assert_called_once()
entity_id = "number.energy_site_backup_reserve"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.backup",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{
ATTR_ENTITY_ID: entity_id,
ATTR_VALUE: 80,
},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == "80"
call.assert_called_once()
entity_id = "number.energy_site_off_grid_reserve"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.off_grid_vehicle_charging_reserve",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
NUMBER_DOMAIN,
SERVICE_SET_VALUE,
{ATTR_ENTITY_ID: entity_id, ATTR_VALUE: 88},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == "88"
call.assert_called_once()

View File

@@ -0,0 +1,121 @@
"""Test the Teslemetry select platform."""
from unittest.mock import AsyncMock, patch
import pytest
from syrupy.assertion import SnapshotAssertion
from tesla_fleet_api.const import EnergyExportMode, EnergyOperationMode
from homeassistant.components.select import (
ATTR_OPTION,
DOMAIN as SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
)
from homeassistant.components.teslemetry.select import LOW
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, setup_platform
from .const import COMMAND_OK, VEHICLE_DATA_ALT
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_select(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the select entities are correct."""
entry = await setup_platform(hass, [Platform.SELECT])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_select_services(hass: HomeAssistant, mock_vehicle_data) -> None:
"""Tests that the select services work."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
await setup_platform(hass, [Platform.SELECT])
entity_id = "select.test_seat_heater_front_left"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.remote_seat_heater_request",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: LOW},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == LOW
call.assert_called_once()
entity_id = "select.test_steering_wheel_heater"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.remote_steering_wheel_heat_level_request",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: LOW},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == LOW
call.assert_called_once()
entity_id = "select.energy_site_operation_mode"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.operation",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{
ATTR_ENTITY_ID: entity_id,
ATTR_OPTION: EnergyOperationMode.AUTONOMOUS.value,
},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == EnergyOperationMode.AUTONOMOUS.value
call.assert_called_once()
entity_id = "select.energy_site_allow_export"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.grid_import_export",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
SELECT_DOMAIN,
SERVICE_SELECT_OPTION,
{ATTR_ENTITY_ID: entity_id, ATTR_OPTION: EnergyExportMode.BATTERY_OK.value},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == EnergyExportMode.BATTERY_OK.value
call.assert_called_once()
async def test_select_invalid_data(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the select entities handle invalid data."""
broken_data = VEHICLE_DATA_ALT.copy()
broken_data["response"]["climate_state"]["seat_heater_left"] = "green"
broken_data["response"]["climate_state"]["steering_wheel_heat_level"] = "yellow"
mock_vehicle_data.return_value = broken_data
await setup_platform(hass, [Platform.SELECT])
state = hass.states.get("select.test_seat_heater_front_left")
assert state.state == STATE_UNKNOWN
state = hass.states.get("select.test_steering_wheel_heater")
assert state.state == STATE_UNKNOWN

View File

@@ -0,0 +1,42 @@
"""Test the Teslemetry sensor platform."""
from unittest.mock import AsyncMock
from freezegun.api import FrozenDateTimeFactory
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.teslemetry.coordinator import VEHICLE_INTERVAL
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, assert_entities_alt, setup_platform
from .const import VEHICLE_DATA_ALT
from tests.common import async_fire_time_changed
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
async def test_sensors(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
freezer: FrozenDateTimeFactory,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the sensor entities are correct."""
freezer.move_to("2024-01-01 00:00:00+00:00")
entry = await setup_platform(hass, [Platform.SENSOR])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
# Coordinator refresh
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
freezer.tick(VEHICLE_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
assert_entities_alt(hass, entry.entry_id, entity_registry, snapshot)

View File

@@ -0,0 +1,238 @@
"""Test the Teslemetry services."""
from unittest.mock import patch
import pytest
from homeassistant.components.teslemetry.const import DOMAIN
from homeassistant.components.teslemetry.services import (
ATTR_DEPARTURE_TIME,
ATTR_ENABLE,
ATTR_END_OFF_PEAK_TIME,
ATTR_GPS,
ATTR_OFF_PEAK_CHARGING_ENABLED,
ATTR_OFF_PEAK_CHARGING_WEEKDAYS,
ATTR_PIN,
ATTR_PRECONDITIONING_ENABLED,
ATTR_PRECONDITIONING_WEEKDAYS,
ATTR_TIME,
ATTR_TOU_SETTINGS,
SERVICE_NAVIGATE_ATTR_GPS_REQUEST,
SERVICE_SET_SCHEDULED_CHARGING,
SERVICE_SET_SCHEDULED_DEPARTURE,
SERVICE_SPEED_LIMIT,
SERVICE_TIME_OF_USE,
SERVICE_VALET_MODE,
)
from homeassistant.const import CONF_DEVICE_ID, CONF_LATITUDE, CONF_LONGITUDE
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError, ServiceValidationError
from homeassistant.helpers import entity_registry as er
from . import setup_platform
from .const import COMMAND_ERROR, COMMAND_OK
lat = -27.9699373
lon = 153.3726526
async def test_services(
hass: HomeAssistant,
) -> None:
"""Tests that the custom services are correct."""
await setup_platform(hass)
entity_registry = er.async_get(hass)
# Get a vehicle device ID
vehicle_device = entity_registry.async_get("sensor.test_charging").device_id
energy_device = entity_registry.async_get(
"sensor.energy_site_battery_power"
).device_id
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.navigation_gps_request",
return_value=COMMAND_OK,
) as navigation_gps_request:
await hass.services.async_call(
DOMAIN,
SERVICE_NAVIGATE_ATTR_GPS_REQUEST,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_GPS: {CONF_LATITUDE: lat, CONF_LONGITUDE: lon},
},
blocking=True,
)
navigation_gps_request.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_scheduled_charging",
return_value=COMMAND_OK,
) as set_scheduled_charging:
await hass.services.async_call(
DOMAIN,
SERVICE_SET_SCHEDULED_CHARGING,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: True,
ATTR_TIME: "6:00",
},
blocking=True,
)
set_scheduled_charging.assert_called_once()
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
DOMAIN,
SERVICE_SET_SCHEDULED_CHARGING,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: True,
},
blocking=True,
)
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_scheduled_departure",
return_value=COMMAND_OK,
) as set_scheduled_departure:
await hass.services.async_call(
DOMAIN,
SERVICE_SET_SCHEDULED_DEPARTURE,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: True,
ATTR_PRECONDITIONING_ENABLED: True,
ATTR_PRECONDITIONING_WEEKDAYS: False,
ATTR_DEPARTURE_TIME: "6:00",
ATTR_OFF_PEAK_CHARGING_ENABLED: True,
ATTR_OFF_PEAK_CHARGING_WEEKDAYS: False,
ATTR_END_OFF_PEAK_TIME: "5:00",
},
blocking=True,
)
set_scheduled_departure.assert_called_once()
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
DOMAIN,
SERVICE_SET_SCHEDULED_DEPARTURE,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: True,
ATTR_PRECONDITIONING_ENABLED: True,
},
blocking=True,
)
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
DOMAIN,
SERVICE_SET_SCHEDULED_DEPARTURE,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: True,
ATTR_OFF_PEAK_CHARGING_ENABLED: True,
},
blocking=True,
)
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_valet_mode",
return_value=COMMAND_OK,
) as set_valet_mode:
await hass.services.async_call(
DOMAIN,
SERVICE_VALET_MODE,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: True,
ATTR_PIN: 1234,
},
blocking=True,
)
set_valet_mode.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.speed_limit_activate",
return_value=COMMAND_OK,
) as speed_limit_activate:
await hass.services.async_call(
DOMAIN,
SERVICE_SPEED_LIMIT,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: True,
ATTR_PIN: 1234,
},
blocking=True,
)
speed_limit_activate.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.speed_limit_deactivate",
return_value=COMMAND_OK,
) as speed_limit_deactivate:
await hass.services.async_call(
DOMAIN,
SERVICE_SPEED_LIMIT,
{
CONF_DEVICE_ID: vehicle_device,
ATTR_ENABLE: False,
ATTR_PIN: 1234,
},
blocking=True,
)
speed_limit_deactivate.assert_called_once()
with patch(
"homeassistant.components.teslemetry.EnergySpecific.time_of_use_settings",
return_value=COMMAND_OK,
) as set_time_of_use:
await hass.services.async_call(
DOMAIN,
SERVICE_TIME_OF_USE,
{
CONF_DEVICE_ID: energy_device,
ATTR_TOU_SETTINGS: {},
},
blocking=True,
)
set_time_of_use.assert_called_once()
with (
patch(
"homeassistant.components.teslemetry.EnergySpecific.time_of_use_settings",
return_value=COMMAND_ERROR,
) as set_time_of_use,
pytest.raises(HomeAssistantError),
):
await hass.services.async_call(
DOMAIN,
SERVICE_TIME_OF_USE,
{
CONF_DEVICE_ID: energy_device,
ATTR_TOU_SETTINGS: {},
},
blocking=True,
)
async def test_service_validation_errors(
hass: HomeAssistant,
) -> None:
"""Tests that the custom services handle bad data."""
await setup_platform(hass)
# Bad device ID
with pytest.raises(ServiceValidationError):
await hass.services.async_call(
DOMAIN,
SERVICE_NAVIGATE_ATTR_GPS_REQUEST,
{
CONF_DEVICE_ID: "nope",
ATTR_GPS: {CONF_LATITUDE: lat, CONF_LONGITUDE: lon},
},
blocking=True,
)

View File

@@ -0,0 +1,121 @@
"""Test the Teslemetry switch platform."""
from unittest.mock import AsyncMock, patch
import pytest
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.switch import (
DOMAIN as SWITCH_DOMAIN,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
)
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, assert_entities_alt, setup_platform
from .const import COMMAND_OK, VEHICLE_DATA_ALT
async def test_switch(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the switch entities are correct."""
entry = await setup_platform(hass, [Platform.SWITCH])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_switch_alt(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the switch entities are correct."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
entry = await setup_platform(hass, [Platform.SWITCH])
assert_entities_alt(hass, entry.entry_id, entity_registry, snapshot)
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
@pytest.mark.parametrize(
("name", "on", "off"),
[
("test_charge", "VehicleSpecific.charge_start", "VehicleSpecific.charge_stop"),
(
"test_auto_seat_climate_left",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleSpecific.remote_auto_seat_climate_request",
),
(
"test_auto_seat_climate_right",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleSpecific.remote_auto_seat_climate_request",
),
(
"test_auto_steering_wheel_heater",
"VehicleSpecific.remote_auto_steering_wheel_heat_climate_request",
"VehicleSpecific.remote_auto_steering_wheel_heat_climate_request",
),
(
"test_defrost",
"VehicleSpecific.set_preconditioning_max",
"VehicleSpecific.set_preconditioning_max",
),
(
"energy_site_storm_watch",
"EnergySpecific.storm_mode",
"EnergySpecific.storm_mode",
),
(
"energy_site_allow_charging_from_grid",
"EnergySpecific.grid_import_export",
"EnergySpecific.grid_import_export",
),
(
"test_sentry_mode",
"VehicleSpecific.set_sentry_mode",
"VehicleSpecific.set_sentry_mode",
),
],
)
async def test_switch_services(
hass: HomeAssistant, name: str, on: str, off: str
) -> None:
"""Tests that the switch service calls work."""
await setup_platform(hass, [Platform.SWITCH])
entity_id = f"switch.{name}"
with patch(
f"homeassistant.components.teslemetry.{on}",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == STATE_ON
call.assert_called_once()
with patch(
f"homeassistant.components.teslemetry.{off}",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
SWITCH_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == STATE_OFF
call.assert_called_once()

View File

@@ -0,0 +1,80 @@
"""Test the Teslemetry update platform."""
import copy
from unittest.mock import AsyncMock, patch
from freezegun.api import FrozenDateTimeFactory
from syrupy.assertion import SnapshotAssertion
from homeassistant.components.teslemetry.coordinator import VEHICLE_INTERVAL
from homeassistant.components.teslemetry.update import INSTALLING
from homeassistant.components.update import DOMAIN as UPDATE_DOMAIN, SERVICE_INSTALL
from homeassistant.const import ATTR_ENTITY_ID, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from . import assert_entities, setup_platform
from .const import COMMAND_OK, VEHICLE_DATA, VEHICLE_DATA_ALT
from tests.common import async_fire_time_changed
async def test_update(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
) -> None:
"""Tests that the update entities are correct."""
entry = await setup_platform(hass, [Platform.UPDATE])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_update_alt(
hass: HomeAssistant,
snapshot: SnapshotAssertion,
entity_registry: er.EntityRegistry,
mock_vehicle_data: AsyncMock,
) -> None:
"""Tests that the update entities are correct."""
mock_vehicle_data.return_value = VEHICLE_DATA_ALT
entry = await setup_platform(hass, [Platform.UPDATE])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)
async def test_update_services(
hass: HomeAssistant,
mock_vehicle_data: AsyncMock,
freezer: FrozenDateTimeFactory,
snapshot: SnapshotAssertion,
) -> None:
"""Tests that the update services work."""
await setup_platform(hass, [Platform.UPDATE])
entity_id = "update.test_update"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.schedule_software_update",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
UPDATE_DOMAIN,
SERVICE_INSTALL,
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
call.assert_called_once()
VEHICLE_INSTALLING = copy.deepcopy(VEHICLE_DATA)
VEHICLE_INSTALLING["response"]["vehicle_state"]["software_update"]["status"] = (
INSTALLING
)
mock_vehicle_data.return_value = VEHICLE_INSTALLING
freezer.tick(VEHICLE_INTERVAL)
async_fire_time_changed(hass)
await hass.async_block_till_done()
state = hass.states.get(entity_id)
assert state.attributes["in_progress"] == 1