From 7d3378ce2668b0e2b466feb3d4e54094308da4af Mon Sep 17 00:00:00 2001 From: Brett Date: Thu, 8 Feb 2024 09:43:17 +0000 Subject: [PATCH] Fix imports --- custom_components/teslemetry/__init__.py | 6 +++--- custom_components/teslemetry/button.py | 4 ++-- custom_components/teslemetry/climate.py | 4 ++-- custom_components/teslemetry/coordinator.py | 18 +++++++++--------- custom_components/teslemetry/cover.py | 14 +++++++------- custom_components/teslemetry/lock.py | 4 ++-- custom_components/teslemetry/media_player.py | 4 ++-- custom_components/teslemetry/models.py | 4 ++-- custom_components/teslemetry/number.py | 14 +++++++------- custom_components/teslemetry/select.py | 6 +++--- custom_components/teslemetry/switch.py | 20 ++++++++++---------- custom_components/teslemetry/update.py | 4 ++-- 12 files changed, 51 insertions(+), 51 deletions(-) diff --git a/custom_components/teslemetry/__init__.py b/custom_components/teslemetry/__init__.py index 18340bf..6ff82c2 100644 --- a/custom_components/teslemetry/__init__.py +++ b/custom_components/teslemetry/__init__.py @@ -3,7 +3,7 @@ from typing import Final from tesla_fleet_api import EnergySpecific, Teslemetry, VehicleSpecific -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from tesla_fleet_api.exceptions import InvalidToken, PaymentRequired, TeslaFleetError from homeassistant.config_entries import ConfigEntry @@ -63,7 +63,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: vehicles: list[TeslemetryVehicleData] = [] energysites: list[TeslemetryEnergyData] = [] for product in products: - if "vin" in product and Scopes.VEHICLE_DEVICE_DATA in scopes: + 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"] @@ -76,7 +76,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: vin=vin, ) ) - elif "energy_site_id" in product and Scopes.ENERGY_DEVICE_DATA in scopes: + elif "energy_site_id" in product and Scope.ENERGY_DEVICE_DATA in scopes: site_id = product["energy_site_id"] api = EnergySpecific(teslemetry.energy, site_id) energysites.append( diff --git a/custom_components/teslemetry/button.py b/custom_components/teslemetry/button.py index 1d16d07..01b19e5 100644 --- a/custom_components/teslemetry/button.py +++ b/custom_components/teslemetry/button.py @@ -4,7 +4,7 @@ from collections.abc import Callable from dataclasses import dataclass -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from homeassistant.components.button import ButtonEntity, ButtonEntityDescription from homeassistant.config_entries import ConfigEntry @@ -57,7 +57,7 @@ async def async_setup_entry( TeslemetryButtonEntity(vehicle, description) for vehicle in data.vehicles for description in DESCRIPTIONS - if Scopes.VEHICLE_CMDS in data.scopes + if Scope.VEHICLE_CMDS in data.scopes ) diff --git a/custom_components/teslemetry/climate.py b/custom_components/teslemetry/climate.py index 633d783..a01c18f 100644 --- a/custom_components/teslemetry/climate.py +++ b/custom_components/teslemetry/climate.py @@ -2,7 +2,7 @@ from __future__ import annotations from typing import Any -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from homeassistant.components.climate import ( ClimateEntity, ClimateEntityFeature, @@ -27,7 +27,7 @@ async def async_setup_entry( async_add_entities( TeslemetryClimateEntity( - vehicle, TeslemetryClimateSide.DRIVER, Scopes.VEHICLE_CMDS in data.scopes + vehicle, TeslemetryClimateSide.DRIVER, Scope.VEHICLE_CMDS in data.scopes ) for vehicle in data.vehicles ) diff --git a/custom_components/teslemetry/coordinator.py b/custom_components/teslemetry/coordinator.py index 05d9376..ff5dd9c 100644 --- a/custom_components/teslemetry/coordinator.py +++ b/custom_components/teslemetry/coordinator.py @@ -3,7 +3,7 @@ from typing import Any from tesla_fleet_api import EnergySpecific, VehicleSpecific -from tesla_fleet_api.const import VehicleDataEndpoints +from tesla_fleet_api.const import VehicleDataEndpoint from tesla_fleet_api.exceptions import TeslaFleetError, VehicleOffline from homeassistant.core import HomeAssistant @@ -16,14 +16,14 @@ ENERGY_INFO_INTERVAL = timedelta(seconds=30) ENDPOINTS = [ - VehicleDataEndpoints.CHARGE_STATE, - VehicleDataEndpoints.CLIMATE_STATE, - # VehicleDataEndpoints.CLOSURES_STATE, - VehicleDataEndpoints.DRIVE_STATE, - # VehicleDataEndpoints.GUI_SETTINGS, - VehicleDataEndpoints.LOCATION_DATA, - # VehicleDataEndpoints.VEHICLE_CONFIG, - VehicleDataEndpoints.VEHICLE_STATE, + VehicleDataEndpoint.CHARGE_STATE, + VehicleDataEndpoint.CLIMATE_STATE, + # VehicleDataEndpoint.CLOSURES_STATE, + VehicleDataEndpoint.DRIVE_STATE, + # VehicleDataEndpoint.GUI_SETTINGS, + VehicleDataEndpoint.LOCATION_DATA, + # VehicleDataEndpoint.VEHICLE_CONFIG, + VehicleDataEndpoint.VEHICLE_STATE, ] diff --git a/custom_components/teslemetry/cover.py b/custom_components/teslemetry/cover.py index e2a170b..64f91f8 100644 --- a/custom_components/teslemetry/cover.py +++ b/custom_components/teslemetry/cover.py @@ -3,7 +3,7 @@ from typing import Any -from tesla_fleet_api.const import WindowCommands, Trunks, Scopes +from tesla_fleet_api.const import WindowCommand, Trunk, Scope from homeassistant.components.cover import ( CoverDeviceClass, @@ -29,13 +29,13 @@ async def async_setup_entry( async_add_entities( klass(vehicle, any(scope in data.scopes for scope in scopes)) for (klass, scopes) in ( - (TeslemetryWindowEntity, [Scopes.VEHICLE_CMDS]), + (TeslemetryWindowEntity, [Scope.VEHICLE_CMDS]), ( TeslemetryChargePortEntity, - [Scopes.VEHICLE_CMDS, Scopes.VEHICLE_CHARGING_CMDS], + [Scope.VEHICLE_CMDS, Scope.VEHICLE_CHARGING_CMDS], ), - (TeslemetryFrontTrunkEntity, [Scopes.VEHICLE_CMDS]), - (TeslemetryRearTrunkEntity, [Scopes.VEHICLE_CMDS]), + (TeslemetryFrontTrunkEntity, [Scope.VEHICLE_CMDS]), + (TeslemetryRearTrunkEntity, [Scope.VEHICLE_CMDS]), ) for vehicle in data.vehicles ) @@ -73,7 +73,7 @@ async def async_open_cover(self, **kwargs: Any) -> None: self.raise_for_scope() with handle_command(): await self.wake_up_if_asleep() - await self.api.window_control(command=WindowCommands.VENT) + await self.api.window_control(command=WindowCommand.VENT) self.set( ("vehicle_state_fd_window", TeslemetryCoverStates.OPEN), ("vehicle_state_fp_window", TeslemetryCoverStates.OPEN), @@ -86,7 +86,7 @@ async def async_close_cover(self, **kwargs: Any) -> None: self.raise_for_scope() with handle_command(): await self.wake_up_if_asleep() - await self.api.window_control(command=WindowCommands.CLOSE) + await self.api.window_control(command=WindowCommand.CLOSE) self.set( ("vehicle_state_fd_window", TeslemetryCoverStates.CLOSED), ("vehicle_state_fp_window", TeslemetryCoverStates.CLOSED), diff --git a/custom_components/teslemetry/lock.py b/custom_components/teslemetry/lock.py index 5b3e4b7..58a7708 100644 --- a/custom_components/teslemetry/lock.py +++ b/custom_components/teslemetry/lock.py @@ -1,6 +1,6 @@ """Lock platform for Teslemetry integration.""" from __future__ import annotations -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from typing import Any from homeassistant.components.lock import LockEntity @@ -25,7 +25,7 @@ async def async_setup_entry( data = hass.data[DOMAIN][entry.entry_id] async_add_entities( - klass(vehicle, Scopes.VEHICLE_CMDS in data.scopes) + klass(vehicle, Scope.VEHICLE_CMDS in data.scopes) for klass in ( TeslemetryVehicleLockEntity, TeslemetryCableLockEntity, diff --git a/custom_components/teslemetry/media_player.py b/custom_components/teslemetry/media_player.py index fac9aab..778e2a5 100644 --- a/custom_components/teslemetry/media_player.py +++ b/custom_components/teslemetry/media_player.py @@ -1,6 +1,6 @@ """Media Player platform for Teslemetry integration.""" from __future__ import annotations -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from homeassistant.components.media_player import ( MediaPlayerDeviceClass, @@ -34,7 +34,7 @@ async def async_setup_entry( data = hass.data[DOMAIN][entry.entry_id] async_add_entities( - TeslemetryMediaEntity(vehicle, Scopes.VEHICLE_CMDS in data.scopes) + TeslemetryMediaEntity(vehicle, Scope.VEHICLE_CMDS in data.scopes) for vehicle in data.vehicles ) diff --git a/custom_components/teslemetry/models.py b/custom_components/teslemetry/models.py index 95fe00c..91bef4c 100644 --- a/custom_components/teslemetry/models.py +++ b/custom_components/teslemetry/models.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from tesla_fleet_api import EnergySpecific, VehicleSpecific -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from .coordinator import ( TeslemetryEnergySiteLiveCoordinator, @@ -20,7 +20,7 @@ class TeslemetryData: vehicles: list[TeslemetryVehicleData] energysites: list[TeslemetryEnergyData] - scopes: list[Scopes] + scopes: list[Scope] @dataclass diff --git a/custom_components/teslemetry/number.py b/custom_components/teslemetry/number.py index fe4705c..12eda85 100644 --- a/custom_components/teslemetry/number.py +++ b/custom_components/teslemetry/number.py @@ -5,7 +5,7 @@ from collections.abc import Callable from dataclasses import dataclass -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from homeassistant.components.number import ( NumberDeviceClass, @@ -42,7 +42,7 @@ class TeslemetryNumberEntityDescription(NumberEntityDescription): native_max_value: float min_key: str | None = None max_key: str | None = None - scopes: list[Scopes] | None = None + scopes: list[Scope] | None = None VEHICLE_DESCRIPTIONS: tuple[TeslemetryNumberEntityDescription, ...] = ( @@ -55,7 +55,7 @@ class TeslemetryNumberEntityDescription(NumberEntityDescription): device_class=NumberDeviceClass.CURRENT, max_key="charge_state_charge_current_request_max", func=lambda api, value: api.set_charging_amps(int(value)), - scopes=[Scopes.VEHICLE_CHARGING_CMDS], + scopes=[Scope.VEHICLE_CHARGING_CMDS], ), TeslemetryNumberEntityDescription( key="charge_state_charge_limit_soc", @@ -67,7 +67,7 @@ class TeslemetryNumberEntityDescription(NumberEntityDescription): min_key="charge_state_charge_limit_soc_min", max_key="charge_state_charge_limit_soc_max", func=lambda api, value: api.set_charge_limit(int(value)), - scopes=[Scopes.VEHICLE_CHARGING_CMDS, Scopes.VEHICLE_CMDS], + scopes=[Scope.VEHICLE_CHARGING_CMDS, Scope.VEHICLE_CMDS], ), TeslemetryNumberEntityDescription( key="vehicle_state_speed_limit_mode_current_limit_mph", @@ -80,7 +80,7 @@ class TeslemetryNumberEntityDescription(NumberEntityDescription): min_key="vehicle_state_speed_limit_mode_min_limit_mph", max_key="vehicle_state_speed_limit_mode_max_limit_mph", func=lambda api, value: api.speed_limit_set_limit(value), - scopes=[Scopes.VEHICLE_CMDS], + scopes=[Scope.VEHICLE_CMDS], ), ) @@ -92,7 +92,7 @@ class TeslemetryNumberEntityDescription(NumberEntityDescription): native_max_value=100, device_class=NumberDeviceClass.BATTERY, native_unit_of_measurement=PERCENTAGE, - scopes=[Scopes.ENERGY_CMDS], + scopes=[Scope.ENERGY_CMDS], func=lambda api, value: api.backup(int(value)), ), TeslemetryNumberEntityDescription( @@ -103,7 +103,7 @@ class TeslemetryNumberEntityDescription(NumberEntityDescription): native_max_value=100, device_class=NumberDeviceClass.BATTERY, native_unit_of_measurement=PERCENTAGE, - scopes=[Scopes.ENERGY_CMDS], + scopes=[Scope.ENERGY_CMDS], func=lambda api, value: api.off_grid_vehicle_charging_reserve(int(value)) ), ) diff --git a/custom_components/teslemetry/select.py b/custom_components/teslemetry/select.py index a376714..89340af 100644 --- a/custom_components/teslemetry/select.py +++ b/custom_components/teslemetry/select.py @@ -1,7 +1,7 @@ """Select platform for Teslemetry integration.""" from __future__ import annotations -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from dataclasses import dataclass from collections.abc import Callable @@ -61,7 +61,7 @@ async def async_setup_entry( entities = [] for vehicle in data.vehicles: - scoped = Scopes.VEHICLE_CMDS in data.scopes + scoped = Scope.VEHICLE_CMDS in data.scopes entities.append( TeslemetrySeatHeaterSelectEntity( vehicle, "climate_state_seat_heater_left", scoped @@ -105,7 +105,7 @@ async def async_setup_entry( if description.key in energysite.info_coordinator.data: entities.append( TeslemetryEnergySiteSelectEntity( - energysite, description, Scopes.ENERGY_CMDS in data.scopes + energysite, description, Scope.ENERGY_CMDS in data.scopes ) ) diff --git a/custom_components/teslemetry/switch.py b/custom_components/teslemetry/switch.py index 28529ad..220145e 100644 --- a/custom_components/teslemetry/switch.py +++ b/custom_components/teslemetry/switch.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from typing import Any -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from homeassistant.components.switch import ( SwitchDeviceClass, @@ -35,7 +35,7 @@ class TeslemetrySwitchEntityDescription(SwitchEntityDescription): on_func: Callable off_func: Callable - scopes: list[Scopes] | None = None + scopes: list[Scope] | None = None VEHICLE_DESCRIPTIONS: tuple[TeslemetrySwitchEntityDescription, ...] = ( @@ -43,31 +43,31 @@ class TeslemetrySwitchEntityDescription(SwitchEntityDescription): key="charge_state_charge_enable_request", on_func=lambda api: api.charge_start(), off_func=lambda api: api.charge_stop(), - scopes=[Scopes.VEHICLE_CMDS, Scopes.VEHICLE_CHARGING_CMDS], + scopes=[Scope.VEHICLE_CMDS, Scope.VEHICLE_CHARGING_CMDS], ), TeslemetrySwitchEntityDescription( key="vehicle_state_sentry_mode", on_func=lambda api: api.set_sentry_mode(on=True), off_func=lambda api: api.set_sentry_mode(on=False), - scopes=[Scopes.VEHICLE_CMDS], + scopes=[Scope.VEHICLE_CMDS], ), TeslemetrySwitchEntityDescription( key="vehicle_state_valet_mode", on_func=lambda api: api.set_valet_mode(on=True), off_func=lambda api: api.set_valet_mode(on=False), - scopes=[Scopes.VEHICLE_CMDS], + scopes=[Scope.VEHICLE_CMDS], ), TeslemetrySwitchEntityDescription( key="climate_state_auto_seat_climate_left", on_func=lambda api: api.remote_auto_seat_climate_request(0, True), off_func=lambda api: api.remote_auto_seat_climate_request(0, False), - scopes=[Scopes.VEHICLE_CMDS], + scopes=[Scope.VEHICLE_CMDS], ), TeslemetrySwitchEntityDescription( key="climate_state_auto_seat_climate_right", on_func=lambda api: api.remote_auto_seat_climate_request(1, True), off_func=lambda api: api.remote_auto_seat_climate_request(1, False), - scopes=[Scopes.VEHICLE_CMDS], + scopes=[Scope.VEHICLE_CMDS], ), TeslemetrySwitchEntityDescription( key="climate_state_auto_steering_wheel_heat", @@ -77,7 +77,7 @@ class TeslemetrySwitchEntityDescription(SwitchEntityDescription): off_func=lambda api: api.remote_auto_steering_wheel_heat_climate_request( on=False ), - scopes=[Scopes.VEHICLE_CMDS], + scopes=[Scope.VEHICLE_CMDS], ), ) @@ -89,7 +89,7 @@ class TeslemetrySwitchEntityDescription(SwitchEntityDescription): off_func=lambda api: api.grid_import_export( disallow_charge_from_grid_with_solar_installed=True ), - scopes=[Scopes.ENERGY_CMDS], + scopes=[Scope.ENERGY_CMDS], ) @@ -97,7 +97,7 @@ class TeslemetrySwitchEntityDescription(SwitchEntityDescription): key="storm_mode_enabled", on_func=lambda api: api.storm_mode(enabled=True), off_func=lambda api: api.storm_mode(enabled=False), - scopes=[Scopes.ENERGY_CMDS], + scopes=[Scope.ENERGY_CMDS], ) diff --git a/custom_components/teslemetry/update.py b/custom_components/teslemetry/update.py index 5d3e230..7fac13b 100644 --- a/custom_components/teslemetry/update.py +++ b/custom_components/teslemetry/update.py @@ -3,7 +3,7 @@ from typing import Any -from tesla_fleet_api.const import Scopes +from tesla_fleet_api.const import Scope from homeassistant.components.update import UpdateEntity, UpdateEntityFeature from homeassistant.config_entries import ConfigEntry @@ -23,7 +23,7 @@ async def async_setup_entry( data = hass.data[DOMAIN][entry.entry_id] async_add_entities( - TeslemetryUpdateEntity(vehicle, Scopes.VEHICLE_CMDS in data.scopes) + TeslemetryUpdateEntity(vehicle, Scope.VEHICLE_CMDS in data.scopes) for vehicle in data.vehicles )