From 744f9203fb02e5096b33ab3dae4343a319783d21 Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Fri, 19 Feb 2021 22:23:11 +0100 Subject: [PATCH] Code quality improvements based on core feedback (#385) --- custom_components/tahoma/__init__.py | 46 +++++++++++-------- .../tahoma/alarm_control_panel.py | 6 +-- custom_components/tahoma/binary_sensor.py | 6 +-- custom_components/tahoma/climate.py | 2 +- .../atlantic_electrical_heater.py | 4 +- .../climate_devices/atlantic_pass_apcdhw.py | 4 +- .../dimmer_exterior_heating.py | 4 +- .../climate_devices/somfy_thermostat.py | 4 +- .../stateless_exterior_heating.py | 4 +- custom_components/tahoma/config_flow.py | 17 +++---- custom_components/tahoma/const.py | 4 +- custom_components/tahoma/coordinator.py | 15 ++---- custom_components/tahoma/cover.py | 6 +-- custom_components/tahoma/light.py | 6 +-- custom_components/tahoma/lock.py | 6 +-- custom_components/tahoma/manifest.json | 3 +- custom_components/tahoma/scene.py | 2 +- custom_components/tahoma/sensor.py | 6 +-- custom_components/tahoma/switch.py | 6 +-- .../{tahoma_device.py => tahoma_entity.py} | 2 +- custom_components/tahoma/water_heater.py | 2 +- .../domestic_hot_water_production.py | 4 +- 22 files changed, 80 insertions(+), 79 deletions(-) rename custom_components/tahoma/{tahoma_device.py => tahoma_entity.py} (99%) diff --git a/custom_components/tahoma/__init__.py b/custom_components/tahoma/__init__.py index 56fec7f51..ea8af1159 100644 --- a/custom_components/tahoma/__init__.py +++ b/custom_components/tahoma/__init__.py @@ -33,9 +33,9 @@ DEFAULT_UPDATE_INTERVAL, DOMAIN, HUB_MANUFACTURER, - IGNORED_TAHOMA_TYPES, + IGNORED_TAHOMA_DEVICES, SUPPORTED_ENDPOINTS, - TAHOMA_TYPES, + TAHOMA_DEVICE_TO_PLATFORM, ) from .coordinator import TahomaDataUpdateCoordinator @@ -95,7 +95,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): username = entry.data.get(CONF_USERNAME) password = entry.data.get(CONF_PASSWORD) - hub = entry.data.get(CONF_HUB) or DEFAULT_HUB + hub = entry.data.get(CONF_HUB, DEFAULT_HUB) endpoint = SUPPORTED_ENDPOINTS[hub] session = async_get_clientsession(hass) @@ -112,47 +112,55 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): scenarios = await client.get_scenarios() gateways = await client.get_gateways() except BadCredentialsException: - _LOGGER.error("invalid_auth") + _LOGGER.error("Invalid authentication.") return False except TooManyRequestsException as exception: - _LOGGER.error("too_many_requests") + _LOGGER.error("Too many requests, try again later.") raise ConfigEntryNotReady from exception except (TimeoutError, ClientError, ServerDisconnectedError) as exception: - _LOGGER.error("cannot_connect") + _LOGGER.error("Failed to connect.") raise ConfigEntryNotReady from exception except MaintenanceException as exception: - _LOGGER.error("server_in_maintenance") + _LOGGER.error("Server is down for maintenance.") raise ConfigEntryNotReady from exception except Exception as exception: # pylint: disable=broad-except _LOGGER.exception(exception) return False - update_interval = entry.options.get(CONF_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL) + update_interval = timedelta( + seconds=entry.options.get(CONF_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL) + ) tahoma_coordinator = TahomaDataUpdateCoordinator( hass, _LOGGER, - name="events", + name="device events", client=client, devices=devices, - update_interval=timedelta(seconds=update_interval), + update_interval=update_interval, + ) + + _LOGGER.debug( + "Initialized DataUpdateCoordinator with %s interval.", str(update_interval) ) await tahoma_coordinator.async_refresh() - entities = defaultdict(list) - entities[SCENE] = scenarios + platforms = defaultdict(list) + platforms[SCENE] = scenarios hass.data[DOMAIN][entry.entry_id] = { - "entities": entities, + "platforms": platforms, "coordinator": tahoma_coordinator, "update_listener": entry.add_update_listener(update_listener), } for device in tahoma_coordinator.data.values(): - platform = TAHOMA_TYPES.get(device.widget) or TAHOMA_TYPES.get(device.ui_class) + platform = TAHOMA_DEVICE_TO_PLATFORM.get( + device.widget + ) or TAHOMA_DEVICE_TO_PLATFORM.get(device.ui_class) if platform: - entities[platform].append(device) + platforms[platform].append(device) _LOGGER.debug( "Added device (%s - %s - %s - %s)", device.controllable_name, @@ -161,8 +169,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): device.deviceurl, ) elif ( - device.widget not in IGNORED_TAHOMA_TYPES - and device.ui_class not in IGNORED_TAHOMA_TYPES + device.widget not in IGNORED_TAHOMA_DEVICES + and device.ui_class not in IGNORED_TAHOMA_DEVICES ): _LOGGER.debug( "Unsupported device detected (%s - %s - %s - %s)", @@ -175,7 +183,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry): if device.widget == HOMEKIT_STACK: print_homekit_setup_code(device) - for platform in entities: + for platform in platforms: hass.async_create_task( hass.config_entries.async_forward_entry_setup(entry, platform) ) @@ -253,7 +261,7 @@ async def handle_get_execution_history(call): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry): """Unload a config entry.""" - entities_per_platform = hass.data[DOMAIN][entry.entry_id]["entities"] + entities_per_platform = hass.data[DOMAIN][entry.entry_id]["platforms"] unload_ok = all( await asyncio.gather( diff --git a/custom_components/tahoma/alarm_control_panel.py b/custom_components/tahoma/alarm_control_panel.py index b2871b805..09dfda3c2 100644 --- a/custom_components/tahoma/alarm_control_panel.py +++ b/custom_components/tahoma/alarm_control_panel.py @@ -20,7 +20,7 @@ ) from .const import DOMAIN -from .tahoma_device import TahomaDevice +from .tahoma_entity import TahomaEntity COMMAND_ALARM_OFF = "alarmOff" COMMAND_ALARM_ON = "alarmOn" @@ -81,12 +81,12 @@ async def async_setup_entry(hass, entry, async_add_entities): entities = [ TahomaAlarmControlPanel(device.deviceurl, coordinator) - for device in data["entities"].get(ALARM_CONTROL_PANEL) + for device in data["platforms"].get(ALARM_CONTROL_PANEL) ] async_add_entities(entities) -class TahomaAlarmControlPanel(TahomaDevice, AlarmControlPanelEntity): +class TahomaAlarmControlPanel(TahomaEntity, AlarmControlPanelEntity): """Representation of a TaHoma Alarm Control Panel.""" @property diff --git a/custom_components/tahoma/binary_sensor.py b/custom_components/tahoma/binary_sensor.py index 91695c63c..6b0d6c168 100644 --- a/custom_components/tahoma/binary_sensor.py +++ b/custom_components/tahoma/binary_sensor.py @@ -11,7 +11,7 @@ ) from .const import DOMAIN -from .tahoma_device import TahomaDevice +from .tahoma_entity import TahomaEntity CORE_ASSEMBLY_STATE = "core:AssemblyState" CORE_BUTTON_STATE = "core:ButtonState" @@ -65,12 +65,12 @@ async def async_setup_entry(hass, entry, async_add_entities): entities = [ TahomaBinarySensor(device.deviceurl, coordinator) - for device in data["entities"].get(BINARY_SENSOR) + for device in data["platforms"].get(BINARY_SENSOR) ] async_add_entities(entities) -class TahomaBinarySensor(TahomaDevice, BinarySensorEntity): +class TahomaBinarySensor(TahomaEntity, BinarySensorEntity): """Representation of a TaHoma Binary Sensor.""" @property diff --git a/custom_components/tahoma/climate.py b/custom_components/tahoma/climate.py index dc8950b00..eb8fa8d28 100644 --- a/custom_components/tahoma/climate.py +++ b/custom_components/tahoma/climate.py @@ -26,7 +26,7 @@ async def async_setup_entry(hass, entry, async_add_entities): data = hass.data[DOMAIN][entry.entry_id] coordinator = data["coordinator"] - climate_devices = [device for device in data["entities"].get(CLIMATE)] + climate_devices = [device for device in data["platforms"].get(CLIMATE)] entities = [ TYPE[device.widget](device.deviceurl, coordinator) diff --git a/custom_components/tahoma/climate_devices/atlantic_electrical_heater.py b/custom_components/tahoma/climate_devices/atlantic_electrical_heater.py index 85dad8019..b48c83018 100644 --- a/custom_components/tahoma/climate_devices/atlantic_electrical_heater.py +++ b/custom_components/tahoma/climate_devices/atlantic_electrical_heater.py @@ -14,7 +14,7 @@ ) from homeassistant.const import TEMP_CELSIUS -from ..tahoma_device import TahomaDevice +from ..tahoma_device import TahomaEntity COMMAND_SET_HEATING_LEVEL = "setHeatingLevel" @@ -36,7 +36,7 @@ MAP_HVAC_MODES = {HVAC_MODE_HEAT: PRESET_COMFORT, HVAC_MODE_OFF: PRESET_OFF} -class AtlanticElectricalHeater(TahomaDevice, ClimateEntity): +class AtlanticElectricalHeater(TahomaEntity, ClimateEntity): """Representation of TaHoma IO Atlantic Electrical Heater.""" @property diff --git a/custom_components/tahoma/climate_devices/atlantic_pass_apcdhw.py b/custom_components/tahoma/climate_devices/atlantic_pass_apcdhw.py index 52dce69e1..2cab03684 100644 --- a/custom_components/tahoma/climate_devices/atlantic_pass_apcdhw.py +++ b/custom_components/tahoma/climate_devices/atlantic_pass_apcdhw.py @@ -15,7 +15,7 @@ ) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS -from ..tahoma_device import TahomaDevice +from ..tahoma_device import TahomaEntity BOOST_ON_STATE = "on" BOOST_OFF_STATE = "off" @@ -70,7 +70,7 @@ MAP_REVERSE_PRESET_MODES = {v: k for k, v in MAP_PRESET_MODES.items()} -class AtlanticPassAPCDHW(TahomaDevice, ClimateEntity): +class AtlanticPassAPCDHW(TahomaEntity, ClimateEntity): """Representation of TaHoma IO Atlantic Electrical Heater.""" @property diff --git a/custom_components/tahoma/climate_devices/dimmer_exterior_heating.py b/custom_components/tahoma/climate_devices/dimmer_exterior_heating.py index ffdbe1bad..37c058cfa 100644 --- a/custom_components/tahoma/climate_devices/dimmer_exterior_heating.py +++ b/custom_components/tahoma/climate_devices/dimmer_exterior_heating.py @@ -11,7 +11,7 @@ from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from ..coordinator import TahomaDataUpdateCoordinator -from ..tahoma_device import TahomaDevice +from ..tahoma_device import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -21,7 +21,7 @@ CORE_LEVEL_STATE = "core:LevelState" -class DimmerExteriorHeating(TahomaDevice, ClimateEntity): +class DimmerExteriorHeating(TahomaEntity, ClimateEntity): """Representation of TaHoma IO Atlantic Electrical Heater.""" def __init__(self, device_url: str, coordinator: TahomaDataUpdateCoordinator): diff --git a/custom_components/tahoma/climate_devices/somfy_thermostat.py b/custom_components/tahoma/climate_devices/somfy_thermostat.py index ae21b8f89..04d2261da 100644 --- a/custom_components/tahoma/climate_devices/somfy_thermostat.py +++ b/custom_components/tahoma/climate_devices/somfy_thermostat.py @@ -24,7 +24,7 @@ from homeassistant.helpers.event import async_track_state_change from ..coordinator import TahomaDataUpdateCoordinator -from ..tahoma_device import TahomaDevice +from ..tahoma_device import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -73,7 +73,7 @@ } -class SomfyThermostat(TahomaDevice, ClimateEntity): +class SomfyThermostat(TahomaEntity, ClimateEntity): """Representation of Somfy Smart Thermostat.""" def __init__(self, device_url: str, coordinator: TahomaDataUpdateCoordinator): diff --git a/custom_components/tahoma/climate_devices/stateless_exterior_heating.py b/custom_components/tahoma/climate_devices/stateless_exterior_heating.py index d62386d8e..147b0b0c5 100644 --- a/custom_components/tahoma/climate_devices/stateless_exterior_heating.py +++ b/custom_components/tahoma/climate_devices/stateless_exterior_heating.py @@ -10,7 +10,7 @@ ) from homeassistant.const import TEMP_CELSIUS -from ..tahoma_device import TahomaDevice +from ..tahoma_device import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -21,7 +21,7 @@ PRESET_MY = "My" -class StatelessExteriorHeating(TahomaDevice, ClimateEntity): +class StatelessExteriorHeating(TahomaEntity, ClimateEntity): """Representation of TaHoma Stateless Exterior Heating device.""" @property diff --git a/custom_components/tahoma/config_flow.py b/custom_components/tahoma/config_flow.py index cf76d5d12..6182cf58c 100644 --- a/custom_components/tahoma/config_flow.py +++ b/custom_components/tahoma/config_flow.py @@ -36,7 +36,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): - """Handle a config flow for TaHoma.""" + """Handle a config flow for Somfy TaHoma.""" VERSION = 1 CONNECTION_CLASS = config_entries.CONN_CLASS_CLOUD_POLL @@ -52,7 +52,7 @@ async def async_validate_input(self, user_input): username = user_input.get(CONF_USERNAME) password = user_input.get(CONF_PASSWORD) - hub = user_input.get(CONF_HUB) or DEFAULT_HUB + hub = user_input.get(CONF_HUB, DEFAULT_HUB) endpoint = SUPPORTED_ENDPOINTS[hub] async with TahomaClient(username, password, api_url=endpoint) as client: @@ -113,15 +113,11 @@ async def async_step_import(self, import_config: dict): class OptionsFlowHandler(config_entries.OptionsFlow): - """Handle a option flow for TaHoma.""" + """Handle a option flow for Somfy TaHoma.""" def __init__(self, config_entry): """Initialize options flow.""" self.config_entry = config_entry - self.options = dict(config_entry.options) - - if self.options.get(CONF_UPDATE_INTERVAL) is None: - self.options[CONF_UPDATE_INTERVAL] = DEFAULT_UPDATE_INTERVAL async def async_step_init(self, user_input=None): """Manage the Somfy TaHoma options.""" @@ -130,8 +126,7 @@ async def async_step_init(self, user_input=None): async def async_step_update_interval(self, user_input=None): """Manage the options regarding interval updates.""" if user_input is not None: - self.options[CONF_UPDATE_INTERVAL] = user_input[CONF_UPDATE_INTERVAL] - return self.async_create_entry(title="", data=self.options) + return self.async_create_entry(title="", data=user_input) return self.async_show_form( step_id="update_interval", @@ -139,7 +134,9 @@ async def async_step_update_interval(self, user_input=None): { vol.Required( CONF_UPDATE_INTERVAL, - default=self.options.get(CONF_UPDATE_INTERVAL), + default=self.config_entry.options.get( + CONF_UPDATE_INTERVAL, DEFAULT_UPDATE_INTERVAL + ), ): vol.All(cv.positive_int, vol.Clamp(min=MIN_UPDATE_INTERVAL)) } ), diff --git a/custom_components/tahoma/const.py b/custom_components/tahoma/const.py index c2e32932e..b93e5cd7d 100644 --- a/custom_components/tahoma/const.py +++ b/custom_components/tahoma/const.py @@ -36,13 +36,13 @@ MIN_UPDATE_INTERVAL = 30 DEFAULT_UPDATE_INTERVAL = 30 -IGNORED_TAHOMA_TYPES = [ +IGNORED_TAHOMA_DEVICES = [ "ProtocolGateway", "Pod", ] # Used to map the Somfy widget and ui_class to the Home Assistant platform -TAHOMA_TYPES = { +TAHOMA_DEVICE_TO_PLATFORM = { "AdjustableSlatsRollerShutter": COVER, "AirFlowSensor": BINARY_SENSOR, # widgetName, uiClass is AirSensor (sensor) "AirSensor": SENSOR, diff --git a/custom_components/tahoma/coordinator.py b/custom_components/tahoma/coordinator.py index 68515d137..c42fd4149 100644 --- a/custom_components/tahoma/coordinator.py +++ b/custom_components/tahoma/coordinator.py @@ -59,24 +59,19 @@ def __init__( self.devices: Dict[str, Device] = {d.deviceurl: d for d in devices} self.executions: Dict[str, Dict[str, str]] = {} - _LOGGER.debug( - "Initialized DataUpdateCoordinator with %s interval.", str(update_interval) - ) - async def _async_update_data(self) -> Dict[str, Device]: """Fetch TaHoma data via event listener.""" try: events = await self.client.fetch_events() except BadCredentialsException as exception: - raise UpdateFailed("invalid_auth") from exception + raise UpdateFailed("Invalid authentication.") from exception except TooManyRequestsException as exception: - raise UpdateFailed("too_many_requests") from exception + raise UpdateFailed("Too many requests, try again later.") from exception except MaintenanceException as exception: - raise UpdateFailed("server_in_maintenance") from exception + raise UpdateFailed("Server is down for maintenance.") from exception except TimeoutError as exception: - raise UpdateFailed("cannot_connect") from exception - except (ServerDisconnectedError, NotAuthenticatedException) as exception: - _LOGGER.debug(exception) + raise UpdateFailed("Failed to connect.") from exception + except (ServerDisconnectedError, NotAuthenticatedException): self.executions = {} await self.client.login() self.devices = await self._get_devices() diff --git a/custom_components/tahoma/cover.py b/custom_components/tahoma/cover.py index 8514d5ee3..a42ff8fe6 100644 --- a/custom_components/tahoma/cover.py +++ b/custom_components/tahoma/cover.py @@ -26,7 +26,7 @@ import voluptuous as vol from .const import DOMAIN -from .tahoma_device import TahomaDevice +from .tahoma_entity import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -116,7 +116,7 @@ async def async_setup_entry(hass, entry, async_add_entities): entities = [ TahomaCover(device.deviceurl, coordinator) - for device in data["entities"].get(COVER) + for device in data["platforms"].get(COVER) ] async_add_entities(entities) @@ -138,7 +138,7 @@ async def async_setup_entry(hass, entry, async_add_entities): ) -class TahomaCover(TahomaDevice, CoverEntity): +class TahomaCover(TahomaEntity, CoverEntity): """Representation of a TaHoma Cover.""" @property diff --git a/custom_components/tahoma/light.py b/custom_components/tahoma/light.py index 6d5c25e90..16c89b77f 100644 --- a/custom_components/tahoma/light.py +++ b/custom_components/tahoma/light.py @@ -16,7 +16,7 @@ import homeassistant.util.color as color_util from .const import COMMAND_OFF, COMMAND_ON, CORE_ON_OFF_STATE, DOMAIN -from .tahoma_device import TahomaDevice +from .tahoma_entity import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -43,7 +43,7 @@ async def async_setup_entry(hass, entry, async_add_entities): entities = [ TahomaLight(device.deviceurl, coordinator) - for device in data["entities"].get(LIGHT) + for device in data["platforms"].get(LIGHT) ] async_add_entities(entities) @@ -54,7 +54,7 @@ async def async_setup_entry(hass, entry, async_add_entities): ) -class TahomaLight(TahomaDevice, LightEntity): +class TahomaLight(TahomaEntity, LightEntity): """Representation of a TaHoma Light.""" def __init__(self, tahoma_device, controller): diff --git a/custom_components/tahoma/lock.py b/custom_components/tahoma/lock.py index 9c0185e45..455c88083 100644 --- a/custom_components/tahoma/lock.py +++ b/custom_components/tahoma/lock.py @@ -5,7 +5,7 @@ from homeassistant.const import STATE_LOCKED from .const import DOMAIN -from .tahoma_device import TahomaDevice +from .tahoma_entity import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -23,13 +23,13 @@ async def async_setup_entry(hass, entry, async_add_entities): entities = [ TahomaLock(device.deviceurl, coordinator) - for device in data["entities"].get(LOCK) + for device in data["platforms"].get(LOCK) ] async_add_entities(entities) -class TahomaLock(TahomaDevice, LockEntity): +class TahomaLock(TahomaEntity, LockEntity): """Representation of a TaHoma Lock.""" async def async_unlock(self, **_): diff --git a/custom_components/tahoma/manifest.json b/custom_components/tahoma/manifest.json index c0ec690d7..405d37a60 100644 --- a/custom_components/tahoma/manifest.json +++ b/custom_components/tahoma/manifest.json @@ -12,5 +12,6 @@ "@vlebourl", "@tetienne" ], - "issue_tracker": "https://github.com/imicknl/ha-tahoma/issues" + "issue_tracker": "https://github.com/imicknl/ha-tahoma/issues", + "version": "2.4.8" } \ No newline at end of file diff --git a/custom_components/tahoma/scene.py b/custom_components/tahoma/scene.py index dea0dc15f..22fadc98a 100644 --- a/custom_components/tahoma/scene.py +++ b/custom_components/tahoma/scene.py @@ -17,7 +17,7 @@ async def async_setup_entry(hass, entry, async_add_entities): coordinator = data["coordinator"] entities = [ - TahomaScene(scene, coordinator.client) for scene in data["entities"].get(SCENE) + TahomaScene(scene, coordinator.client) for scene in data["platforms"].get(SCENE) ] async_add_entities(entities) diff --git a/custom_components/tahoma/sensor.py b/custom_components/tahoma/sensor.py index 5deab7413..0ca3f06b9 100644 --- a/custom_components/tahoma/sensor.py +++ b/custom_components/tahoma/sensor.py @@ -25,7 +25,7 @@ from homeassistant.helpers.entity import Entity from .const import DOMAIN -from .tahoma_device import TahomaDevice +from .tahoma_entity import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -101,14 +101,14 @@ async def async_setup_entry(hass, entry, async_add_entities): entities = [ TahomaSensor(device.deviceurl, coordinator) - for device in data["entities"].get(SENSOR) + for device in data["platforms"].get(SENSOR) if device.states ] async_add_entities(entities) -class TahomaSensor(TahomaDevice, Entity): +class TahomaSensor(TahomaEntity, Entity): """Representation of a TaHoma Sensor.""" @property diff --git a/custom_components/tahoma/switch.py b/custom_components/tahoma/switch.py index 4b81e50be..a4694ae88 100644 --- a/custom_components/tahoma/switch.py +++ b/custom_components/tahoma/switch.py @@ -10,7 +10,7 @@ from homeassistant.const import STATE_OFF, STATE_ON from .const import COMMAND_OFF, COMMAND_ON, CORE_ON_OFF_STATE, DOMAIN -from .tahoma_device import TahomaDevice +from .tahoma_entity import TahomaEntity _LOGGER = logging.getLogger(__name__) @@ -35,13 +35,13 @@ async def async_setup_entry(hass, entry, async_add_entities): entities = [ TahomaSwitch(device.deviceurl, coordinator) - for device in data["entities"].get(SWITCH) + for device in data["platforms"].get(SWITCH) ] async_add_entities(entities) -class TahomaSwitch(TahomaDevice, SwitchEntity): +class TahomaSwitch(TahomaEntity, SwitchEntity): """Representation a TaHoma Switch.""" @property diff --git a/custom_components/tahoma/tahoma_device.py b/custom_components/tahoma/tahoma_entity.py similarity index 99% rename from custom_components/tahoma/tahoma_device.py rename to custom_components/tahoma/tahoma_entity.py index a5a129b0a..65e4e0058 100644 --- a/custom_components/tahoma/tahoma_device.py +++ b/custom_components/tahoma/tahoma_entity.py @@ -31,7 +31,7 @@ _LOGGER = logging.getLogger(__name__) -class TahomaDevice(CoordinatorEntity, Entity): +class TahomaEntity(CoordinatorEntity, Entity): """Representation of a TaHoma device entity.""" def __init__(self, device_url: str, coordinator: TahomaDataUpdateCoordinator): diff --git a/custom_components/tahoma/water_heater.py b/custom_components/tahoma/water_heater.py index 847076109..6b1ca736c 100644 --- a/custom_components/tahoma/water_heater.py +++ b/custom_components/tahoma/water_heater.py @@ -16,7 +16,7 @@ async def async_setup_entry(hass, entry, async_add_entities): data = hass.data[DOMAIN][entry.entry_id] coordinator = data["coordinator"] - water_heater_devices = [device for device in data["entities"].get(WATER_HEATER)] + water_heater_devices = [device for device in data["platforms"].get(WATER_HEATER)] entities = [ TYPE[device.widget](device.deviceurl, coordinator) diff --git a/custom_components/tahoma/water_heater_devices/domestic_hot_water_production.py b/custom_components/tahoma/water_heater_devices/domestic_hot_water_production.py index d40b58711..8c873d37c 100644 --- a/custom_components/tahoma/water_heater_devices/domestic_hot_water_production.py +++ b/custom_components/tahoma/water_heater_devices/domestic_hot_water_production.py @@ -8,7 +8,7 @@ ) from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, STATE_ON, TEMP_CELSIUS -from ..tahoma_device import TahomaDevice +from ..tahoma_device import TahomaEntity CORE_MAXIMAL_TEMPERATURE_MANUAL_MODE_STATE = "core:MaximalTemperatureManualModeState" CORE_MINIMAL_TEMPERATURE_MANUAL_MODE_STATE = "core:MinimalTemperatureManualModeState" @@ -40,7 +40,7 @@ MAP_REVERSE_OPERATION_MODES = {v: k for k, v in MAP_OPERATION_MODES.items()} -class DomesticHotWaterProduction(TahomaDevice, WaterHeaterEntity): +class DomesticHotWaterProduction(TahomaEntity, WaterHeaterEntity): """Representation of a DomesticHotWaterProduction Water Heater.""" @property