Bump tesla-fleet-api to v1.0.16 (#140869)

* Add streaming climate

* fixes

* Add missing changes

* Fix restore

* Update homeassistant/components/teslemetry/climate.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Use dict

* Add fan mode translations

* Infer side

* WIP

* fix deps

* Migration in progress

* Working

* tesla-fleet-api==1.0.15

* tesla-fleet-api==1.0.16

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
Brett Adams 2025-03-26 21:28:16 +10:00 committed by GitHub
parent d7de8c5f68
commit 4a6d2c91da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
49 changed files with 196 additions and 203 deletions

View File

@ -5,12 +5,7 @@ from typing import Final
from aiohttp.client_exceptions import ClientResponseError
import jwt
from tesla_fleet_api import (
EnergySpecific,
TeslaFleetApi,
VehicleSigned,
VehicleSpecific,
)
from tesla_fleet_api import TeslaFleetApi
from tesla_fleet_api.const import Scope
from tesla_fleet_api.exceptions import (
InvalidRegion,
@ -128,7 +123,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) -
vehicles: list[TeslaFleetVehicleData] = []
energysites: list[TeslaFleetEnergyData] = []
for product in products:
if "vin" in product and hasattr(tesla, "vehicle"):
if "vin" in product and Scope.VEHICLE_DEVICE_DATA in scopes:
# Remove the protobuff 'cached_data' that we do not use to save memory
product.pop("cached_data", None)
vin = product["vin"]
@ -136,9 +131,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) -
if signing:
if not tesla.private_key:
await tesla.get_private_key(hass.config.path("tesla_fleet.key"))
api = VehicleSigned(tesla.vehicle, vin)
api = tesla.vehicles.createSigned(vin)
else:
api = VehicleSpecific(tesla.vehicle, vin)
api = tesla.vehicles.createFleet(vin)
coordinator = TeslaFleetVehicleDataCoordinator(hass, entry, api, product)
await coordinator.async_config_entry_first_refresh()
@ -160,7 +155,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) -
signing=signing,
)
)
elif "energy_site_id" in product and hasattr(tesla, "energy"):
elif "energy_site_id" in product and Scope.ENERGY_DEVICE_DATA in scopes:
site_id = product["energy_site_id"]
if not (
product["components"]["battery"]
@ -173,7 +168,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) -
)
continue
api = EnergySpecific(tesla.energy, site_id)
api = tesla.energySites.create(site_id)
live_coordinator = TeslaFleetEnergySiteLiveCoordinator(hass, entry, api)
history_coordinator = TeslaFleetEnergySiteHistoryCoordinator(
@ -227,7 +222,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslaFleetConfigEntry) -
# Setup Platforms
entry.runtime_data = TeslaFleetData(vehicles, energysites, scopes)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True

View File

@ -7,7 +7,6 @@ from random import randint
from time import time
from typing import TYPE_CHECKING, Any
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import TeslaEnergyPeriod, VehicleDataEndpoint
from tesla_fleet_api.exceptions import (
InvalidToken,
@ -17,6 +16,7 @@ from tesla_fleet_api.exceptions import (
TeslaFleetError,
VehicleOffline,
)
from tesla_fleet_api.tesla import EnergySite, VehicleFleet
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
@ -70,7 +70,7 @@ class TeslaFleetVehicleDataCoordinator(DataUpdateCoordinator[dict[str, Any]]):
self,
hass: HomeAssistant,
config_entry: TeslaFleetConfigEntry,
api: VehicleSpecific,
api: VehicleFleet,
product: dict,
) -> None:
"""Initialize TeslaFleet Vehicle Update Coordinator."""
@ -149,7 +149,7 @@ class TeslaFleetEnergySiteLiveCoordinator(DataUpdateCoordinator[dict[str, Any]])
self,
hass: HomeAssistant,
config_entry: TeslaFleetConfigEntry,
api: EnergySpecific,
api: EnergySite,
) -> None:
"""Initialize TeslaFleet Energy Site Live coordinator."""
super().__init__(
@ -202,7 +202,7 @@ class TeslaFleetEnergySiteHistoryCoordinator(DataUpdateCoordinator[dict[str, Any
self,
hass: HomeAssistant,
config_entry: TeslaFleetConfigEntry,
api: EnergySpecific,
api: EnergySite,
) -> None:
"""Initialize Tesla Fleet Energy Site History coordinator."""
super().__init__(
@ -266,7 +266,7 @@ class TeslaFleetEnergySiteInfoCoordinator(DataUpdateCoordinator[dict[str, Any]])
self,
hass: HomeAssistant,
config_entry: TeslaFleetConfigEntry,
api: EnergySpecific,
api: EnergySite,
product: dict,
) -> None:
"""Initialize TeslaFleet Energy Info coordinator."""

View File

@ -3,8 +3,9 @@
from abc import abstractmethod
from typing import Any
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.tesla.energysite import EnergySite
from tesla_fleet_api.tesla.vehicle.fleet import VehicleFleet
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers.device_registry import DeviceInfo
@ -41,7 +42,7 @@ class TeslaFleetEntity(
| TeslaFleetEnergySiteLiveCoordinator
| TeslaFleetEnergySiteHistoryCoordinator
| TeslaFleetEnergySiteInfoCoordinator,
api: VehicleSpecific | EnergySpecific,
api: VehicleFleet | EnergySite,
key: str,
) -> None:
"""Initialize common aspects of a TeslaFleet entity."""

View File

@ -7,5 +7,5 @@
"documentation": "https://www.home-assistant.io/integrations/tesla_fleet",
"iot_class": "cloud_polling",
"loggers": ["tesla-fleet-api"],
"requirements": ["tesla-fleet-api==0.9.13"]
"requirements": ["tesla-fleet-api==1.0.16"]
}

View File

@ -5,8 +5,8 @@ from __future__ import annotations
import asyncio
from dataclasses import dataclass
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.tesla import EnergySite, VehicleFleet
from homeassistant.helpers.device_registry import DeviceInfo
@ -31,7 +31,7 @@ class TeslaFleetData:
class TeslaFleetVehicleData:
"""Data for a vehicle in the TeslaFleet integration."""
api: VehicleSpecific
api: VehicleFleet
coordinator: TeslaFleetVehicleDataCoordinator
vin: str
device: DeviceInfo
@ -43,7 +43,7 @@ class TeslaFleetVehicleData:
class TeslaFleetEnergyData:
"""Data for a vehicle in the TeslaFleet integration."""
api: EnergySpecific
api: EnergySite
live_coordinator: TeslaFleetEnergySiteLiveCoordinator
history_coordinator: TeslaFleetEnergySiteHistoryCoordinator
info_coordinator: TeslaFleetEnergySiteInfoCoordinator

View File

@ -7,8 +7,8 @@ from dataclasses import dataclass
from itertools import chain
from typing import Any
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.tesla import EnergySite, VehicleFleet
from homeassistant.components.number import (
NumberDeviceClass,
@ -33,7 +33,7 @@ PARALLEL_UPDATES = 0
class TeslaFleetNumberVehicleEntityDescription(NumberEntityDescription):
"""Describes TeslaFleet Number entity."""
func: Callable[[VehicleSpecific, float], Awaitable[Any]]
func: Callable[[VehicleFleet, float], Awaitable[Any]]
native_min_value: float
native_max_value: float
min_key: str | None = None
@ -74,7 +74,7 @@ VEHICLE_DESCRIPTIONS: tuple[TeslaFleetNumberVehicleEntityDescription, ...] = (
class TeslaFleetNumberBatteryEntityDescription(NumberEntityDescription):
"""Describes TeslaFleet Number entity."""
func: Callable[[EnergySpecific, float], Awaitable[Any]]
func: Callable[[EnergySite, float], Awaitable[Any]]
requires: str | None = None

View File

@ -4,7 +4,6 @@ import asyncio
from collections.abc import Callable
from typing import Final
from tesla_fleet_api import EnergySpecific, Teslemetry, VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.exceptions import (
Forbidden,
@ -12,6 +11,7 @@ from tesla_fleet_api.exceptions import (
SubscriptionRequired,
TeslaFleetError,
)
from tesla_fleet_api.teslemetry import Teslemetry
from teslemetry_stream import TeslemetryStream
from homeassistant.config_entries import ConfigEntry
@ -111,7 +111,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslemetryConfigEntry) -
# Remove the protobuff 'cached_data' that we do not use to save memory
product.pop("cached_data", None)
vin = product["vin"]
api = VehicleSpecific(teslemetry.vehicle, vin)
api = teslemetry.vehicles.create(vin)
coordinator = TeslemetryVehicleDataCoordinator(hass, entry, api, product)
device = DeviceInfo(
identifiers={(DOMAIN, vin)},
@ -156,7 +156,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TeslemetryConfigEntry) -
)
continue
api = EnergySpecific(teslemetry.energy, site_id)
api = teslemetry.energySites.create(site_id)
device = DeviceInfo(
identifiers={(DOMAIN, str(site_id))},
manufacturer="Tesla",

View File

@ -6,7 +6,7 @@ from itertools import chain
from typing import Any, cast
from tesla_fleet_api.const import CabinOverheatProtectionTemp, Scope
from tesla_fleet_api.vehicle import VehicleSpecific
from tesla_fleet_api.teslemetry import Vehicle
from homeassistant.components.climate import (
ATTR_HVAC_MODE,
@ -90,7 +90,7 @@ async def async_setup_entry(
class TeslemetryClimateEntity(TeslemetryRootEntity, ClimateEntity):
"""Vehicle Climate Control."""
api: VehicleSpecific
api: Vehicle
_attr_precision = PRECISION_HALVES
_attr_temperature_unit = UnitOfTemperature.CELSIUS
@ -369,7 +369,7 @@ COP_LEVELS = {
class TeslemetryCabinOverheatProtectionEntity(TeslemetryRootEntity, ClimateEntity):
"""Vehicle Cabin Overheat Protection."""
api: VehicleSpecific
api: Vehicle
_attr_precision = PRECISION_WHOLE
_attr_target_temperature_step = 5

View File

@ -6,12 +6,12 @@ from collections.abc import Mapping
from typing import Any
from aiohttp import ClientConnectionError
from tesla_fleet_api import Teslemetry
from tesla_fleet_api.exceptions import (
InvalidToken,
SubscriptionRequired,
TeslaFleetError,
)
from tesla_fleet_api.teslemetry import Teslemetry
import voluptuous as vol
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult

View File

@ -5,13 +5,13 @@ from __future__ import annotations
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Any
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import TeslaEnergyPeriod, VehicleDataEndpoint
from tesla_fleet_api.exceptions import (
InvalidToken,
SubscriptionRequired,
TeslaFleetError,
)
from tesla_fleet_api.teslemetry import EnergySite, Vehicle
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed
@ -49,7 +49,7 @@ class TeslemetryVehicleDataCoordinator(DataUpdateCoordinator[dict[str, Any]]):
self,
hass: HomeAssistant,
config_entry: TeslemetryConfigEntry,
api: VehicleSpecific,
api: Vehicle,
product: dict,
) -> None:
"""Initialize Teslemetry Vehicle Update Coordinator."""
@ -87,7 +87,7 @@ class TeslemetryEnergySiteLiveCoordinator(DataUpdateCoordinator[dict[str, Any]])
self,
hass: HomeAssistant,
config_entry: TeslemetryConfigEntry,
api: EnergySpecific,
api: EnergySite,
data: dict,
) -> None:
"""Initialize Teslemetry Energy Site Live coordinator."""
@ -133,7 +133,7 @@ class TeslemetryEnergySiteInfoCoordinator(DataUpdateCoordinator[dict[str, Any]])
self,
hass: HomeAssistant,
config_entry: TeslemetryConfigEntry,
api: EnergySpecific,
api: EnergySite,
product: dict,
) -> None:
"""Initialize Teslemetry Energy Info coordinator."""
@ -169,7 +169,7 @@ class TeslemetryEnergyHistoryCoordinator(DataUpdateCoordinator[dict[str, Any]]):
self,
hass: HomeAssistant,
config_entry: TeslemetryConfigEntry,
api: EnergySpecific,
api: EnergySite,
) -> None:
"""Initialize Teslemetry Energy Info coordinator."""
super().__init__(

View File

@ -4,8 +4,8 @@ from abc import abstractmethod
from typing import Any
from propcache.api import cached_property
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.teslemetry import EnergySite, Vehicle
from teslemetry_stream import Signal
from homeassistant.exceptions import ServiceValidationError
@ -29,7 +29,7 @@ class TeslemetryRootEntity(Entity):
_attr_has_entity_name = True
scoped: bool
api: VehicleSpecific | EnergySpecific
api: Vehicle | EnergySite
def raise_for_scope(self, scope: Scope):
"""Raise an error if a scope is not available."""
@ -105,7 +105,7 @@ class TeslemetryVehicleEntity(TeslemetryEntity):
"""Parent class for Teslemetry Vehicle entities."""
_last_update: int = 0
api: VehicleSpecific
api: Vehicle
vehicle: TeslemetryVehicleData
def __init__(
@ -134,7 +134,7 @@ class TeslemetryVehicleEntity(TeslemetryEntity):
class TeslemetryEnergyLiveEntity(TeslemetryEntity):
"""Parent class for Teslemetry Energy Site Live entities."""
api: EnergySpecific
api: EnergySite
def __init__(
self,
@ -155,7 +155,7 @@ class TeslemetryEnergyLiveEntity(TeslemetryEntity):
class TeslemetryEnergyInfoEntity(TeslemetryEntity):
"""Parent class for Teslemetry Energy Site Info Entities."""
api: EnergySpecific
api: EnergySite
def __init__(
self,
@ -194,7 +194,7 @@ class TeslemetryWallConnectorEntity(TeslemetryEntity):
"""Parent class for Teslemetry Wall Connector Entities."""
_attr_has_entity_name = True
api: EnergySpecific
api: EnergySite
def __init__(
self,

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/teslemetry",
"iot_class": "cloud_polling",
"loggers": ["tesla-fleet-api"],
"requirements": ["tesla-fleet-api==0.9.13", "teslemetry-stream==0.6.12"]
"requirements": ["tesla-fleet-api==1.0.16", "teslemetry-stream==0.6.12"]
}

View File

@ -2,8 +2,8 @@
from __future__ import annotations
from tesla_fleet_api import VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.teslemetry import Vehicle
from homeassistant.components.media_player import (
MediaPlayerDeviceClass,
@ -62,7 +62,7 @@ async def async_setup_entry(
class TeslemetryMediaEntity(TeslemetryRootEntity, MediaPlayerEntity):
"""Base vehicle media player class."""
api: VehicleSpecific
api: Vehicle
_attr_device_class = MediaPlayerDeviceClass.SPEAKER
_attr_volume_step = VOLUME_STEP

View File

@ -6,8 +6,8 @@ import asyncio
from collections.abc import Callable
from dataclasses import dataclass
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.teslemetry import EnergySite, Vehicle
from teslemetry_stream import TeslemetryStream, TeslemetryStreamVehicle
from homeassistant.config_entries import ConfigEntry
@ -34,7 +34,7 @@ class TeslemetryData:
class TeslemetryVehicleData:
"""Data for a vehicle in the Teslemetry integration."""
api: VehicleSpecific
api: Vehicle
config_entry: ConfigEntry
coordinator: TeslemetryVehicleDataCoordinator
stream: TeslemetryStream
@ -50,7 +50,7 @@ class TeslemetryVehicleData:
class TeslemetryEnergyData:
"""Data for a vehicle in the Teslemetry integration."""
api: EnergySpecific
api: EnergySite
live_coordinator: TeslemetryEnergySiteLiveCoordinator | None
info_coordinator: TeslemetryEnergySiteInfoCoordinator
history_coordinator: TeslemetryEnergyHistoryCoordinator | None

View File

@ -7,8 +7,8 @@ from dataclasses import dataclass
from itertools import chain
from typing import Any
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope
from tesla_fleet_api.teslemetry import EnergySite, Vehicle
from teslemetry_stream import TeslemetryStreamVehicle
from homeassistant.components.number import (
@ -46,7 +46,7 @@ PARALLEL_UPDATES = 0
class TeslemetryNumberVehicleEntityDescription(NumberEntityDescription):
"""Describes Teslemetry Number entity."""
func: Callable[[VehicleSpecific, int], Awaitable[Any]]
func: Callable[[Vehicle, int], Awaitable[Any]]
min_key: str | None = None
max_key: str
native_min_value: float
@ -99,7 +99,7 @@ VEHICLE_DESCRIPTIONS: tuple[TeslemetryNumberVehicleEntityDescription, ...] = (
class TeslemetryNumberBatteryEntityDescription(NumberEntityDescription):
"""Describes Teslemetry Number entity."""
func: Callable[[EnergySpecific, float], Awaitable[Any]]
func: Callable[[EnergySite, float], Awaitable[Any]]
requires: str | None = None
scopes: list[Scope]

View File

@ -7,8 +7,8 @@ from dataclasses import dataclass
from itertools import chain
from typing import Any
from tesla_fleet_api import VehicleSpecific
from tesla_fleet_api.const import EnergyExportMode, EnergyOperationMode, Scope, Seat
from tesla_fleet_api.teslemetry import Vehicle
from teslemetry_stream import TeslemetryStreamVehicle
from homeassistant.components.select import SelectEntity, SelectEntityDescription
@ -40,7 +40,7 @@ LEVEL = {OFF: 0, LOW: 1, MEDIUM: 2, HIGH: 3}
class TeslemetrySelectEntityDescription(SelectEntityDescription):
"""Seat Heater entity description."""
select_fn: Callable[[VehicleSpecific, int], Awaitable[Any]]
select_fn: Callable[[Vehicle, int], Awaitable[Any]]
supported_fn: Callable[[dict], bool] = lambda _: True
streaming_listener: (
Callable[

View File

@ -5,7 +5,7 @@ from __future__ import annotations
from typing import Any
from tesla_fleet_api.const import Scope
from tesla_fleet_api.vehiclespecific import VehicleSpecific
from tesla_fleet_api.teslemetry import Vehicle
from homeassistant.components.update import UpdateEntity, UpdateEntityFeature
from homeassistant.core import HomeAssistant
@ -48,7 +48,7 @@ async def async_setup_entry(
class TeslemetryUpdateEntity(TeslemetryRootEntity, UpdateEntity):
"""Teslemetry Updates entity."""
api: VehicleSpecific
api: Vehicle
_attr_supported_features = UpdateEntityFeature.PROGRESS
async def async_install(

View File

@ -5,9 +5,9 @@ from http import HTTPStatus
import logging
from aiohttp import ClientError, ClientResponseError
from tesla_fleet_api import EnergySpecific, Tessie
from tesla_fleet_api.const import Scope
from tesla_fleet_api.exceptions import TeslaFleetError
from tesla_fleet_api.tessie import Tessie
from tessie_api import get_state_of_all_vehicles
from homeassistant.config_entries import ConfigEntry
@ -123,7 +123,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: TessieConfigEntry) -> bo
)
continue
api = EnergySpecific(tessie.energy, site_id)
api = tessie.energySites.create(site_id)
energysites.append(
TessieEnergyData(
api=api,

View File

@ -8,8 +8,8 @@ import logging
from typing import TYPE_CHECKING, Any
from aiohttp import ClientResponseError
from tesla_fleet_api import EnergySpecific
from tesla_fleet_api.exceptions import InvalidToken, MissingToken, TeslaFleetError
from tesla_fleet_api.tessie import EnergySite
from tessie_api import get_state, get_status
from homeassistant.core import HomeAssistant
@ -102,7 +102,7 @@ class TessieEnergySiteLiveCoordinator(DataUpdateCoordinator[dict[str, Any]]):
config_entry: TessieConfigEntry
def __init__(
self, hass: HomeAssistant, config_entry: TessieConfigEntry, api: EnergySpecific
self, hass: HomeAssistant, config_entry: TessieConfigEntry, api: EnergySite
) -> None:
"""Initialize Tessie Energy Site Live coordinator."""
super().__init__(
@ -138,7 +138,7 @@ class TessieEnergySiteInfoCoordinator(DataUpdateCoordinator[dict[str, Any]]):
config_entry: TessieConfigEntry
def __init__(
self, hass: HomeAssistant, config_entry: TessieConfigEntry, api: EnergySpecific
self, hass: HomeAssistant, config_entry: TessieConfigEntry, api: EnergySite
) -> None:
"""Initialize Tessie Energy Info coordinator."""
super().__init__(

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/tessie",
"iot_class": "cloud_polling",
"loggers": ["tessie", "tesla-fleet-api"],
"requirements": ["tessie-api==0.1.1", "tesla-fleet-api==0.9.13"]
"requirements": ["tessie-api==0.1.1", "tesla-fleet-api==1.0.16"]
}

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from dataclasses import dataclass
from tesla_fleet_api import EnergySpecific
from tesla_fleet_api.tessie import EnergySite
from homeassistant.helpers.device_registry import DeviceInfo
@ -27,7 +27,7 @@ class TessieData:
class TessieEnergyData:
"""Data for a Energy Site in the Tessie integration."""
api: EnergySpecific
api: EnergySite
live_coordinator: TessieEnergySiteLiveCoordinator
info_coordinator: TessieEnergySiteInfoCoordinator
id: int

View File

@ -7,7 +7,7 @@ from dataclasses import dataclass
from itertools import chain
from typing import Any
from tesla_fleet_api import EnergySpecific
from tesla_fleet_api.tessie import EnergySite
from tessie_api import set_charge_limit, set_charging_amps, set_speed_limit
from homeassistant.components.number import (
@ -90,7 +90,7 @@ VEHICLE_DESCRIPTIONS: tuple[TessieNumberEntityDescription, ...] = (
class TessieNumberBatteryEntityDescription(NumberEntityDescription):
"""Describes Tessie Number entity."""
func: Callable[[EnergySpecific, float], Awaitable[Any]]
func: Callable[[EnergySite, float], Awaitable[Any]]
requires: str

2
requirements_all.txt generated
View File

@ -2878,7 +2878,7 @@ temperusb==1.6.1
# homeassistant.components.tesla_fleet
# homeassistant.components.teslemetry
# homeassistant.components.tessie
tesla-fleet-api==0.9.13
tesla-fleet-api==1.0.16
# homeassistant.components.powerwall
tesla-powerwall==0.5.2

View File

@ -2316,7 +2316,7 @@ temperusb==1.6.1
# homeassistant.components.tesla_fleet
# homeassistant.components.teslemetry
# homeassistant.components.tessie
tesla-fleet-api==0.9.13
tesla-fleet-api==1.0.16
# homeassistant.components.powerwall
tesla-powerwall==0.5.2

View File

@ -1,4 +1,4 @@
"""Fixtures for Tessie."""
"""Fixtures for Tesla Fleet."""
from __future__ import annotations
@ -113,7 +113,7 @@ def mock_products() -> Generator[AsyncMock]:
def mock_vehicle_state() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle method."""
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.vehicle",
"tesla_fleet_api.tesla.VehicleFleet.vehicle",
return_value=VEHICLE_ONLINE,
) as mock_vehicle:
yield mock_vehicle
@ -123,7 +123,7 @@ def mock_vehicle_state() -> Generator[AsyncMock]:
def mock_vehicle_data() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle_data method."""
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.vehicle_data",
"tesla_fleet_api.tesla.VehicleFleet.vehicle_data",
return_value=VEHICLE_DATA,
) as mock_vehicle_data:
yield mock_vehicle_data
@ -133,7 +133,7 @@ def mock_vehicle_data() -> Generator[AsyncMock]:
def mock_wake_up() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific wake_up method."""
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.wake_up",
"tesla_fleet_api.tesla.VehicleFleet.wake_up",
return_value=VEHICLE_ONLINE,
) as mock_wake_up:
yield mock_wake_up
@ -143,7 +143,7 @@ def mock_wake_up() -> Generator[AsyncMock]:
def mock_live_status() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Energy Specific live_status method."""
with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.live_status",
"tesla_fleet_api.tesla.EnergySite.live_status",
side_effect=lambda: deepcopy(LIVE_STATUS),
) as mock_live_status:
yield mock_live_status
@ -153,7 +153,7 @@ def mock_live_status() -> Generator[AsyncMock]:
def mock_site_info() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Energy Specific site_info method."""
with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.site_info",
"tesla_fleet_api.tesla.EnergySite.site_info",
side_effect=lambda: deepcopy(SITE_INFO),
) as mock_live_status:
yield mock_live_status
@ -182,7 +182,7 @@ def mock_request():
def mock_energy_history():
"""Mock Teslemetry Energy Specific site_info method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.energy_history",
"tesla_fleet_api.tesla.EnergySite.energy_history",
return_value=ENERGY_HISTORY,
) as mock_live_status:
yield mock_live_status
@ -192,7 +192,7 @@ def mock_energy_history():
def mock_signed_command() -> Generator[AsyncMock]:
"""Mock Tesla Fleet Api signed_command method."""
with patch(
"homeassistant.components.tesla_fleet.VehicleSigned.signed_command",
"tesla_fleet_api.tesla.VehicleSigned.signed_command",
return_value=COMMAND_OK,
) as mock_signed_command:
yield mock_signed_command

View File

@ -56,7 +56,7 @@ async def test_press(
await setup_platform(hass, normal_config_entry, [Platform.BUTTON])
with patch(
f"homeassistant.components.tesla_fleet.VehicleSpecific.{func}",
f"tesla_fleet_api.tesla.VehicleFleet.{func}",
return_value=COMMAND_OK,
) as command:
await hass.services.async_call(
@ -85,7 +85,7 @@ async def test_press_signing_error(
with (
patch("homeassistant.components.tesla_fleet.TeslaFleetApi.get_private_key"),
patch(
"homeassistant.components.tesla_fleet.VehicleSigned.flash_lights",
"tesla_fleet_api.tesla.VehicleSigned.flash_lights",
side_effect=NotOnWhitelistFault,
),
pytest.raises(HomeAssistantError) as error,

View File

@ -257,7 +257,7 @@ async def test_invalid_error(
with (
patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.tesla.VehicleFleet.auto_conditioning_start",
side_effect=InvalidCommand,
) as mock_on,
pytest.raises(
@ -285,7 +285,7 @@ async def test_errors(
with (
patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.tesla.VehicleFleet.auto_conditioning_start",
return_value=response,
) as mock_on,
pytest.raises(HomeAssistantError),
@ -308,7 +308,7 @@ async def test_ignored_error(
await setup_platform(hass, normal_config_entry, [Platform.CLIMATE])
entity_id = "climate.test_climate"
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.tesla.VehicleFleet.auto_conditioning_start",
return_value=COMMAND_IGNORED_REASON,
) as mock_on:
await hass.services.async_call(

View File

@ -89,7 +89,7 @@ async def test_cover_services(
# Vent Windows
entity_id = "cover.test_windows"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.window_control",
"tesla_fleet_api.tesla.VehicleFleet.window_control",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -118,7 +118,7 @@ async def test_cover_services(
# Charge Port Door
entity_id = "cover.test_charge_port_door"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_open",
"tesla_fleet_api.tesla.VehicleFleet.charge_port_door_open",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -133,7 +133,7 @@ async def test_cover_services(
assert state.state == CoverState.OPEN
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_close",
"tesla_fleet_api.tesla.VehicleFleet.charge_port_door_close",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -150,7 +150,7 @@ async def test_cover_services(
# Frunk
entity_id = "cover.test_frunk"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.actuate_trunk",
"tesla_fleet_api.tesla.VehicleFleet.actuate_trunk",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -167,7 +167,7 @@ async def test_cover_services(
# Trunk
entity_id = "cover.test_trunk"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.actuate_trunk",
"tesla_fleet_api.tesla.VehicleFleet.actuate_trunk",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -196,7 +196,7 @@ async def test_cover_services(
# Sunroof
entity_id = "cover.test_sunroof"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.sun_roof_control",
"tesla_fleet_api.tesla.VehicleFleet.sun_roof_control",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -59,7 +59,7 @@ async def test_lock_services(
entity_id = "lock.test_lock"
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.door_lock",
"tesla_fleet_api.tesla.VehicleFleet.door_lock",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -73,7 +73,7 @@ async def test_lock_services(
call.assert_called_once()
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.door_unlock",
"tesla_fleet_api.tesla.VehicleFleet.door_unlock",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -97,7 +97,7 @@ async def test_lock_services(
)
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.charge_port_door_open",
"tesla_fleet_api.tesla.VehicleFleet.charge_port_door_open",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -88,7 +88,7 @@ async def test_media_player_services(
entity_id = "media_player.test_media_player"
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.adjust_volume",
"tesla_fleet_api.tesla.VehicleFleet.adjust_volume",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -102,7 +102,7 @@ async def test_media_player_services(
call.assert_called_once()
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_toggle_playback",
"tesla_fleet_api.tesla.VehicleFleet.media_toggle_playback",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -117,7 +117,7 @@ async def test_media_player_services(
# This test will fail without the previous call to pause playback
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_toggle_playback",
"tesla_fleet_api.tesla.VehicleFleet.media_toggle_playback",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -131,7 +131,7 @@ async def test_media_player_services(
call.assert_called_once()
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_next_track",
"tesla_fleet_api.tesla.VehicleFleet.media_next_track",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -144,7 +144,7 @@ async def test_media_player_services(
call.assert_called_once()
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_prev_track",
"tesla_fleet_api.tesla.VehicleFleet.media_prev_track",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -57,7 +57,7 @@ async def test_number_services(
entity_id = "number.test_charge_current"
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.set_charging_amps",
"tesla_fleet_api.tesla.VehicleFleet.set_charging_amps",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -72,7 +72,7 @@ async def test_number_services(
entity_id = "number.test_charge_limit"
with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.set_charge_limit",
"tesla_fleet_api.tesla.VehicleFleet.set_charge_limit",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -87,7 +87,7 @@ async def test_number_services(
entity_id = "number.energy_site_backup_reserve"
with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.backup",
"tesla_fleet_api.tesla.EnergySite.backup",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -105,7 +105,7 @@ async def test_number_services(
entity_id = "number.energy_site_off_grid_reserve"
with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.off_grid_vehicle_charging_reserve",
"tesla_fleet_api.tesla.EnergySite.off_grid_vehicle_charging_reserve",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -61,11 +61,11 @@ async def test_select_services(
entity_id = "select.test_seat_heater_front_left"
with (
patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.remote_seat_heater_request",
"tesla_fleet_api.tesla.VehicleFleet.remote_seat_heater_request",
return_value=COMMAND_OK,
) as remote_seat_heater_request,
patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.tesla.VehicleFleet.auto_conditioning_start",
return_value=COMMAND_OK,
) as auto_conditioning_start,
):
@ -83,11 +83,11 @@ async def test_select_services(
entity_id = "select.test_steering_wheel_heater"
with (
patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.remote_steering_wheel_heat_level_request",
"tesla_fleet_api.tesla.VehicleFleet.remote_steering_wheel_heat_level_request",
return_value=COMMAND_OK,
) as remote_steering_wheel_heat_level_request,
patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.tesla.VehicleFleet.auto_conditioning_start",
return_value=COMMAND_OK,
) as auto_conditioning_start,
):
@ -104,7 +104,7 @@ async def test_select_services(
entity_id = "select.energy_site_operation_mode"
with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.operation",
"tesla_fleet_api.tesla.EnergySite.operation",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -122,7 +122,7 @@ async def test_select_services(
entity_id = "select.energy_site_allow_export"
with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.grid_import_export",
"tesla_fleet_api.tesla.EnergySite.grid_import_export",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -71,41 +71,41 @@ async def test_switch_offline(
@pytest.mark.parametrize(
("name", "on", "off"),
[
("test_charge", "VehicleSpecific.charge_start", "VehicleSpecific.charge_stop"),
("test_charge", "VehicleFleet.charge_start", "VehicleFleet.charge_stop"),
(
"test_auto_seat_climate_left",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleFleet.remote_auto_seat_climate_request",
"VehicleFleet.remote_auto_seat_climate_request",
),
(
"test_auto_seat_climate_right",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleFleet.remote_auto_seat_climate_request",
"VehicleFleet.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",
"VehicleFleet.remote_auto_steering_wheel_heat_climate_request",
"VehicleFleet.remote_auto_steering_wheel_heat_climate_request",
),
(
"test_defrost",
"VehicleSpecific.set_preconditioning_max",
"VehicleSpecific.set_preconditioning_max",
"VehicleFleet.set_preconditioning_max",
"VehicleFleet.set_preconditioning_max",
),
(
"energy_site_storm_watch",
"EnergySpecific.storm_mode",
"EnergySpecific.storm_mode",
"EnergySite.storm_mode",
"EnergySite.storm_mode",
),
(
"energy_site_allow_charging_from_grid",
"EnergySpecific.grid_import_export",
"EnergySpecific.grid_import_export",
"EnergySite.grid_import_export",
"EnergySite.grid_import_export",
),
(
"test_sentry_mode",
"VehicleSpecific.set_sentry_mode",
"VehicleSpecific.set_sentry_mode",
"VehicleFleet.set_sentry_mode",
"VehicleFleet.set_sentry_mode",
),
],
)
@ -122,7 +122,7 @@ async def test_switch_services(
entity_id = f"switch.{name}"
with patch(
f"homeassistant.components.tesla_fleet.{on}",
f"tesla_fleet_api.tesla.{on}",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -136,7 +136,7 @@ async def test_switch_services(
call.assert_called_once()
with patch(
f"homeassistant.components.tesla_fleet.{off}",
f"tesla_fleet_api.tesla.{off}",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -25,7 +25,7 @@ from .const import (
def mock_metadata():
"""Mock Tesla Fleet Api metadata method."""
with patch(
"homeassistant.components.teslemetry.Teslemetry.metadata", return_value=METADATA
"tesla_fleet_api.teslemetry.Teslemetry.metadata", return_value=METADATA
) as mock_products:
yield mock_products
@ -34,7 +34,7 @@ def mock_metadata():
def mock_products():
"""Mock Tesla Fleet Api products method."""
with patch(
"homeassistant.components.teslemetry.Teslemetry.products", return_value=PRODUCTS
"tesla_fleet_api.teslemetry.Teslemetry.products", return_value=PRODUCTS
) as mock_products:
yield mock_products
@ -43,7 +43,7 @@ def mock_products():
def mock_vehicle_data() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle_data method."""
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.vehicle_data",
"tesla_fleet_api.teslemetry.Vehicle.vehicle_data",
return_value=VEHICLE_DATA,
) as mock_vehicle_data:
yield mock_vehicle_data
@ -53,7 +53,7 @@ def mock_vehicle_data() -> Generator[AsyncMock]:
def mock_legacy():
"""Mock Tesla Fleet Api products method."""
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.pre2021", return_value=True
"tesla_fleet_api.teslemetry.Vehicle.pre2021", return_value=True
) as mock_pre2021:
yield mock_pre2021
@ -62,7 +62,7 @@ def mock_legacy():
def mock_wake_up():
"""Mock Tesla Fleet API Vehicle Specific wake_up method."""
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.wake_up",
"tesla_fleet_api.teslemetry.Vehicle.wake_up",
return_value=WAKE_UP_ONLINE,
) as mock_wake_up:
yield mock_wake_up
@ -72,7 +72,7 @@ def mock_wake_up():
def mock_vehicle() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle method."""
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.vehicle",
"tesla_fleet_api.teslemetry.Vehicle.vehicle",
return_value=WAKE_UP_ONLINE,
) as mock_vehicle:
yield mock_vehicle
@ -82,7 +82,7 @@ def mock_vehicle() -> Generator[AsyncMock]:
def mock_request():
"""Mock Tesla Fleet API Vehicle Specific class."""
with patch(
"homeassistant.components.teslemetry.Teslemetry._request",
"tesla_fleet_api.teslemetry.Teslemetry._request",
return_value=COMMAND_OK,
) as mock_request:
yield mock_request
@ -92,7 +92,7 @@ def mock_request():
def mock_live_status():
"""Mock Teslemetry Energy Specific live_status method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.live_status",
"tesla_fleet_api.tesla.energysite.EnergySite.live_status",
side_effect=lambda: deepcopy(LIVE_STATUS),
) as mock_live_status:
yield mock_live_status
@ -102,7 +102,7 @@ def mock_live_status():
def mock_site_info():
"""Mock Teslemetry Energy Specific site_info method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.site_info",
"tesla_fleet_api.tesla.energysite.EnergySite.site_info",
side_effect=lambda: deepcopy(SITE_INFO),
) as mock_live_status:
yield mock_live_status
@ -112,7 +112,7 @@ def mock_site_info():
def mock_energy_history():
"""Mock Teslemetry Energy Specific site_info method."""
with patch(
"homeassistant.components.teslemetry.EnergySpecific.energy_history",
"tesla_fleet_api.tesla.energysite.EnergySite.energy_history",
return_value=ENERGY_HISTORY,
) as mock_live_status:
yield mock_live_status
@ -122,7 +122,7 @@ def mock_energy_history():
def mock_add_listener():
"""Mock Teslemetry Stream listen method."""
with patch(
"homeassistant.components.teslemetry.TeslemetryStream.async_add_listener",
"teslemetry_stream.TeslemetryStream.async_add_listener",
) as mock_add_listener:
mock_add_listener.listeners = []
@ -165,7 +165,7 @@ def mock_stream_update_config():
def mock_stream_connected():
"""Mock Teslemetry Stream listen method."""
with patch(
"homeassistant.components.teslemetry.TeslemetryStream.connected",
"teslemetry_stream.TeslemetryStream.connected",
return_value=True,
) as mock_stream_connected:
yield mock_stream_connected

View File

@ -42,7 +42,7 @@ async def test_press(hass: HomeAssistant, name: str, func: str) -> None:
await setup_platform(hass, [Platform.BUTTON])
with patch(
f"homeassistant.components.teslemetry.VehicleSpecific.{func}",
f"tesla_fleet_api.teslemetry.Vehicle.{func}",
return_value=COMMAND_OK,
) as command:
await hass.services.async_call(

View File

@ -210,7 +210,7 @@ async def test_invalid_error(hass: HomeAssistant, snapshot: SnapshotAssertion) -
with (
patch(
"homeassistant.components.teslemetry.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.teslemetry.Vehicle.auto_conditioning_start",
side_effect=InvalidCommand,
) as mock_on,
pytest.raises(HomeAssistantError) as error,
@ -234,7 +234,7 @@ async def test_errors(hass: HomeAssistant, response: str) -> None:
with (
patch(
"homeassistant.components.teslemetry.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.teslemetry.Vehicle.auto_conditioning_start",
return_value=response,
) as mock_on,
pytest.raises(HomeAssistantError),
@ -256,7 +256,7 @@ async def test_ignored_error(
await setup_platform(hass, [Platform.CLIMATE])
entity_id = "climate.test_climate"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.auto_conditioning_start",
"tesla_fleet_api.teslemetry.Vehicle.auto_conditioning_start",
return_value=COMMAND_IGNORED_REASON,
) as mock_on:
await hass.services.async_call(

View File

@ -75,7 +75,7 @@ async def test_cover_services(
# Vent Windows
entity_id = "cover.test_windows"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.window_control",
"tesla_fleet_api.teslemetry.Vehicle.window_control",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -104,7 +104,7 @@ async def test_cover_services(
# Charge Port Door
entity_id = "cover.test_charge_port_door"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_open",
"tesla_fleet_api.teslemetry.Vehicle.charge_port_door_open",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -119,7 +119,7 @@ async def test_cover_services(
assert state.state == CoverState.OPEN
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_close",
"tesla_fleet_api.teslemetry.Vehicle.charge_port_door_close",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -136,7 +136,7 @@ async def test_cover_services(
# Frunk
entity_id = "cover.test_frunk"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.actuate_trunk",
"tesla_fleet_api.teslemetry.Vehicle.actuate_trunk",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -153,7 +153,7 @@ async def test_cover_services(
# Trunk
entity_id = "cover.test_trunk"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.actuate_trunk",
"tesla_fleet_api.teslemetry.Vehicle.actuate_trunk",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -182,7 +182,7 @@ async def test_cover_services(
# Sunroof
entity_id = "cover.test_sunroof"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.sun_roof_control",
"tesla_fleet_api.teslemetry.Vehicle.sun_roof_control",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -57,7 +57,7 @@ async def test_lock_services(
entity_id = "lock.test_lock"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.door_lock",
"tesla_fleet_api.teslemetry.Vehicle.door_lock",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -71,7 +71,7 @@ async def test_lock_services(
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.door_unlock",
"tesla_fleet_api.teslemetry.Vehicle.door_unlock",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -95,7 +95,7 @@ async def test_lock_services(
)
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_open",
"tesla_fleet_api.teslemetry.Vehicle.charge_port_door_open",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -76,7 +76,7 @@ async def test_media_player_services(
entity_id = "media_player.test_media_player"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.adjust_volume",
"tesla_fleet_api.teslemetry.Vehicle.adjust_volume",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -90,7 +90,7 @@ async def test_media_player_services(
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_toggle_playback",
"tesla_fleet_api.teslemetry.Vehicle.media_toggle_playback",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -105,7 +105,7 @@ async def test_media_player_services(
# This test will fail without the previous call to pause playback
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_toggle_playback",
"tesla_fleet_api.teslemetry.Vehicle.media_toggle_playback",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -119,7 +119,7 @@ async def test_media_player_services(
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_next_track",
"tesla_fleet_api.teslemetry.Vehicle.media_next_track",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -132,7 +132,7 @@ async def test_media_player_services(
call.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_prev_track",
"tesla_fleet_api.teslemetry.Vehicle.media_prev_track",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -42,7 +42,7 @@ async def test_number_services(
entity_id = "number.test_charge_current"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_charging_amps",
"tesla_fleet_api.teslemetry.Vehicle.set_charging_amps",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -57,7 +57,7 @@ async def test_number_services(
entity_id = "number.test_charge_limit"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_charge_limit",
"tesla_fleet_api.teslemetry.Vehicle.set_charge_limit",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -72,7 +72,7 @@ async def test_number_services(
entity_id = "number.energy_site_backup_reserve"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.backup",
"tesla_fleet_api.teslemetry.EnergySite.backup",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -90,7 +90,7 @@ async def test_number_services(
entity_id = "number.energy_site_off_grid_reserve"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.off_grid_vehicle_charging_reserve",
"tesla_fleet_api.teslemetry.EnergySite.off_grid_vehicle_charging_reserve",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -41,7 +41,7 @@ async def test_select_services(hass: HomeAssistant, mock_vehicle_data) -> None:
entity_id = "select.test_seat_heater_front_left"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.remote_seat_heater_request",
"tesla_fleet_api.teslemetry.Vehicle.remote_seat_heater_request",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -56,7 +56,7 @@ async def test_select_services(hass: HomeAssistant, mock_vehicle_data) -> None:
entity_id = "select.test_steering_wheel_heater"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.remote_steering_wheel_heat_level_request",
"tesla_fleet_api.teslemetry.Vehicle.remote_steering_wheel_heat_level_request",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -71,7 +71,7 @@ async def test_select_services(hass: HomeAssistant, mock_vehicle_data) -> None:
entity_id = "select.energy_site_operation_mode"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.operation",
"tesla_fleet_api.teslemetry.EnergySite.operation",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -89,7 +89,7 @@ async def test_select_services(hass: HomeAssistant, mock_vehicle_data) -> None:
entity_id = "select.energy_site_allow_export"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.grid_import_export",
"tesla_fleet_api.teslemetry.EnergySite.grid_import_export",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -31,9 +31,7 @@ async def test_sensors(
freezer.move_to("2024-01-01 00:00:00+00:00")
# Force the vehicle to use polling
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.pre2021", return_value=True
):
with patch("tesla_fleet_api.teslemetry.Vehicle.pre2021", return_value=True):
entry = await setup_platform(hass, [Platform.SENSOR])
assert_entities(hass, entry.entry_id, entity_registry, snapshot)

View File

@ -51,7 +51,7 @@ async def test_services(
).device_id
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.navigation_gps_request",
"tesla_fleet_api.teslemetry.Vehicle.navigation_gps_request",
return_value=COMMAND_OK,
) as navigation_gps_request:
await hass.services.async_call(
@ -66,7 +66,7 @@ async def test_services(
navigation_gps_request.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_scheduled_charging",
"tesla_fleet_api.teslemetry.Vehicle.set_scheduled_charging",
return_value=COMMAND_OK,
) as set_scheduled_charging:
await hass.services.async_call(
@ -93,7 +93,7 @@ async def test_services(
)
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_scheduled_departure",
"tesla_fleet_api.teslemetry.Vehicle.set_scheduled_departure",
return_value=COMMAND_OK,
) as set_scheduled_departure:
await hass.services.async_call(
@ -138,7 +138,7 @@ async def test_services(
)
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_valet_mode",
"tesla_fleet_api.teslemetry.Vehicle.set_valet_mode",
return_value=COMMAND_OK,
) as set_valet_mode:
await hass.services.async_call(
@ -154,7 +154,7 @@ async def test_services(
set_valet_mode.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.speed_limit_activate",
"tesla_fleet_api.teslemetry.Vehicle.speed_limit_activate",
return_value=COMMAND_OK,
) as speed_limit_activate:
await hass.services.async_call(
@ -170,7 +170,7 @@ async def test_services(
speed_limit_activate.assert_called_once()
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.speed_limit_deactivate",
"tesla_fleet_api.teslemetry.Vehicle.speed_limit_deactivate",
return_value=COMMAND_OK,
) as speed_limit_deactivate:
await hass.services.async_call(
@ -186,7 +186,7 @@ async def test_services(
speed_limit_deactivate.assert_called_once()
with patch(
"homeassistant.components.teslemetry.EnergySpecific.time_of_use_settings",
"tesla_fleet_api.teslemetry.EnergySite.time_of_use_settings",
return_value=COMMAND_OK,
) as set_time_of_use:
await hass.services.async_call(
@ -202,7 +202,7 @@ async def test_services(
with (
patch(
"homeassistant.components.teslemetry.EnergySpecific.time_of_use_settings",
"tesla_fleet_api.teslemetry.EnergySite.time_of_use_settings",
return_value=COMMAND_ERROR,
) as set_time_of_use,
pytest.raises(HomeAssistantError),

View File

@ -49,41 +49,41 @@ async def test_switch_alt(
@pytest.mark.parametrize(
("name", "on", "off"),
[
("test_charge", "VehicleSpecific.charge_start", "VehicleSpecific.charge_stop"),
("test_charge", "Vehicle.charge_start", "Vehicle.charge_stop"),
(
"test_auto_seat_climate_left",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleSpecific.remote_auto_seat_climate_request",
"Vehicle.remote_auto_seat_climate_request",
"Vehicle.remote_auto_seat_climate_request",
),
(
"test_auto_seat_climate_right",
"VehicleSpecific.remote_auto_seat_climate_request",
"VehicleSpecific.remote_auto_seat_climate_request",
"Vehicle.remote_auto_seat_climate_request",
"Vehicle.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",
"Vehicle.remote_auto_steering_wheel_heat_climate_request",
"Vehicle.remote_auto_steering_wheel_heat_climate_request",
),
(
"test_defrost",
"VehicleSpecific.set_preconditioning_max",
"VehicleSpecific.set_preconditioning_max",
"Vehicle.set_preconditioning_max",
"Vehicle.set_preconditioning_max",
),
(
"energy_site_storm_watch",
"EnergySpecific.storm_mode",
"EnergySpecific.storm_mode",
"EnergySite.storm_mode",
"EnergySite.storm_mode",
),
(
"energy_site_allow_charging_from_grid",
"EnergySpecific.grid_import_export",
"EnergySpecific.grid_import_export",
"EnergySite.grid_import_export",
"EnergySite.grid_import_export",
),
(
"test_sentry_mode",
"VehicleSpecific.set_sentry_mode",
"VehicleSpecific.set_sentry_mode",
"Vehicle.set_sentry_mode",
"Vehicle.set_sentry_mode",
),
],
)
@ -96,7 +96,7 @@ async def test_switch_services(
entity_id = f"switch.{name}"
with patch(
f"homeassistant.components.teslemetry.{on}",
f"tesla_fleet_api.teslemetry.{on}",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(
@ -110,7 +110,7 @@ async def test_switch_services(
call.assert_called_once()
with patch(
f"homeassistant.components.teslemetry.{off}",
f"tesla_fleet_api.teslemetry.{off}",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -61,7 +61,7 @@ async def test_update_services(
entity_id = "update.test_update"
with patch(
"homeassistant.components.teslemetry.VehicleSpecific.schedule_software_update",
"tesla_fleet_api.teslemetry.Vehicle.schedule_software_update",
return_value=COMMAND_OK,
) as call:
await hass.services.async_call(

View File

@ -85,7 +85,7 @@ def mock_request():
def mock_live_status():
"""Mock Tesla Fleet API EnergySpecific live_status method."""
with patch(
"homeassistant.components.tessie.EnergySpecific.live_status",
"tesla_fleet_api.tessie.EnergySite.live_status",
side_effect=lambda: deepcopy(LIVE_STATUS),
) as mock_live_status:
yield mock_live_status
@ -95,7 +95,7 @@ def mock_live_status():
def mock_site_info():
"""Mock Tesla Fleet API EnergySpecific site_info method."""
with patch(
"homeassistant.components.tessie.EnergySpecific.site_info",
"tesla_fleet_api.tessie.EnergySite.site_info",
side_effect=lambda: deepcopy(SITE_INFO),
) as mock_live_status:
yield mock_live_status

View File

@ -67,7 +67,7 @@ async def test_numbers(
entity_id = "number.energy_site_backup_reserve"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.backup",
"tesla_fleet_api.tessie.EnergySite.backup",
return_value=TEST_RESPONSE,
) as call:
await hass.services.async_call(
@ -85,7 +85,7 @@ async def test_numbers(
entity_id = "number.energy_site_off_grid_reserve"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.off_grid_vehicle_charging_reserve",
"tesla_fleet_api.tessie.EnergySite.off_grid_vehicle_charging_reserve",
return_value=TEST_RESPONSE,
) as call:
await hass.services.async_call(

View File

@ -52,7 +52,7 @@ async def test_select(
# Test site operation mode
entity_id = "select.energy_site_operation_mode"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.operation",
"tesla_fleet_api.tessie.EnergySite.operation",
return_value=TEST_RESPONSE,
) as call:
await hass.services.async_call(
@ -71,7 +71,7 @@ async def test_select(
# Test site export mode
entity_id = "select.energy_site_allow_export"
with patch(
"homeassistant.components.teslemetry.EnergySpecific.grid_import_export",
"tesla_fleet_api.tessie.EnergySite.grid_import_export",
return_value=TEST_RESPONSE,
) as call:
await hass.services.async_call(
@ -129,7 +129,7 @@ async def test_errors(hass: HomeAssistant) -> None:
# Test changing energy select with unknown error
with (
patch(
"homeassistant.components.tessie.EnergySpecific.operation",
"tesla_fleet_api.tessie.EnergySite.operation",
side_effect=UnsupportedVehicle,
) as mock_set,
pytest.raises(HomeAssistantError) as error,

View File

@ -61,13 +61,13 @@ async def test_switches(
[
(
"energy_site_storm_watch",
"EnergySpecific.storm_mode",
"EnergySpecific.storm_mode",
"storm_mode",
"storm_mode",
),
(
"energy_site_allow_charging_from_grid",
"EnergySpecific.grid_import_export",
"EnergySpecific.grid_import_export",
"grid_import_export",
"grid_import_export",
),
],
)
@ -80,7 +80,7 @@ async def test_switch_services(
entity_id = f"switch.{name}"
with patch(
f"homeassistant.components.teslemetry.{on}",
f"tesla_fleet_api.tessie.EnergySite.{on}",
return_value=RESPONSE_OK,
) as call:
await hass.services.async_call(
@ -94,7 +94,7 @@ async def test_switch_services(
call.assert_called_once()
with patch(
f"homeassistant.components.teslemetry.{off}",
f"tesla_fleet_api.tessie.EnergySite.{off}",
return_value=RESPONSE_OK,
) as call:
await hass.services.async_call(