Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Autoformat all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Prior99 committed Sep 10, 2024
1 parent 147f2d6 commit 021c4f6
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lint:
poetry run ruff check .
poetry run ruff format . --dif
poetry run ruff format . --diff
poetry run mypy .

2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

Expand Down
1 change: 0 additions & 1 deletion authorization.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,5 @@ async def idk_authorize(
)



class InternalAuthorizationError(HomeAssistantError):
"""Error to indicate that something unexpected happened during authorization."""
2 changes: 1 addition & 1 deletion climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(
hass: HomeAssistant,
config: ConfigEntry,
Expand Down Expand Up @@ -133,4 +134,3 @@ async def async_set_temperature(self, **kwargs): # noqa: D102
break
await self.coordinator.async_refresh()
_LOGGER.info("AC disabled.")

24 changes: 14 additions & 10 deletions myskoda.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Contains API representation for the MySkoda REST API."""

from asyncio import gather
from datetime import datetime
import logging
Expand Down Expand Up @@ -158,16 +160,16 @@ class Position:
lat: float
lng: float

def __init__(self, dict): # noqa: D107
dict = dict.get("positions")[0]
self.city = dict.get("address", {}).get("city")
self.country = dict.get("address", {}).get("country")
self.country_code = dict.get("address", {}).get("countryCode")
self.house_number = dict.get("address", {}).get("houseNumber")
self.street = dict.get("address", {}).get("street")
self.zip_code = dict.get("address", {}).get("zipCode")
self.lat = dict.get("gpsCoordinates", {}).get("latitude")
self.lng = dict.get("gpsCoordinates", {}).get("longitude")
def __init__(self, data): # noqa: D107
data = data.get("positions")[0]
self.city = data.get("address", {}).get("city")
self.country = data.get("address", {}).get("country")
self.country_code = data.get("address", {}).get("countryCode")
self.house_number = data.get("address", {}).get("houseNumber")
self.street = data.get("address", {}).get("street")
self.zip_code = data.get("address", {}).get("zipCode")
self.lat = data.get("gpsCoordinates", {}).get("latitude")
self.lng = data.get("gpsCoordinates", {}).get("longitude")


class Health:
Expand Down Expand Up @@ -207,6 +209,8 @@ def __init__( # noqa: D107


class MySkodaHub:
"""API hub class that can perform all calls to the MySkoda API."""

session: ClientSession
idk_session: IDKSession

Expand Down
3 changes: 2 additions & 1 deletion number.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(
hass: HomeAssistant,
config: ConfigEntry,
Expand Down Expand Up @@ -93,7 +94,7 @@ def native_value(self) -> float | None:

async def async_set_native_value(self, value: float): # noqa: D102
await self.coordinator.hub.set_charge_limit(self.vehicle.info.vin, value)
for i in range(0, 10):
for _ in range(10):
await sleep(15)
if self.native_value == value:
break
Expand Down
3 changes: 1 addition & 2 deletions sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,7 @@ def icon(self):

if self.vehicle.charging.charge_type == "AC":
return "mdi:ev-plug-type2"
else:
return "mdi:ev-plug-ccs2"
return "mdi:ev-plug-ccs2"


class ChargingState(MySkodaSensor):
Expand Down
23 changes: 15 additions & 8 deletions switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ async def async_turn_off(self, **kwargs): # noqa: D102
await self.coordinator.async_refresh()
_LOGGER.debug("Window heating disabled.")

async def async_turn_on(self, **kwargs): #noqa: D102
async def async_turn_on(self, **kwargs): # noqa: D102
await self.coordinator.hub.start_window_heating(self.vehicle.info.vin)
for _ in range(10):
await sleep(15)
Expand All @@ -104,6 +104,7 @@ async def async_turn_on(self, **kwargs): #noqa: D102
await self.coordinator.async_refresh()
_LOGGER.debug("Window heating enabled.")


class BatteryCareMode(MySkodaSwitch):
"""Controls battery care mode."""

Expand Down Expand Up @@ -139,7 +140,7 @@ async def async_turn_off(self, **kwargs): # noqa: D102 # noqa: D102
await self.coordinator.async_refresh()
_LOGGER.info("Battery care mode disabled.")

async def async_turn_on(self, **kwargs): #noqa: D102
async def async_turn_on(self, **kwargs): # noqa: D102
await self.coordinator.hub.set_battery_care_mode(self.vehicle.info.vin, True)
for _ in range(10):
await sleep(15)
Expand All @@ -148,6 +149,7 @@ async def async_turn_on(self, **kwargs): #noqa: D102
await self.coordinator.async_refresh()
_LOGGER.info("Battery care mode enabled.")


class ReducedCurrent(MySkodaSwitch):
"""Control whether to charge with reduced current."""

Expand All @@ -174,24 +176,29 @@ def is_on(self) -> bool | None:

return self.vehicle.charging.use_reduced_current

async def async_turn_off(self, **kwargs): # noqa: D102
await self.coordinator.hub.set_reduced_current_limit(self.vehicle.info.vin, False)
async def async_turn_off(self, **kwargs): # noqa: D102
await self.coordinator.hub.set_reduced_current_limit(
self.vehicle.info.vin, False
)
for _ in range(10):
await sleep(15)
if not self.is_on:
break
await self.coordinator.async_refresh()
_LOGGER.info("Reduced current limit disabled.")

async def async_turn_on(self, **kwargs): #noqa: D102
await self.coordinator.hub.set_reduced_current_limit(self.vehicle.info.vin, True)
async def async_turn_on(self, **kwargs): # noqa: D102
await self.coordinator.hub.set_reduced_current_limit(
self.vehicle.info.vin, True
)
for _ in range(10):
await sleep(15)
if self.is_on:
break
await self.coordinator.async_refresh()
_LOGGER.info("Reduced current limit enabled.")


class Charging(MySkodaSwitch):
"""Control whether the vehicle should be charging."""

Expand All @@ -218,7 +225,7 @@ def is_on(self) -> bool | None:

return self.vehicle.charging.state == "CHARGING"

async def async_turn_off(self, **kwargs): # noqa: D102
async def async_turn_off(self, **kwargs): # noqa: D102
await self.coordinator.hub.stop_charging(self.vehicle.info.vin)
for _ in range(10):
await sleep(15)
Expand All @@ -227,7 +234,7 @@ async def async_turn_off(self, **kwargs): # noqa: D102
await self.coordinator.async_refresh()
_LOGGER.info("Charging stopped.")

async def async_turn_on(self, **kwargs): #noqa: D102
async def async_turn_on(self, **kwargs): # noqa: D102
await self.coordinator.hub.start_charging(self.vehicle.info.vin)
for _ in range(10):
await sleep(15)
Expand Down

0 comments on commit 021c4f6

Please sign in to comment.