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

View File

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

View File

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

View File

@ -7,5 +7,5 @@
"documentation": "https://www.home-assistant.io/integrations/tesla_fleet", "documentation": "https://www.home-assistant.io/integrations/tesla_fleet",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"loggers": ["tesla-fleet-api"], "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 import asyncio
from dataclasses import dataclass from dataclasses import dataclass
from tesla_fleet_api import EnergySpecific, VehicleSpecific
from tesla_fleet_api.const import Scope from tesla_fleet_api.const import Scope
from tesla_fleet_api.tesla import EnergySite, VehicleFleet
from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.device_registry import DeviceInfo
@ -31,7 +31,7 @@ class TeslaFleetData:
class TeslaFleetVehicleData: class TeslaFleetVehicleData:
"""Data for a vehicle in the TeslaFleet integration.""" """Data for a vehicle in the TeslaFleet integration."""
api: VehicleSpecific api: VehicleFleet
coordinator: TeslaFleetVehicleDataCoordinator coordinator: TeslaFleetVehicleDataCoordinator
vin: str vin: str
device: DeviceInfo device: DeviceInfo
@ -43,7 +43,7 @@ class TeslaFleetVehicleData:
class TeslaFleetEnergyData: class TeslaFleetEnergyData:
"""Data for a vehicle in the TeslaFleet integration.""" """Data for a vehicle in the TeslaFleet integration."""
api: EnergySpecific api: EnergySite
live_coordinator: TeslaFleetEnergySiteLiveCoordinator live_coordinator: TeslaFleetEnergySiteLiveCoordinator
history_coordinator: TeslaFleetEnergySiteHistoryCoordinator history_coordinator: TeslaFleetEnergySiteHistoryCoordinator
info_coordinator: TeslaFleetEnergySiteInfoCoordinator info_coordinator: TeslaFleetEnergySiteInfoCoordinator

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/teslemetry", "documentation": "https://www.home-assistant.io/integrations/teslemetry",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"loggers": ["tesla-fleet-api"], "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 __future__ import annotations
from tesla_fleet_api import VehicleSpecific
from tesla_fleet_api.const import Scope from tesla_fleet_api.const import Scope
from tesla_fleet_api.teslemetry import Vehicle
from homeassistant.components.media_player import ( from homeassistant.components.media_player import (
MediaPlayerDeviceClass, MediaPlayerDeviceClass,
@ -62,7 +62,7 @@ async def async_setup_entry(
class TeslemetryMediaEntity(TeslemetryRootEntity, MediaPlayerEntity): class TeslemetryMediaEntity(TeslemetryRootEntity, MediaPlayerEntity):
"""Base vehicle media player class.""" """Base vehicle media player class."""
api: VehicleSpecific api: Vehicle
_attr_device_class = MediaPlayerDeviceClass.SPEAKER _attr_device_class = MediaPlayerDeviceClass.SPEAKER
_attr_volume_step = VOLUME_STEP _attr_volume_step = VOLUME_STEP

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,5 +6,5 @@
"documentation": "https://www.home-assistant.io/integrations/tessie", "documentation": "https://www.home-assistant.io/integrations/tessie",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"loggers": ["tessie", "tesla-fleet-api"], "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 dataclasses import dataclass
from tesla_fleet_api import EnergySpecific from tesla_fleet_api.tessie import EnergySite
from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.device_registry import DeviceInfo
@ -27,7 +27,7 @@ class TessieData:
class TessieEnergyData: class TessieEnergyData:
"""Data for a Energy Site in the Tessie integration.""" """Data for a Energy Site in the Tessie integration."""
api: EnergySpecific api: EnergySite
live_coordinator: TessieEnergySiteLiveCoordinator live_coordinator: TessieEnergySiteLiveCoordinator
info_coordinator: TessieEnergySiteInfoCoordinator info_coordinator: TessieEnergySiteInfoCoordinator
id: int id: int

View File

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

2
requirements_all.txt generated
View File

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

View File

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

View File

@ -1,4 +1,4 @@
"""Fixtures for Tessie.""" """Fixtures for Tesla Fleet."""
from __future__ import annotations from __future__ import annotations
@ -113,7 +113,7 @@ def mock_products() -> Generator[AsyncMock]:
def mock_vehicle_state() -> Generator[AsyncMock]: def mock_vehicle_state() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle method.""" """Mock Tesla Fleet API Vehicle Specific vehicle method."""
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.vehicle", "tesla_fleet_api.tesla.VehicleFleet.vehicle",
return_value=VEHICLE_ONLINE, return_value=VEHICLE_ONLINE,
) as mock_vehicle: ) as mock_vehicle:
yield mock_vehicle yield mock_vehicle
@ -123,7 +123,7 @@ def mock_vehicle_state() -> Generator[AsyncMock]:
def mock_vehicle_data() -> Generator[AsyncMock]: def mock_vehicle_data() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific vehicle_data method.""" """Mock Tesla Fleet API Vehicle Specific vehicle_data method."""
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.vehicle_data", "tesla_fleet_api.tesla.VehicleFleet.vehicle_data",
return_value=VEHICLE_DATA, return_value=VEHICLE_DATA,
) as mock_vehicle_data: ) as mock_vehicle_data:
yield mock_vehicle_data yield mock_vehicle_data
@ -133,7 +133,7 @@ def mock_vehicle_data() -> Generator[AsyncMock]:
def mock_wake_up() -> Generator[AsyncMock]: def mock_wake_up() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Vehicle Specific wake_up method.""" """Mock Tesla Fleet API Vehicle Specific wake_up method."""
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.wake_up", "tesla_fleet_api.tesla.VehicleFleet.wake_up",
return_value=VEHICLE_ONLINE, return_value=VEHICLE_ONLINE,
) as mock_wake_up: ) as mock_wake_up:
yield mock_wake_up yield mock_wake_up
@ -143,7 +143,7 @@ def mock_wake_up() -> Generator[AsyncMock]:
def mock_live_status() -> Generator[AsyncMock]: def mock_live_status() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Energy Specific live_status method.""" """Mock Tesla Fleet API Energy Specific live_status method."""
with patch( with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.live_status", "tesla_fleet_api.tesla.EnergySite.live_status",
side_effect=lambda: deepcopy(LIVE_STATUS), side_effect=lambda: deepcopy(LIVE_STATUS),
) as mock_live_status: ) as mock_live_status:
yield mock_live_status yield mock_live_status
@ -153,7 +153,7 @@ def mock_live_status() -> Generator[AsyncMock]:
def mock_site_info() -> Generator[AsyncMock]: def mock_site_info() -> Generator[AsyncMock]:
"""Mock Tesla Fleet API Energy Specific site_info method.""" """Mock Tesla Fleet API Energy Specific site_info method."""
with patch( with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.site_info", "tesla_fleet_api.tesla.EnergySite.site_info",
side_effect=lambda: deepcopy(SITE_INFO), side_effect=lambda: deepcopy(SITE_INFO),
) as mock_live_status: ) as mock_live_status:
yield mock_live_status yield mock_live_status
@ -182,7 +182,7 @@ def mock_request():
def mock_energy_history(): def mock_energy_history():
"""Mock Teslemetry Energy Specific site_info method.""" """Mock Teslemetry Energy Specific site_info method."""
with patch( with patch(
"homeassistant.components.teslemetry.EnergySpecific.energy_history", "tesla_fleet_api.tesla.EnergySite.energy_history",
return_value=ENERGY_HISTORY, return_value=ENERGY_HISTORY,
) as mock_live_status: ) as mock_live_status:
yield mock_live_status yield mock_live_status
@ -192,7 +192,7 @@ def mock_energy_history():
def mock_signed_command() -> Generator[AsyncMock]: def mock_signed_command() -> Generator[AsyncMock]:
"""Mock Tesla Fleet Api signed_command method.""" """Mock Tesla Fleet Api signed_command method."""
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSigned.signed_command", "tesla_fleet_api.tesla.VehicleSigned.signed_command",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as mock_signed_command: ) as mock_signed_command:
yield 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]) await setup_platform(hass, normal_config_entry, [Platform.BUTTON])
with patch( with patch(
f"homeassistant.components.tesla_fleet.VehicleSpecific.{func}", f"tesla_fleet_api.tesla.VehicleFleet.{func}",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as command: ) as command:
await hass.services.async_call( await hass.services.async_call(
@ -85,7 +85,7 @@ async def test_press_signing_error(
with ( with (
patch("homeassistant.components.tesla_fleet.TeslaFleetApi.get_private_key"), patch("homeassistant.components.tesla_fleet.TeslaFleetApi.get_private_key"),
patch( patch(
"homeassistant.components.tesla_fleet.VehicleSigned.flash_lights", "tesla_fleet_api.tesla.VehicleSigned.flash_lights",
side_effect=NotOnWhitelistFault, side_effect=NotOnWhitelistFault,
), ),
pytest.raises(HomeAssistantError) as error, pytest.raises(HomeAssistantError) as error,

View File

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

View File

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

View File

@ -59,7 +59,7 @@ async def test_lock_services(
entity_id = "lock.test_lock" entity_id = "lock.test_lock"
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.door_lock", "tesla_fleet_api.tesla.VehicleFleet.door_lock",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -73,7 +73,7 @@ async def test_lock_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.door_unlock", "tesla_fleet_api.tesla.VehicleFleet.door_unlock",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -97,7 +97,7 @@ async def test_lock_services(
) )
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.charge_port_door_open", "tesla_fleet_api.tesla.VehicleFleet.charge_port_door_open",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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" entity_id = "media_player.test_media_player"
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.adjust_volume", "tesla_fleet_api.tesla.VehicleFleet.adjust_volume",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -102,7 +102,7 @@ async def test_media_player_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_toggle_playback", "tesla_fleet_api.tesla.VehicleFleet.media_toggle_playback",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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 # This test will fail without the previous call to pause playback
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_toggle_playback", "tesla_fleet_api.tesla.VehicleFleet.media_toggle_playback",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -131,7 +131,7 @@ async def test_media_player_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_next_track", "tesla_fleet_api.tesla.VehicleFleet.media_next_track",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -144,7 +144,7 @@ async def test_media_player_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.media_prev_track", "tesla_fleet_api.tesla.VehicleFleet.media_prev_track",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(

View File

@ -57,7 +57,7 @@ async def test_number_services(
entity_id = "number.test_charge_current" entity_id = "number.test_charge_current"
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.set_charging_amps", "tesla_fleet_api.tesla.VehicleFleet.set_charging_amps",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -72,7 +72,7 @@ async def test_number_services(
entity_id = "number.test_charge_limit" entity_id = "number.test_charge_limit"
with patch( with patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.set_charge_limit", "tesla_fleet_api.tesla.VehicleFleet.set_charge_limit",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -87,7 +87,7 @@ async def test_number_services(
entity_id = "number.energy_site_backup_reserve" entity_id = "number.energy_site_backup_reserve"
with patch( with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.backup", "tesla_fleet_api.tesla.EnergySite.backup",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -105,7 +105,7 @@ async def test_number_services(
entity_id = "number.energy_site_off_grid_reserve" entity_id = "number.energy_site_off_grid_reserve"
with patch( 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, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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" entity_id = "select.test_seat_heater_front_left"
with ( with (
patch( patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.remote_seat_heater_request", "tesla_fleet_api.tesla.VehicleFleet.remote_seat_heater_request",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as remote_seat_heater_request, ) as remote_seat_heater_request,
patch( patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.auto_conditioning_start", "tesla_fleet_api.tesla.VehicleFleet.auto_conditioning_start",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as auto_conditioning_start, ) as auto_conditioning_start,
): ):
@ -83,11 +83,11 @@ async def test_select_services(
entity_id = "select.test_steering_wheel_heater" entity_id = "select.test_steering_wheel_heater"
with ( with (
patch( 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, return_value=COMMAND_OK,
) as remote_steering_wheel_heat_level_request, ) as remote_steering_wheel_heat_level_request,
patch( patch(
"homeassistant.components.tesla_fleet.VehicleSpecific.auto_conditioning_start", "tesla_fleet_api.tesla.VehicleFleet.auto_conditioning_start",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as auto_conditioning_start, ) as auto_conditioning_start,
): ):
@ -104,7 +104,7 @@ async def test_select_services(
entity_id = "select.energy_site_operation_mode" entity_id = "select.energy_site_operation_mode"
with patch( with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.operation", "tesla_fleet_api.tesla.EnergySite.operation",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -122,7 +122,7 @@ async def test_select_services(
entity_id = "select.energy_site_allow_export" entity_id = "select.energy_site_allow_export"
with patch( with patch(
"homeassistant.components.tesla_fleet.EnergySpecific.grid_import_export", "tesla_fleet_api.tesla.EnergySite.grid_import_export",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(

View File

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

View File

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

View File

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

View File

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

View File

@ -57,7 +57,7 @@ async def test_lock_services(
entity_id = "lock.test_lock" entity_id = "lock.test_lock"
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.door_lock", "tesla_fleet_api.teslemetry.Vehicle.door_lock",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -71,7 +71,7 @@ async def test_lock_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.door_unlock", "tesla_fleet_api.teslemetry.Vehicle.door_unlock",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -95,7 +95,7 @@ async def test_lock_services(
) )
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.charge_port_door_open", "tesla_fleet_api.teslemetry.Vehicle.charge_port_door_open",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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" entity_id = "media_player.test_media_player"
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.adjust_volume", "tesla_fleet_api.teslemetry.Vehicle.adjust_volume",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -90,7 +90,7 @@ async def test_media_player_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_toggle_playback", "tesla_fleet_api.teslemetry.Vehicle.media_toggle_playback",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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 # This test will fail without the previous call to pause playback
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_toggle_playback", "tesla_fleet_api.teslemetry.Vehicle.media_toggle_playback",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -119,7 +119,7 @@ async def test_media_player_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_next_track", "tesla_fleet_api.teslemetry.Vehicle.media_next_track",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -132,7 +132,7 @@ async def test_media_player_services(
call.assert_called_once() call.assert_called_once()
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.media_prev_track", "tesla_fleet_api.teslemetry.Vehicle.media_prev_track",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(

View File

@ -42,7 +42,7 @@ async def test_number_services(
entity_id = "number.test_charge_current" entity_id = "number.test_charge_current"
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_charging_amps", "tesla_fleet_api.teslemetry.Vehicle.set_charging_amps",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -57,7 +57,7 @@ async def test_number_services(
entity_id = "number.test_charge_limit" entity_id = "number.test_charge_limit"
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.set_charge_limit", "tesla_fleet_api.teslemetry.Vehicle.set_charge_limit",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -72,7 +72,7 @@ async def test_number_services(
entity_id = "number.energy_site_backup_reserve" entity_id = "number.energy_site_backup_reserve"
with patch( with patch(
"homeassistant.components.teslemetry.EnergySpecific.backup", "tesla_fleet_api.teslemetry.EnergySite.backup",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_call( await hass.services.async_call(
@ -90,7 +90,7 @@ async def test_number_services(
entity_id = "number.energy_site_off_grid_reserve" entity_id = "number.energy_site_off_grid_reserve"
with patch( 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, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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" entity_id = "select.test_seat_heater_front_left"
with patch( with patch(
"homeassistant.components.teslemetry.VehicleSpecific.remote_seat_heater_request", "tesla_fleet_api.teslemetry.Vehicle.remote_seat_heater_request",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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" entity_id = "select.test_steering_wheel_heater"
with patch( 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, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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" entity_id = "select.energy_site_operation_mode"
with patch( with patch(
"homeassistant.components.teslemetry.EnergySpecific.operation", "tesla_fleet_api.teslemetry.EnergySite.operation",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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" entity_id = "select.energy_site_allow_export"
with patch( with patch(
"homeassistant.components.teslemetry.EnergySpecific.grid_import_export", "tesla_fleet_api.teslemetry.EnergySite.grid_import_export",
return_value=COMMAND_OK, return_value=COMMAND_OK,
) as call: ) as call:
await hass.services.async_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") freezer.move_to("2024-01-01 00:00:00+00:00")
# Force the vehicle to use polling # Force the vehicle to use polling
with patch( with patch("tesla_fleet_api.teslemetry.Vehicle.pre2021", return_value=True):
"homeassistant.components.teslemetry.VehicleSpecific.pre2021", return_value=True
):
entry = await setup_platform(hass, [Platform.SENSOR]) entry = await setup_platform(hass, [Platform.SENSOR])
assert_entities(hass, entry.entry_id, entity_registry, snapshot) assert_entities(hass, entry.entry_id, entity_registry, snapshot)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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