From 21a617b3ae63387f6dc1c40924d5dfadcb7ec537 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 12:07:00 +0100 Subject: [PATCH 01/21] First batch of core-vs-beta --- custom_components/plugwise/__init__.py | 12 ++--- custom_components/plugwise/binary_sensor.py | 56 +++++++++------------ custom_components/plugwise/climate.py | 45 +++++++++++------ 3 files changed, 61 insertions(+), 52 deletions(-) diff --git a/custom_components/plugwise/__init__.py b/custom_components/plugwise/__init__.py index 15df260d1..ffee7debe 100644 --- a/custom_components/plugwise/__init__.py +++ b/custom_components/plugwise/__init__.py @@ -4,17 +4,17 @@ 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 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 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 + return await async_setup_entry_usb(hass, entry) # pw-beta 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 + return await async_unload_entry_usb(hass, entry) # pw-beta return False # pragma: no cover diff --git a/custom_components/plugwise/binary_sensor.py b/custom_components/plugwise/binary_sensor.py index 77d4966c9..7685119ec 100644 --- a/custom_components/plugwise/binary_sensor.py +++ b/custom_components/plugwise/binary_sensor.py @@ -12,33 +12,27 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import ( - ATTR_SCAN_DAYLIGHT_MODE, - ATTR_SCAN_RESET_TIMER, - ATTR_SCAN_SENSITIVITY_MODE, - ATTR_SED_CLOCK_INTERVAL, - ATTR_SED_CLOCK_SYNC, - ATTR_SED_MAINTENANCE_INTERVAL, - 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, -) +from .const import ATTR_SCAN_DAYLIGHT_MODE # pw-beta +from .const import ATTR_SCAN_RESET_TIMER # pw-beta +from .const import ATTR_SCAN_SENSITIVITY_MODE # pw-beta +from .const import ATTR_SED_CLOCK_INTERVAL # pw-beta +from .const import ATTR_SED_CLOCK_SYNC # pw-beta +from .const import ATTR_SED_MAINTENANCE_INTERVAL # pw-beta +from .const import ATTR_SED_SLEEP_FOR # pw-beta +from .const import ATTR_SED_STAY_ACTIVE # pw-beta +from .const import CB_NEW_NODE # pw-beta +from .const import COORDINATOR, DOMAIN, LOGGER, SEVERITIES, STICK +from .const import PW_TYPE # pw-beta +from .const import SERVICE_USB_SCAN_CONFIG # pw-beta +from .const import SERVICE_USB_SCAN_CONFIG_SCHEMA # pw-beta +from .const import SERVICE_USB_SED_BATTERY_CONFIG # pw-beta +from .const import SERVICE_USB_SED_BATTERY_CONFIG_SCHEMA # pw-beta +from .const import USB # pw-beta +from .const import USB_MOTION_ID # pw-beta 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 +49,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 +144,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,17 +167,15 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None: if self.entity_description.key != "plugwise_notification": return None - attrs: dict[str, list[str]] = {} + attrs: dict[str, list[str]] = {f"{severity}_msg": [] for severity in SEVERITIES} 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: - attrs[f"{msg_type}_msg"] = [] attrs[f"{msg_type}_msg"].append(msg) self._notification[ @@ -192,6 +185,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..df33614fb 100644 --- a/custom_components/plugwise/climate.py +++ b/custom_components/plugwise/climate.py @@ -1,13 +1,14 @@ """Plugwise Climate component for Home Assistant.""" from __future__ import annotations +from collections.abc import Mapping 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 +26,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 +43,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 ) @@ -66,6 +71,7 @@ def __init__( ) -> None: """Set up the Plugwise API.""" super().__init__(coordinator, device_id) + self._attr_extra_state_attributes = {} self._homekit_enabled = homekit_enabled # pw-beta homekit emulation self._homekit_mode: str | None = None # pw-beta homekit emulation self._attr_unique_id = f"{device_id}-climate" @@ -91,9 +97,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 +135,7 @@ 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.get("mode")) is None or mode not in self.hvac_modes: 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 | None: """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,11 +161,19 @@ 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 + @property + def extra_state_attributes(self) -> Mapping[str, Any] | None: + """Return entity specific state attributes.""" + return { + "available_schemas": self.device["available_schedules"], + "selected_schema": self.device["selected_schedule"], + } + @property def preset_mode(self) -> str | None: """Return the current preset mode.""" @@ -167,8 +182,8 @@ 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 + await self.async_set_hvac_mode(kwargs[ATTR_HVAC_MODE]) # pw-beta data: dict[str, Any] = {} if ATTR_TEMPERATURE in kwargs: @@ -187,7 +202,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") From 570fd43d438291c3b335555f05382ab451ecc111 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 12:18:40 +0100 Subject: [PATCH 02/21] Improve tagging --- custom_components/plugwise/__init__.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/custom_components/plugwise/__init__.py b/custom_components/plugwise/__init__.py index ffee7debe..dbc4065c5 100644 --- a/custom_components/plugwise/__init__.py +++ b/custom_components/plugwise/__init__.py @@ -4,17 +4,17 @@ from homeassistant.const import CONF_HOST from homeassistant.core import HomeAssistant -from .const import CONF_USB_PATH # pw-beta +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 # pw-beta +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): # pw-beta - return await async_setup_entry_usb(hass, entry) # pw-beta + 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): # pw-beta - return await async_unload_entry_usb(hass, entry) # pw-beta + 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 From 9197fb2ceff21ea67a75dae809dcbf2eb29cc5cc Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 13:36:13 +0100 Subject: [PATCH 03/21] Revert according to comments, more explicit tags --- custom_components/plugwise/climate.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/custom_components/plugwise/climate.py b/custom_components/plugwise/climate.py index df33614fb..4a5eb5de2 100644 --- a/custom_components/plugwise/climate.py +++ b/custom_components/plugwise/climate.py @@ -1,7 +1,6 @@ """Plugwise Climate component for Home Assistant.""" from __future__ import annotations -from collections.abc import Mapping from typing import Any from homeassistant.components.climate import ( @@ -144,7 +143,7 @@ def hvac_mode(self) -> HVACMode: return HVACMode(mode) @property - def hvac_action(self) -> HVACAction | None: + 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": @@ -166,14 +165,6 @@ def hvac_action(self) -> HVACAction | None: return HVACAction.IDLE - @property - def extra_state_attributes(self) -> Mapping[str, Any] | None: - """Return entity specific state attributes.""" - return { - "available_schemas": self.device["available_schedules"], - "selected_schema": self.device["selected_schedule"], - } - @property def preset_mode(self) -> str | None: """Return the current preset mode.""" @@ -182,8 +173,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: # pw-beta - await self.async_set_hvac_mode(kwargs[ATTR_HVAC_MODE]) # pw-beta + 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: From 68ad832ed93c1e9dd6829ee45c576ac75654a2ab Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 13:38:38 +0100 Subject: [PATCH 04/21] Add explicit tags --- custom_components/plugwise/config_flow.py | 51 +++++++++++++---------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/custom_components/plugwise/config_flow.py b/custom_components/plugwise/config_flow.py index f72a09503..4a40614a2 100644 --- a/custom_components/plugwise/config_flow.py +++ b/custom_components/plugwise/config_flow.py @@ -1,10 +1,10 @@ """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 @@ -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( From 53f6aa9833bcb5b491a800d000e4448c66306a10 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 13:44:21 +0100 Subject: [PATCH 05/21] Add/improve tags --- custom_components/plugwise/const.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From 36b5d91ab87508933cffd40eb6343634c0076bbb Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 13:47:54 +0100 Subject: [PATCH 06/21] Retag according to comment --- custom_components/plugwise/climate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/plugwise/climate.py b/custom_components/plugwise/climate.py index 4a5eb5de2..6598216eb 100644 --- a/custom_components/plugwise/climate.py +++ b/custom_components/plugwise/climate.py @@ -134,7 +134,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.get("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: From 0cc5b38ea30fc37cc8f340438dbb3f5b0c4ea0e8 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 13:54:33 +0100 Subject: [PATCH 07/21] Add/improve tags --- custom_components/plugwise/coordinator.py | 27 +++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/custom_components/plugwise/coordinator.py b/custom_components/plugwise/coordinator.py index fc90166e8..6cc9bf403 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 add to Core """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 From 85f8f2bc040b39e5a9e26d6864c888676c4c2c13 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 13:57:26 +0100 Subject: [PATCH 08/21] Add/improve tags --- custom_components/plugwise/coordinator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/plugwise/coordinator.py b/custom_components/plugwise/coordinator.py index 6cc9bf403..0e88515f1 100644 --- a/custom_components/plugwise/coordinator.py +++ b/custom_components/plugwise/coordinator.py @@ -37,7 +37,7 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[PlugwiseData]): def __init__( self, hass: HomeAssistant, entry: ConfigEntry, cooldown: float - ) -> None: # pw-beta add to Core + ) -> None: # pw-beta cooldown """Initialize the coordinator.""" super().__init__( hass, From a2c5747b7634bc1c0fee76d3139f101dc2c8cc4c Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:02:06 +0100 Subject: [PATCH 09/21] Add/improve tags --- custom_components/plugwise/gateway.py | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) 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" From 63e8695f7cdd9e3bfaa930ed7e69e3ba10be1f8a Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:03:15 +0100 Subject: [PATCH 10/21] Remove accordingly --- custom_components/plugwise/climate.py | 1 - 1 file changed, 1 deletion(-) diff --git a/custom_components/plugwise/climate.py b/custom_components/plugwise/climate.py index 6598216eb..b3a72110c 100644 --- a/custom_components/plugwise/climate.py +++ b/custom_components/plugwise/climate.py @@ -70,7 +70,6 @@ def __init__( ) -> None: """Set up the Plugwise API.""" super().__init__(coordinator, device_id) - self._attr_extra_state_attributes = {} self._homekit_enabled = homekit_enabled # pw-beta homekit emulation self._homekit_mode: str | None = None # pw-beta homekit emulation self._attr_unique_id = f"{device_id}-climate" From 62af13c55fd061115763a82e38880ad10adfae14 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:08:10 +0100 Subject: [PATCH 11/21] Missed desc --- custom_components/plugwise/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/plugwise/__init__.py b/custom_components/plugwise/__init__.py index dbc4065c5..d614207a1 100644 --- a/custom_components/plugwise/__init__.py +++ b/custom_components/plugwise/__init__.py @@ -1,4 +1,4 @@ -"""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 d9d1516b954a4ac7888365f94e9962924a951970 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:15:51 +0100 Subject: [PATCH 12/21] Retag according to comment --- custom_components/plugwise/binary_sensor.py | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/custom_components/plugwise/binary_sensor.py b/custom_components/plugwise/binary_sensor.py index 7685119ec..ae11a98b4 100644 --- a/custom_components/plugwise/binary_sensor.py +++ b/custom_components/plugwise/binary_sensor.py @@ -10,25 +10,25 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback -from plugwise.nodes import PlugwiseNode - -from .const import ATTR_SCAN_DAYLIGHT_MODE # pw-beta -from .const import ATTR_SCAN_RESET_TIMER # pw-beta -from .const import ATTR_SCAN_SENSITIVITY_MODE # pw-beta -from .const import ATTR_SED_CLOCK_INTERVAL # pw-beta -from .const import ATTR_SED_CLOCK_SYNC # pw-beta -from .const import ATTR_SED_MAINTENANCE_INTERVAL # pw-beta -from .const import ATTR_SED_SLEEP_FOR # pw-beta -from .const import ATTR_SED_STAY_ACTIVE # pw-beta -from .const import CB_NEW_NODE # pw-beta +from plugwise.nodes import PlugwiseNode # pw-beta usb + +from .const import ATTR_SCAN_DAYLIGHT_MODE # pw-beta usb +from .const import ATTR_SCAN_RESET_TIMER # pw-beta usb +from .const import ATTR_SCAN_SENSITIVITY_MODE # pw-beta usb +from .const import ATTR_SED_CLOCK_INTERVAL # pw-beta usb +from .const import ATTR_SED_CLOCK_SYNC # pw-beta usb +from .const import ATTR_SED_MAINTENANCE_INTERVAL # pw-beta usb +from .const import ATTR_SED_SLEEP_FOR # pw-beta usb +from .const import ATTR_SED_STAY_ACTIVE # pw-beta usb +from .const import CB_NEW_NODE # pw-beta usb from .const import COORDINATOR, DOMAIN, LOGGER, SEVERITIES, STICK from .const import PW_TYPE # pw-beta -from .const import SERVICE_USB_SCAN_CONFIG # pw-beta -from .const import SERVICE_USB_SCAN_CONFIG_SCHEMA # pw-beta -from .const import SERVICE_USB_SED_BATTERY_CONFIG # pw-beta -from .const import SERVICE_USB_SED_BATTERY_CONFIG_SCHEMA # pw-beta -from .const import USB # pw-beta -from .const import USB_MOTION_ID # pw-beta +from .const import SERVICE_USB_SCAN_CONFIG # pw-beta usb +from .const import SERVICE_USB_SCAN_CONFIG_SCHEMA # pw-beta usb +from .const import SERVICE_USB_SED_BATTERY_CONFIG # pw-beta usb +from .const import SERVICE_USB_SED_BATTERY_CONFIG_SCHEMA # pw-beta usb +from .const import USB # pw-beta usb +from .const import USB_MOTION_ID # pw-beta usb from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .models import PW_BINARY_SENSOR_TYPES, PlugwiseBinarySensorEntityDescription From 422516b5792a947d1b2c153015929f0b9166f844 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:18:39 +0100 Subject: [PATCH 13/21] Retag according to comment --- custom_components/plugwise/binary_sensor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/plugwise/binary_sensor.py b/custom_components/plugwise/binary_sensor.py index ae11a98b4..fc8602189 100644 --- a/custom_components/plugwise/binary_sensor.py +++ b/custom_components/plugwise/binary_sensor.py @@ -167,7 +167,7 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None: if self.entity_description.key != "plugwise_notification": return None - attrs: dict[str, list[str]] = {f"{severity}_msg": [] for severity in SEVERITIES} + 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(): # pw-beta uses notify_id @@ -176,6 +176,10 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None: if msg_type not in SEVERITIES: msg_type = "other" # pragma: no cover + 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) self._notification[ From 7ed41a66ca3492067654e7a57ff17f252734c807 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:22:12 +0100 Subject: [PATCH 14/21] Add tags / re-tag --- custom_components/plugwise/sensor.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/custom_components/plugwise/sensor.py b/custom_components/plugwise/sensor.py index 42554d6ea..b08670c9c 100644 --- a/custom_components/plugwise/sensor.py +++ b/custom_components/plugwise/sensor.py @@ -8,11 +8,12 @@ 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 CB_NEW_NODE, COORDINATOR, DOMAIN, LOGGER, STICK, USB # pw-beta usb +from .const import PW_TYPE # pw-beta 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 +24,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 +109,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__( From ba4a180f0da29e2af62e94c19c66e3cde082be97 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:24:16 +0100 Subject: [PATCH 15/21] Add tags / re-tag --- custom_components/plugwise/switch.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/custom_components/plugwise/switch.py b/custom_components/plugwise/switch.py index 9cbc63be3..883e9a909 100644 --- a/custom_components/plugwise/switch.py +++ b/custom_components/plugwise/switch.py @@ -10,11 +10,20 @@ 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 ( # pw-beta usb + CB_NEW_NODE, + COORDINATOR, + DOMAIN, + LOGGER, + SMILE, + STICK, + USB, +) +from .const import PW_TYPE # pw-beta 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 +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 the USB switches from a config entry.""" api_stick = hass.data[DOMAIN][config_entry.entry_id][STICK] @@ -121,7 +130,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__( From 3e33d1db3a45067ac384408bbe35ef94734ce024 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:28:00 +0100 Subject: [PATCH 16/21] Add desc from review --- custom_components/plugwise/binary_sensor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/custom_components/plugwise/binary_sensor.py b/custom_components/plugwise/binary_sensor.py index fc8602189..718c26b76 100644 --- a/custom_components/plugwise/binary_sensor.py +++ b/custom_components/plugwise/binary_sensor.py @@ -167,6 +167,8 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None: if self.entity_description.key != "plugwise_notification": return None + # 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"]: From 92a2302a2b67782c7d0f6bc0e63f7d8f8978aaf1 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 14:34:17 +0100 Subject: [PATCH 17/21] Add missing tags --- custom_components/plugwise/config_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/plugwise/config_flow.py b/custom_components/plugwise/config_flow.py index 4a40614a2..28164bcb6 100644 --- a/custom_components/plugwise/config_flow.py +++ b/custom_components/plugwise/config_flow.py @@ -8,7 +8,7 @@ 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 ( From f8a9736efe3bd807ecd93e4038fe32095798496f Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 4 Mar 2023 15:51:30 +0100 Subject: [PATCH 18/21] Retag according to comment --- custom_components/plugwise/sensor.py | 5 ++++- custom_components/plugwise/switch.py | 14 +++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/custom_components/plugwise/sensor.py b/custom_components/plugwise/sensor.py index b08670c9c..89848dcd6 100644 --- a/custom_components/plugwise/sensor.py +++ b/custom_components/plugwise/sensor.py @@ -8,8 +8,11 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import CB_NEW_NODE, COORDINATOR, DOMAIN, LOGGER, STICK, USB # pw-beta usb +from .const import CB_NEW_NODE # pw-beta usb +from .const import COORDINATOR, DOMAIN, LOGGER from .const import PW_TYPE # pw-beta +from .const import STICK # pw-beta usb, +from .const import USB # pw-beta usb from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .models import PW_SENSOR_TYPES, PlugwiseSensorEntityDescription diff --git a/custom_components/plugwise/switch.py b/custom_components/plugwise/switch.py index 883e9a909..3c9895e53 100644 --- a/custom_components/plugwise/switch.py +++ b/custom_components/plugwise/switch.py @@ -10,16 +10,12 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import ( # pw-beta usb - CB_NEW_NODE, - COORDINATOR, - DOMAIN, - LOGGER, - SMILE, - STICK, - USB, -) +from .const import CB_NEW_NODE # pw-beta usb +from .const import COORDINATOR, DOMAIN, LOGGER from .const import PW_TYPE # pw-beta +from .const import SMILE # pw-beta usb +from .const import STICK # pw-beta usb +from .const import USB # pw-beta usb from .coordinator import PlugwiseDataUpdateCoordinator from .entity import PlugwiseEntity from .models import PW_SWITCH_TYPES, PlugwiseSwitchEntityDescription From c71a27d843c513e11d2c7ecd9b82f521700f2faa Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 5 Mar 2023 10:17:28 +0100 Subject: [PATCH 19/21] isort skip --- custom_components/plugwise/binary_sensor.py | 37 ++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/custom_components/plugwise/binary_sensor.py b/custom_components/plugwise/binary_sensor.py index 718c26b76..8f6ca43c2 100644 --- a/custom_components/plugwise/binary_sensor.py +++ b/custom_components/plugwise/binary_sensor.py @@ -12,23 +12,30 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode # pw-beta usb -from .const import ATTR_SCAN_DAYLIGHT_MODE # pw-beta usb -from .const import ATTR_SCAN_RESET_TIMER # pw-beta usb -from .const import ATTR_SCAN_SENSITIVITY_MODE # pw-beta usb -from .const import ATTR_SED_CLOCK_INTERVAL # pw-beta usb -from .const import ATTR_SED_CLOCK_SYNC # pw-beta usb -from .const import ATTR_SED_MAINTENANCE_INTERVAL # pw-beta usb -from .const import ATTR_SED_SLEEP_FOR # pw-beta usb -from .const import ATTR_SED_STAY_ACTIVE # pw-beta usb -from .const import CB_NEW_NODE # pw-beta usb from .const import COORDINATOR, DOMAIN, LOGGER, SEVERITIES, STICK from .const import PW_TYPE # pw-beta -from .const import SERVICE_USB_SCAN_CONFIG # pw-beta usb -from .const import SERVICE_USB_SCAN_CONFIG_SCHEMA # pw-beta usb -from .const import SERVICE_USB_SED_BATTERY_CONFIG # pw-beta usb -from .const import SERVICE_USB_SED_BATTERY_CONFIG_SCHEMA # pw-beta usb -from .const import USB # pw-beta usb -from .const import USB_MOTION_ID # pw-beta usb + +# isort: off +from .const import ( + ATTR_SCAN_DAYLIGHT_MODE, + ATTR_SCAN_RESET_TIMER, + ATTR_SCAN_SENSITIVITY_MODE, + ATTR_SED_CLOCK_INTERVAL, + ATTR_SED_CLOCK_SYNC, + ATTR_SED_MAINTENANCE_INTERVAL, + ATTR_SED_SLEEP_FOR, + ATTR_SED_STAY_ACTIVE, + CB_NEW_NODE, + SERVICE_USB_SCAN_CONFIG, + SERVICE_USB_SCAN_CONFIG_SCHEMA, + SERVICE_USB_SED_BATTERY_CONFIG, + SERVICE_USB_SED_BATTERY_CONFIG_SCHEMA, + 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 f758cdd3ac4cec7248094d5698bde9a488a3ecae Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 5 Mar 2023 10:36:23 +0100 Subject: [PATCH 20/21] More isort --- custom_components/plugwise/binary_sensor.py | 6 ++++-- custom_components/plugwise/diagnostics.py | 3 ++- custom_components/plugwise/number.py | 3 ++- custom_components/plugwise/select.py | 3 ++- custom_components/plugwise/sensor.py | 15 ++++++++++----- custom_components/plugwise/switch.py | 18 ++++++++++++------ 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/custom_components/plugwise/binary_sensor.py b/custom_components/plugwise/binary_sensor.py index 8f6ca43c2..c17028df5 100644 --- a/custom_components/plugwise/binary_sensor.py +++ b/custom_components/plugwise/binary_sensor.py @@ -12,10 +12,11 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode # pw-beta usb -from .const import COORDINATOR, DOMAIN, LOGGER, SEVERITIES, STICK -from .const import PW_TYPE # pw-beta +from .const import DOMAIN, LOGGER, SEVERITIES # isort: off +from .const import COORDINATOR, PW_TYPE # pw-beta + from .const import ( ATTR_SCAN_DAYLIGHT_MODE, ATTR_SCAN_RESET_TIMER, @@ -30,6 +31,7 @@ SERVICE_USB_SCAN_CONFIG_SCHEMA, SERVICE_USB_SED_BATTERY_CONFIG, SERVICE_USB_SED_BATTERY_CONFIG_SCHEMA, + STICK, USB, USB_MOTION_ID, ) # pw-beta usb 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/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 89848dcd6..60aa4157b 100644 --- a/custom_components/plugwise/sensor.py +++ b/custom_components/plugwise/sensor.py @@ -8,11 +8,16 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import CB_NEW_NODE # pw-beta usb -from .const import COORDINATOR, DOMAIN, LOGGER -from .const import PW_TYPE # pw-beta -from .const import STICK # pw-beta usb, -from .const import USB # pw-beta usb +from .const import COORDINATOR, DOMAIN, LOGGER, PW_TYPE # pw-beta + +# isort: off +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 diff --git a/custom_components/plugwise/switch.py b/custom_components/plugwise/switch.py index 3c9895e53..f25b67b6e 100644 --- a/custom_components/plugwise/switch.py +++ b/custom_components/plugwise/switch.py @@ -10,12 +10,18 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import CB_NEW_NODE # pw-beta usb -from .const import COORDINATOR, DOMAIN, LOGGER -from .const import PW_TYPE # pw-beta -from .const import SMILE # pw-beta usb -from .const import STICK # pw-beta usb -from .const import USB # pw-beta 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 e4b80252427a1ec6e264a781774cd905787e07d9 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 5 Mar 2023 10:38:27 +0100 Subject: [PATCH 21/21] More isort --- custom_components/plugwise/sensor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/plugwise/sensor.py b/custom_components/plugwise/sensor.py index 60aa4157b..5be6e0691 100644 --- a/custom_components/plugwise/sensor.py +++ b/custom_components/plugwise/sensor.py @@ -8,9 +8,10 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from plugwise.nodes import PlugwiseNode -from .const import COORDINATOR, DOMAIN, LOGGER, PW_TYPE # pw-beta +from .const import DOMAIN, LOGGER # isort: off +from .const import COORDINATOR, PW_TYPE # pw-beta from .const import ( CB_NEW_NODE, STICK,