diff --git a/custom_components/plugwise/__init__.py b/custom_components/plugwise/__init__.py index 15df260d1..d614207a1 100644 --- a/custom_components/plugwise/__init__.py +++ b/custom_components/plugwise/__init__.py @@ -1,20 +1,20 @@ -"""Plugwise beta for Home Assistant Core.""" +"""Plugwise platform for Home Assistant Core.""" from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant -from .const import CONF_USB_PATH +from .const import CONF_USB_PATH # pw-beta usb from .gateway import async_setup_entry_gw, async_unload_entry_gw -from .usb import async_setup_entry_usb, async_unload_entry_usb +from .usb import async_setup_entry_usb, async_unload_entry_usb # pw-beta usb async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Plugwise components from a config entry.""" if entry.data.get(CONF_HOST): return await async_setup_entry_gw(hass, entry) - if entry.data.get(CONF_USB_PATH): - return await async_setup_entry_usb(hass, entry) + if entry.data.get(CONF_USB_PATH): # pw-beta usb + return await async_setup_entry_usb(hass, entry) # pw-beta usb return False # pragma: no cover @@ -22,6 +22,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Unload the Plugwise components.""" if entry.data.get(CONF_HOST): return await async_unload_entry_gw(hass, entry) - if entry.data.get(CONF_USB_PATH): - return await async_unload_entry_usb(hass, entry) + if entry.data.get(CONF_USB_PATH): # pw-beta usb + return await async_unload_entry_usb(hass, entry) # pw-beta usb return False # pragma: no cover diff --git a/custom_components/plugwise/binary_sensor.py b/custom_components/plugwise/binary_sensor.py index 77d4966c9..c17028df5 100644 --- a/custom_components/plugwise/binary_sensor.py +++ b/custom_components/plugwise/binary_sensor.py @@ -10,7 +10,12 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback -from plugwise.nodes import PlugwiseNode +from plugwise.nodes import PlugwiseNode # pw-beta usb + +from .const import DOMAIN, LOGGER, SEVERITIES + +# isort: off +from .const import COORDINATOR, PW_TYPE # pw-beta from .const import ( ATTR_SCAN_DAYLIGHT_MODE, @@ -22,23 +27,21 @@ ATTR_SED_SLEEP_FOR, ATTR_SED_STAY_ACTIVE, CB_NEW_NODE, - COORDINATOR, - DOMAIN, - LOGGER, - PW_TYPE, SERVICE_USB_SCAN_CONFIG, SERVICE_USB_SCAN_CONFIG_SCHEMA, SERVICE_USB_SED_BATTERY_CONFIG, SERVICE_USB_SED_BATTERY_CONFIG_SCHEMA, - SEVERITIES, STICK, USB, USB_MOTION_ID, -) +) # pw-beta usb + +# isort: on + from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .models import PW_BINARY_SENSOR_TYPES, PlugwiseBinarySensorEntityDescription -from .usb import PlugwiseUSBEntity +from .usb import PlugwiseUSBEntity # pw-beta PARALLEL_UPDATES = 0 @@ -55,7 +58,7 @@ async def async_setup_entry( return await async_setup_entry_gateway(hass, config_entry, async_add_entities) -async def async_setup_entry_usb(hass, config_entry, async_add_entities): +async def async_setup_entry_usb(hass, config_entry, async_add_entities): # pw-beta """Set up Plugwise binary sensor based on config_entry.""" api_stick = hass.data[DOMAIN][config_entry.entry_id][STICK] platform = entity_platform.current_platform.get() @@ -150,8 +153,9 @@ def __init__( @property def is_on(self) -> bool | None: """Return true if the binary sensor is on.""" - # pw-beta: show Plugwise notifications as HA persistent notifications - if self._notification: + if ( + self._notification + ): # pw-beta: show Plugwise notifications as HA persistent notifications for notify_id, message in self._notification.items(): self.hass.components.persistent_notification.async_create( message, "Plugwise Notification:", f"{DOMAIN}.{notify_id}" @@ -172,16 +176,20 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None: if self.entity_description.key != "plugwise_notification": return None - attrs: dict[str, list[str]] = {} + # pw-beta adjustment with attrs is to only represent severities *with* content + # not all severities including those without content as empty lists + attrs: dict[str, list[str]] = {} # pw-beta Re-evaluate against Core self._notification = {} # pw-beta if notify := self.coordinator.data.gateway["notifications"]: - for notify_id, details in notify.items(): + for notify_id, details in notify.items(): # pw-beta uses notify_id for msg_type, msg in details.items(): msg_type = msg_type.lower() if msg_type not in SEVERITIES: msg_type = "other" # pragma: no cover - if f"{msg_type}_msg" not in attrs: + if ( + f"{msg_type}_msg" not in attrs + ): # pw-beta Re-evaluate against Core attrs[f"{msg_type}_msg"] = [] attrs[f"{msg_type}_msg"].append(msg) @@ -192,6 +200,7 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None: return attrs +# pw-beta # Github issue #265 class USBBinarySensor(PlugwiseUSBEntity, BinarySensorEntity): # type: ignore[misc] """Representation of a Plugwise USB Binary Sensor.""" diff --git a/custom_components/plugwise/climate.py b/custom_components/plugwise/climate.py index ba88d4995..b3a72110c 100644 --- a/custom_components/plugwise/climate.py +++ b/custom_components/plugwise/climate.py @@ -3,11 +3,11 @@ from typing import Any -from homeassistant.components.climate import ClimateEntity -from homeassistant.components.climate.const import ( +from homeassistant.components.climate import ( ATTR_HVAC_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, + ClimateEntity, ClimateEntityFeature, HVACAction, HVACMode, @@ -25,7 +25,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from .const import CONF_HOMEKIT_EMULATION # pw-beta homekit emulation -from .const import COORDINATOR, DOMAIN, MASTER_THERMOSTATS +from .const import COORDINATOR # pw-beta +from .const import DOMAIN, MASTER_THERMOSTATS from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .util import plugwise_command @@ -41,11 +42,14 @@ async def async_setup_entry( config_entry.entry_id ][COORDINATOR] - # pw-beta homekit emulation - homekit_enabled: bool = config_entry.options.get(CONF_HOMEKIT_EMULATION, False) + homekit_enabled: bool = config_entry.options.get( + CONF_HOMEKIT_EMULATION, False + ) # pw-beta homekit emulation async_add_entities( - PlugwiseClimateEntity(coordinator, device_id, homekit_enabled) + PlugwiseClimateEntity( + coordinator, device_id, homekit_enabled + ) # pw-beta homekit emulation for device_id, device in coordinator.data.devices.items() if device["dev_class"] in MASTER_THERMOSTATS ) @@ -91,9 +95,10 @@ def __init__( self._attr_min_temp = self.device["thermostat"]["lower_bound"] self._attr_max_temp = self.device["thermostat"]["upper_bound"] - if resolution := self.device["thermostat"]["resolution"]: - # Ensure we don't drop below 0.1 - self._attr_target_temperature_step = max(resolution, 0.1) + # Ensure we don't drop below 0.1 + self._attr_target_temperature_step = max( + self.device["thermostat"]["resolution"], 0.1 + ) @property def current_temperature(self) -> float: @@ -128,7 +133,9 @@ def target_temperature_low(self) -> float: @property def hvac_mode(self) -> HVACMode: """Return HVAC operation ie. auto, heat, heat_cool, or off mode.""" - if (mode := self.device["mode"]) is None or mode not in self.hvac_modes: + if ( + mode := self.device["mode"] + ) is None or mode not in self.hvac_modes: # pw-beta add to Core return HVACMode.HEAT # pragma: no cover # pw-beta homekit emulation if self._homekit_enabled and self._homekit_mode == HVACMode.OFF: @@ -137,7 +144,7 @@ def hvac_mode(self) -> HVACMode: return HVACMode(mode) @property - def hvac_action(self) -> HVACAction: + def hvac_action(self) -> HVACAction: # pw-beta add to Core """Return the current running hvac operation if supported.""" # When control_state is present, prefer this data if (control_state := self.device.get("control_state")) == "cooling": @@ -154,7 +161,7 @@ def hvac_action(self) -> HVACAction: ] if hc_data["binary_sensors"]["heating_state"]: return HVACAction.HEATING - if hc_data["binary_sensors"].get("cooling_state", False): + if hc_data["binary_sensors"].get("cooling_state", False): # pw-beta adds False return HVACAction.COOLING return HVACAction.IDLE @@ -167,8 +174,10 @@ def preset_mode(self) -> str | None: @plugwise_command async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" - if ATTR_HVAC_MODE in kwargs: - await self.async_set_hvac_mode(kwargs[ATTR_HVAC_MODE]) + if ATTR_HVAC_MODE in kwargs: # pw-beta add to Core + await self.async_set_hvac_mode( + kwargs[ATTR_HVAC_MODE] + ) # pw-beta add to Core data: dict[str, Any] = {} if ATTR_TEMPERATURE in kwargs: @@ -187,7 +196,7 @@ async def async_set_temperature(self, **kwargs: Any) -> None: await self.coordinator.api.set_temperature(self.device["location"], data) @plugwise_command - async def async_set_hvac_mode(self, hvac_mode: str) -> None: + async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set the hvac mode.""" if hvac_mode not in self.hvac_modes: raise HomeAssistantError("Unsupported hvac_mode") diff --git a/custom_components/plugwise/config_flow.py b/custom_components/plugwise/config_flow.py index f72a09503..28164bcb6 100644 --- a/custom_components/plugwise/config_flow.py +++ b/custom_components/plugwise/config_flow.py @@ -1,14 +1,14 @@ """Config flow for Plugwise integration.""" from __future__ import annotations -import datetime as dt # pw-beta +import datetime as dt # pw-beta options from typing import Any -import serial.tools.list_ports +import serial.tools.list_ports # pw-beta usb import voluptuous as vol from homeassistant import config_entries -from homeassistant.components import usb +from homeassistant.components import usb # pw-beta usb from homeassistant.components.zeroconf import ZeroconfServiceInfo from homeassistant.config_entries import ConfigEntry, ConfigFlow from homeassistant.const import ( @@ -29,47 +29,51 @@ InvalidAuthentication, InvalidSetupError, InvalidXMLError, - NetworkDown, - PortError, ResponseError, - StickInitError, - TimeoutException, UnsupportedDeviceError, ) + +# pw-beta Note; the below are explicit through isort +from plugwise.exceptions import NetworkDown # pw-beta usb +from plugwise.exceptions import PortError # pw-beta usb +from plugwise.exceptions import StickInitError # pw-beta usb +from plugwise.exceptions import TimeoutException # pw-beta usb from plugwise.smile import Smile -from plugwise.stick import Stick +from plugwise.stick import Stick # pw-beta usb from .const import ( API, - CONF_MANUAL_PATH, - CONF_USB_PATH, COORDINATOR, DEFAULT_PORT, DEFAULT_USERNAME, DOMAIN, - FLOW_NET, FLOW_SMILE, FLOW_STRETCH, - FLOW_TYPE, - FLOW_USB, PW_TYPE, SMILE, - STICK, STRETCH, STRETCH_USERNAME, ZEROCONF_MAP, ) + +# pw-beta Note; the below are explicit through isort from .const import CONF_HOMEKIT_EMULATION # pw-beta option +from .const import CONF_MANUAL_PATH # pw-beta usb from .const import CONF_REFRESH_INTERVAL # pw-beta option +from .const import CONF_USB_PATH # pw-beta usb from .const import DEFAULT_SCAN_INTERVAL # pw-beta option +from .const import FLOW_NET # pw-beta usb +from .const import FLOW_TYPE # pw-beta usb +from .const import FLOW_USB # pw-beta usb +from .const import STICK # pw-beta usb CONNECTION_SCHEMA = vol.Schema( {vol.Required(FLOW_TYPE, default=FLOW_NET): vol.In([FLOW_NET, FLOW_USB])} -) +) # pw-beta usb @callback -def plugwise_stick_entries(hass): +def plugwise_stick_entries(hass): # pw-beta usb """Return existing connections for Plugwise USB-stick domain.""" sticks = [] for entry in hass.config_entries.async_entries(DOMAIN): @@ -81,7 +85,9 @@ def plugwise_stick_entries(hass): # Github issue: #265 # Might be a `tuple[dict[str, str], Stick | None]` for typing, but that throws # Item None of Optional[Any] not having attribute mac [union-attr] -async def validate_usb_connection(self, device_path=None) -> tuple[dict[str, str], Any]: +async def validate_usb_connection( + self, device_path=None +) -> tuple[dict[str, str], Any]: # pw-beta usb """Test if device_path is a real Plugwise USB-Stick.""" errors = {} @@ -240,7 +246,7 @@ async def async_step_zeroconf( async def async_step_user_usb( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> FlowResult: # pw-beta usb """Step when user initializes a integration.""" errors: dict[str, str] = {} ports = await self.hass.async_add_executor_job(serial.tools.list_ports.comports) @@ -278,7 +284,7 @@ async def async_step_user_usb( async def async_step_manual_path( self, user_input: dict[str, Any] | None = None - ) -> FlowResult: + ) -> FlowResult: # pw-beta usb """Step when manual path to device.""" errors: dict[str, str] = {} if user_input is not None: @@ -369,10 +375,11 @@ async def async_step_user( errors=errors, ) - # pw-beta @staticmethod @callback - def async_get_options_flow(config_entry: ConfigEntry) -> config_entries.OptionsFlow: + def async_get_options_flow( + config_entry: ConfigEntry, + ) -> config_entries.OptionsFlow: # pw-beta options """Get the options flow for this handler.""" return PlugwiseOptionsFlowHandler(config_entry) @@ -380,7 +387,7 @@ def async_get_options_flow(config_entry: ConfigEntry) -> config_entries.OptionsF # pw-beta - change the scan-interval via CONFIGURE # pw-beta - add homekit emulation via CONFIGURE # pw-beta - change the frontend refresh interval via CONFIGURE -class PlugwiseOptionsFlowHandler(config_entries.OptionsFlow): +class PlugwiseOptionsFlowHandler(config_entries.OptionsFlow): # pw-beta options """Plugwise option flow.""" def __init__(self, config_entry: ConfigEntry) -> None: # pragma: no cover @@ -410,7 +417,7 @@ async def async_step_init( coordinator = self.hass.data[DOMAIN][self.config_entry.entry_id][COORDINATOR] interval: dt.timedelta = DEFAULT_SCAN_INTERVAL[ coordinator.api.smile_type - ] # pw-beta + ] # pw-beta options data = { vol.Optional( diff --git a/custom_components/plugwise/const.py b/custom_components/plugwise/const.py index 90417e06f..343a835da 100644 --- a/custom_components/plugwise/const.py +++ b/custom_components/plugwise/const.py @@ -1,9 +1,9 @@ -"""Constants for Plugwise beta component.""" +"""Constants for Plugwise component.""" from datetime import timedelta import logging from typing import Final -import voluptuous as vol +import voluptuous as vol # pw-beta usb from homeassistant.const import Platform from homeassistant.helpers import config_validation as cv @@ -14,8 +14,8 @@ API: Final = "api" COORDINATOR: Final = "coordinator" -CONF_HOMEKIT_EMULATION: Final = "homekit_emulation" # pw-beta -CONF_REFRESH_INTERVAL: Final = "refresh_interval" # pw-beta +CONF_HOMEKIT_EMULATION: Final = "homekit_emulation" # pw-beta options +CONF_REFRESH_INTERVAL: Final = "refresh_interval" # pw-beta options CONF_MANUAL_PATH: Final = "Enter Manually" GATEWAY: Final = "gateway" PW_TYPE: Final = "plugwise_type" @@ -160,7 +160,7 @@ SERVICE_USB_DEVICE_REMOVE: Final = "device_remove" SERVICE_USB_DEVICE_SCHEMA: Final = vol.Schema( {vol.Required(ATTR_MAC_ADDRESS): cv.string} -) +) # pw-beta usb # USB Relay device constants diff --git a/custom_components/plugwise/coordinator.py b/custom_components/plugwise/coordinator.py index fc90166e8..0e88515f1 100644 --- a/custom_components/plugwise/coordinator.py +++ b/custom_components/plugwise/coordinator.py @@ -3,13 +3,8 @@ from typing import NamedTuple, cast from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - CONF_HOST, - CONF_PASSWORD, - CONF_PORT, - CONF_SCAN_INTERVAL, - CONF_USERNAME, -) +from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME +from homeassistant.const import CONF_SCAN_INTERVAL # pw-beta options from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryError from homeassistant.helpers.aiohttp_client import async_get_clientsession @@ -25,7 +20,6 @@ UnsupportedDeviceError, ) -# pw-beta - for core compat should import DEFAULT_SCAN_INTERVAL from .const import DEFAULT_PORT, DEFAULT_SCAN_INTERVAL, DEFAULT_USERNAME, DOMAIN, LOGGER @@ -43,7 +37,7 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]): def __init__( self, hass: HomeAssistant, entry: ConfigEntry, cooldown: float - ) -> None: + ) -> None: # pw-beta cooldown """Initialize the coordinator.""" super().__init__( hass, @@ -78,16 +72,15 @@ async def _connect(self) -> None: self.api.get_all_devices() self.name = self.api.smile_name - # pw-beta scan-interval self.update_interval = DEFAULT_SCAN_INTERVAL.get( self.api.smile_type, timedelta(seconds=60) - ) + ) # pw-beta options scan-interval if (custom_time := self._entry.options.get(CONF_SCAN_INTERVAL)) is not None: self.update_interval = timedelta( seconds=int(custom_time) - ) # pragma: no cover + ) # pragma: no cover # pw-beta options - LOGGER.debug("DUC update interval: %s", self.update_interval) + LOGGER.debug("DUC update interval: %s", self.update_interval) # pw-beta options async def _async_update_data(self) -> PlugwiseData: """Fetch data from Plugwise.""" @@ -101,21 +94,21 @@ async def _async_update_data(self) -> PlugwiseData: if self._unavailable_logged: self._unavailable_logged = False except InvalidAuthentication as err: - if not self._unavailable_logged: + if not self._unavailable_logged: # pw-beta add to Core self._unavailable_logged = True raise ConfigEntryError("Authentication failed") from err except (InvalidXMLError, ResponseError) as err: - if not self._unavailable_logged: + if not self._unavailable_logged: # pw-beta add to Core self._unavailable_logged = True raise UpdateFailed( "Invalid XML data, or error indication received from the Plugwise Adam/Smile/Stretch" ) from err except UnsupportedDeviceError as err: - if not self._unavailable_logged: + if not self._unavailable_logged: # pw-beta add to Core self._unavailable_logged = True raise ConfigEntryError("Device with unsupported firmware") from err except ConnectionFailedError as err: - if not self._unavailable_logged: + if not self._unavailable_logged: # pw-beta add to Core self._unavailable_logged = True raise UpdateFailed("Failed to connect") from err diff --git a/custom_components/plugwise/diagnostics.py b/custom_components/plugwise/diagnostics.py index 2b79d22f6..fc00e6772 100644 --- a/custom_components/plugwise/diagnostics.py +++ b/custom_components/plugwise/diagnostics.py @@ -6,7 +6,8 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant -from .const import COORDINATOR, DOMAIN +from .const import COORDINATOR # pw-beta +from .const import DOMAIN from .coordinator import PlugwiseDataUpdateCoordinator diff --git a/custom_components/plugwise/gateway.py b/custom_components/plugwise/gateway.py index 4d060adb1..9e079f36f 100644 --- a/custom_components/plugwise/gateway.py +++ b/custom_components/plugwise/gateway.py @@ -1,4 +1,4 @@ -"""Plugwise network/gateway platform.""" +"""Plugwise platform for Home Assistant Core.""" from __future__ import annotations from typing import Any @@ -22,7 +22,7 @@ SERVICE_DELETE, UNDO_UPDATE_LISTENER, ) -from .const import CONF_REFRESH_INTERVAL # pw-beta +from .const import CONF_REFRESH_INTERVAL # pw-beta options from .coordinator import PlugwiseDataUpdateCoordinator @@ -30,22 +30,21 @@ async def async_setup_entry_gw(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Plugwise Smiles from a config entry.""" await er.async_migrate_entries(hass, entry.entry_id, async_migrate_entity_entry) - # pw-beta frontend refresh-interval - cooldown = 1.5 + cooldown = 1.5 # pw-beta frontend refresh-interval if ( custom_refresh := entry.options.get(CONF_REFRESH_INTERVAL) ) is not None: # pragma: no cover cooldown = custom_refresh LOGGER.debug("DUC cooldown interval: %s", cooldown) - # pw-beta - cooldown, update_interval as extra - coordinator = PlugwiseDataUpdateCoordinator(hass, entry, cooldown) + coordinator = PlugwiseDataUpdateCoordinator( + hass, entry, cooldown + ) # pw-beta - cooldown, update_interval as extra await coordinator.async_config_entry_first_refresh() # Migrate a changed sensor unique_id - migrate_sensor_entity(hass, coordinator) + migrate_sensor_entities(hass, coordinator) - # pw-beta - undo_listener = entry.add_update_listener(_update_listener) + undo_listener = entry.add_update_listener(_update_listener) # pw-beta hass.data.setdefault(DOMAIN, {})[entry.entry_id] = { COORDINATOR: coordinator, # pw-beta @@ -63,8 +62,9 @@ async def async_setup_entry_gw(hass: HomeAssistant, entry: ConfigEntry) -> bool: sw_version=coordinator.api.smile_version[0], ) - # pw-beta: HA service - delete_notification - async def delete_notification(self): # pragma: no cover + async def delete_notification( + self, + ): # pragma: no cover # pw-beta: HA service - delete_notification """Service: delete the Plugwise Notification.""" LOGGER.debug( "Service delete PW Notification called for %s", coordinator.api.smile_name @@ -80,8 +80,7 @@ async def delete_notification(self): # pragma: no cover await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS_GATEWAY) - # pw-beta - for component in PLATFORMS_GATEWAY: + for component in PLATFORMS_GATEWAY: # pw-beta if component == Platform.BINARY_SENSOR: hass.services.async_register( DOMAIN, SERVICE_DELETE, delete_notification, schema=vol.Schema({}) @@ -90,8 +89,9 @@ async def delete_notification(self): # pragma: no cover return True -# pw-beta -async def _update_listener(hass: HomeAssistant, entry: ConfigEntry): # pragma: no cover +async def _update_listener( + hass: HomeAssistant, entry: ConfigEntry +): # pragma: no cover # pw-beta """Handle options update.""" await hass.config_entries.async_reload(entry.entry_id) @@ -118,17 +118,17 @@ def async_migrate_entity_entry(entry: er.RegistryEntry) -> dict[str, Any] | None return None -def migrate_sensor_entity( +def migrate_sensor_entities( hass: HomeAssistant, coordinator: PlugwiseDataUpdateCoordinator, ) -> None: """Migrate Sensors if needed.""" ent_reg = er.async_get(hass) - # Migrate opentherm_outdoor_temperature + # Migrate opentherm_outdoor_temperature # pw-beta add to Core # to opentherm_outdoor_air_temperature sensor for device_id, device in coordinator.data.devices.items(): - if device["dev_class"] != "heater_central": + if device["dev_class"] != "heater_central": # pw-beta add to Core continue old_unique_id = f"{device_id}-outdoor_temperature" diff --git a/custom_components/plugwise/number.py b/custom_components/plugwise/number.py index e3a047fb3..fac686264 100644 --- a/custom_components/plugwise/number.py +++ b/custom_components/plugwise/number.py @@ -16,7 +16,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise import Smile -from .const import COORDINATOR, DOMAIN, LOGGER +from .const import COORDINATOR # pw-beta +from .const import DOMAIN, LOGGER from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity diff --git a/custom_components/plugwise/select.py b/custom_components/plugwise/select.py index ecdbaf771..5001caa3b 100644 --- a/custom_components/plugwise/select.py +++ b/custom_components/plugwise/select.py @@ -12,7 +12,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise import Smile -from .const import COORDINATOR, DOMAIN, LOGGER +from .const import COORDINATOR # pw-beta +from .const import DOMAIN, LOGGER from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity diff --git a/custom_components/plugwise/sensor.py b/custom_components/plugwise/sensor.py index 42554d6ea..5be6e0691 100644 --- a/custom_components/plugwise/sensor.py +++ b/custom_components/plugwise/sensor.py @@ -8,11 +8,21 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import CB_NEW_NODE, COORDINATOR, DOMAIN, LOGGER, PW_TYPE, STICK, USB +from .const import DOMAIN, LOGGER + +# isort: off +from .const import COORDINATOR, PW_TYPE # pw-beta +from .const import ( + CB_NEW_NODE, + STICK, + USB, +) # pw-beta usb + +# isort: on from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .models import PW_SENSOR_TYPES, PlugwiseSensorEntityDescription -from .usb import PlugwiseUSBEntity +from .usb import PlugwiseUSBEntity # pw-beta usb PARALLEL_UPDATES = 0 @@ -23,13 +33,13 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Set up the Smile switches from a config entry.""" - if hass.data[DOMAIN][config_entry.entry_id][PW_TYPE] == USB: + if hass.data[DOMAIN][config_entry.entry_id][PW_TYPE] == USB: # pw-beta usb return await async_setup_entry_usb(hass, config_entry, async_add_entities) # Considered default and for earlier setups without usb/network config_flow return await async_setup_entry_gateway(hass, config_entry, async_add_entities) -async def async_setup_entry_usb(hass, config_entry, async_add_entities): +async def async_setup_entry_usb(hass, config_entry, async_add_entities): # pw-beta usb """Set up Plugwise sensor based on config_entry.""" api_stick = hass.data[DOMAIN][config_entry.entry_id][STICK] @@ -108,7 +118,7 @@ def native_value(self) -> int | float | None: # Github issue #265 -class USBSensor(PlugwiseUSBEntity, SensorEntity): # type: ignore[misc] +class USBSensor(PlugwiseUSBEntity, SensorEntity): # type: ignore[misc] # pw-beta usb """Representation of a Plugwise USB sensor.""" def __init__( diff --git a/custom_components/plugwise/switch.py b/custom_components/plugwise/switch.py index 9cbc63be3..f25b67b6e 100644 --- a/custom_components/plugwise/switch.py +++ b/custom_components/plugwise/switch.py @@ -10,11 +10,22 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import CB_NEW_NODE, COORDINATOR, DOMAIN, LOGGER, PW_TYPE, SMILE, STICK, USB +from .const import DOMAIN, LOGGER + +# isort: off +from .const import COORDINATOR, PW_TYPE # pw-beta +from .const import ( + CB_NEW_NODE, + SMILE, + STICK, + USB, +) + +# isort: on from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .models import PW_SWITCH_TYPES, PlugwiseSwitchEntityDescription -from .usb import PlugwiseUSBEntity +from .usb import PlugwiseUSBEntity # pw-beta usb from .util import plugwise_command @@ -24,13 +35,13 @@ async def async_setup_entry( async_add_entities: AddEntitiesCallback, ) -> None: """Set up the Smile switches from a config entry.""" - if hass.data[DOMAIN][config_entry.entry_id][PW_TYPE] == USB: + if hass.data[DOMAIN][config_entry.entry_id][PW_TYPE] == USB: # pw-beta usb return await async_setup_entry_usb(hass, config_entry, async_add_entities) # Considered default and for earlier setups without usb/network config_flow return await async_setup_entry_gateway(hass, config_entry, async_add_entities) -async def async_setup_entry_usb(hass, config_entry, async_add_entities): +async def async_setup_entry_usb(hass, config_entry, async_add_entities): # pw-beta usb """Set up the USB switches from a config entry.""" api_stick = hass.data[DOMAIN][config_entry.entry_id][STICK] @@ -121,7 +132,7 @@ async def async_turn_off(self, **kwargs: Any) -> None: # Github issue #265 -class USBSwitch(PlugwiseUSBEntity, SwitchEntity): # type: ignore[misc] +class USBSwitch(PlugwiseUSBEntity, SwitchEntity): # type: ignore[misc] # pw-beta usb """Representation of a Stick Node switch.""" def __init__(