diff --git a/custom_components/fordpass/__init__.py b/custom_components/fordpass/__init__.py index 9c20156..26a3aba 100644 --- a/custom_components/fordpass/__init__.py +++ b/custom_components/fordpass/__init__.py @@ -16,7 +16,7 @@ UpdateFailed, ) -from .const import DOMAIN, MANUFACTURER, VEHICLE, VIN, DEFAULT_UNIT, CONF_UNIT +from .const import CONF_UNIT, DEFAULT_UNIT, DOMAIN, MANUFACTURER, VEHICLE, VIN from .fordpass_new import Vehicle CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA) @@ -72,14 +72,8 @@ async def async_refresh_status_service(service_call): async def async_update_options(hass, config_entry): - options = { - CONF_UNIT: entry.data.get( - CONF_UNIT, DEFAULT_UNIT - ) - } - hass.config_entries.async_update_entry( - config_entry, options=options - ) + options = {CONF_UNIT: config_entry.data.get(CONF_UNIT, DEFAULT_UNIT)} + hass.config_entries.async_update_entry(config_entry, options=options) def refresh_status(service, hass, coordinator): diff --git a/custom_components/fordpass/config_flow.py b/custom_components/fordpass/config_flow.py index f5206e8..2828c14 100644 --- a/custom_components/fordpass/config_flow.py +++ b/custom_components/fordpass/config_flow.py @@ -6,9 +6,13 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME from homeassistant.core import callback - -from .const import DOMAIN, VIN, CONF_UNITS, CONF_UNIT, DEFAULT_UNIT # pylint:disable=unused-import - +from .const import ( # pylint:disable=unused-import + CONF_UNIT, + CONF_UNITS, + DEFAULT_UNIT, + DOMAIN, + VIN, +) from .fordpass_new import Vehicle _LOGGER = logging.getLogger(__name__) @@ -75,29 +79,23 @@ def async_get_options_flow(config_entry): """Get the options flow for this handler.""" return OptionsFlow(config_entry) -class OptionsFlow(config_entries.OptionsFlow): +class OptionsFlow(config_entries.OptionsFlow): def __init__(self, config_entry: config_entries.ConfigEntry): """Initialize options flow.""" self.config_entry = config_entry - async def async_step_init(self, user_input=None): if user_input is not None: return self.async_create_entry(title="", data=user_input) options = { vol.Optional( CONF_UNIT, - default=self.config_entry.options.get( - CONF_UNIT, DEFAULT_UNIT - ), + default=self.config_entry.options.get(CONF_UNIT, DEFAULT_UNIT), ): vol.In(CONF_UNITS) } - return self.async_show_form( - step_id="init", data_schema=vol.Schema(options) - ) - + return self.async_show_form(step_id="init", data_schema=vol.Schema(options)) class CannotConnect(exceptions.HomeAssistantError): diff --git a/custom_components/fordpass/const.py b/custom_components/fordpass/const.py index cecaa8e..2fcc0cd 100644 --- a/custom_components/fordpass/const.py +++ b/custom_components/fordpass/const.py @@ -11,7 +11,4 @@ DEFAULT_UNIT = "metric" CONF_UNIT = "units" -CONF_UNITS = [ - "imperial", - "metric" -] \ No newline at end of file +CONF_UNITS = ["imperial", "metric"] diff --git a/custom_components/fordpass/lock.py b/custom_components/fordpass/lock.py index 9f039cd..eff6e46 100644 --- a/custom_components/fordpass/lock.py +++ b/custom_components/fordpass/lock.py @@ -22,7 +22,11 @@ class Lock(FordPassEntity, LockEntity): def __init__(self, coordinator): """Initialize.""" - super().__init__(device_id="fordpass_doorlock", name="fordpass_doorlock", coordinator=coordinator) + super().__init__( + device_id="fordpass_doorlock", + name="fordpass_doorlock", + coordinator=coordinator, + ) async def async_lock(self, **kwargs): """Locks the vehicle.""" diff --git a/custom_components/fordpass/sensor.py b/custom_components/fordpass/sensor.py index 1cdf8fa..3763531 100644 --- a/custom_components/fordpass/sensor.py +++ b/custom_components/fordpass/sensor.py @@ -5,7 +5,7 @@ from homeassistant.util import Throttle from . import FordPassEntity -from .const import DOMAIN, CONF_UNIT +from .const import CONF_UNIT, DOMAIN _LOGGER = logging.getLogger(__name__) @@ -31,7 +31,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities): async_add_entities([CarSensor(entry, snr, config_entry.options)], True) -class CarSensor(FordPassEntity, Entity,): +class CarSensor( + FordPassEntity, + Entity, +): def __init__(self, coordinator, sensor, options): self.sensor = sensor @@ -44,7 +47,9 @@ def get_value(self, ftype): if ftype == "state": if self.sensor == "odometer": if self.options[CONF_UNIT] == "imperial": - return round(float(self.coordinator.data[self.sensor]["value"]) / 1.60934) + return round( + float(self.coordinator.data[self.sensor]["value"]) / 1.60934 + ) else: return self.coordinator.data[self.sensor]["value"] elif self.sensor == "fuel": diff --git a/info.md b/info.md index 8a14f01..06b5b30 100644 --- a/info.md +++ b/info.md @@ -4,7 +4,7 @@ - Added device_tracker type (fordpass_tracker) - Added imperial or metric selection - Change fuel reading to % -- Renamed lock entity from "lock.lock" to "lock.fordpass_lock" +- Renamed lock entity from "lock.lock" to "lock.fordpass_doorlock" ### Version 1.04