From f8deffa490fb54c941e6877f6a689ada24de8dfd Mon Sep 17 00:00:00 2001 From: Chris <2675875+cgraf@users.noreply.github.com> Date: Wed, 9 Aug 2023 21:25:53 -0500 Subject: [PATCH 1/3] Fix to #81 --- custom_components/smartthings/binary_sensor.py | 2 +- custom_components/smartthings/number.py | 2 +- custom_components/smartthings/select.py | 2 +- custom_components/smartthings/sensor.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/custom_components/smartthings/binary_sensor.py b/custom_components/smartthings/binary_sensor.py index 7129f3d..376232c 100644 --- a/custom_components/smartthings/binary_sensor.py +++ b/custom_components/smartthings/binary_sensor.py @@ -75,7 +75,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): SamsungCooktopBurner(device, "Cooktop Bottom Right", 16), ] ) - elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K"): + elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K","TP1X_REF_21K"): sensors.extend( [ SamsungOcfDoorBinarySensor( diff --git a/custom_components/smartthings/number.py b/custom_components/smartthings/number.py index 8f7fc96..e43113b 100644 --- a/custom_components/smartthings/number.py +++ b/custom_components/smartthings/number.py @@ -72,7 +72,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): and device.type == "OCF" ): model = device.status.attributes[Attribute.mnmo].value.split("|")[0] - if model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K"): + if model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K","TP1X_REF_21K"): numbers.extend( [ SamsungOcfTemperatureNumber( diff --git a/custom_components/smartthings/select.py b/custom_components/smartthings/select.py index 3296d20..a53f573 100644 --- a/custom_components/smartthings/select.py +++ b/custom_components/smartthings/select.py @@ -84,7 +84,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): and "motionIndirect" in supported_ac_optional_modes ): selects.extend([SamsungACMotionSensorSaver(device)]) - elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K"): + elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K", "TP1X_REF_21K"): selects.extend([SamsungOcfDeliModeSelect(device)]) async_add_entities(selects) diff --git a/custom_components/smartthings/sensor.py b/custom_components/smartthings/sensor.py index 10efba7..28c5c88 100644 --- a/custom_components/smartthings/sensor.py +++ b/custom_components/smartthings/sensor.py @@ -652,7 +652,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ), ] ) - elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K"): + elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K","TP1X_REF_21K"): sensors.extend( [ SamsungOcfTemperatureSensor( From 1ac2c32d6655009daf3bb48000cc9f51af63a8c0 Mon Sep 17 00:00:00 2001 From: cgraf <2675875+cgraf@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:24:10 -0500 Subject: [PATCH 2/3] Fix deprecation warnings and support for TP1X_REF_21K Fixes recent deprecation warnings and includes addition of model from #81 --- custom_components/smartthings/__init__.py | 10 +- .../smartthings/binary_sensor.py | 37 +++--- custom_components/smartthings/climate.py | 124 ++++++++---------- custom_components/smartthings/const.py | 15 +-- custom_components/smartthings/cover.py | 22 ++-- custom_components/smartthings/fan.py | 4 +- custom_components/smartthings/sensor.py | 28 ++-- custom_components/smartthings/smartapp.py | 3 +- 8 files changed, 113 insertions(+), 130 deletions(-) diff --git a/custom_components/smartthings/__init__.py b/custom_components/smartthings/__init__.py index 257b758..d7f0c3d 100644 --- a/custom_components/smartthings/__init__.py +++ b/custom_components/smartthings/__init__.py @@ -24,6 +24,8 @@ from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType +from homeassistant.loader import async_get_loaded_integration +from homeassistant.setup import SetupPhases, async_pause_setup from .config_flow import SmartThingsFlowHandler # noqa: F401 from .const import ( @@ -154,7 +156,13 @@ async def retrieve_device_status(device): ) # Setup device broker - broker = DeviceBroker(hass, entry, token, smart_app, devices, scenes) + with async_pause_setup(hass, SetupPhases.WAIT_IMPORT_PLATFORMS): + # DeviceBroker has a side effect of importing platform + # modules when its created. In the future this should be + # refactored to not do this. + broker = await hass.async_add_import_executor_job( + DeviceBroker, hass, entry, token, smart_app, devices, scenes + ) broker.connect() hass.data[DOMAIN][DATA_BROKERS][entry.entry_id] = broker diff --git a/custom_components/smartthings/binary_sensor.py b/custom_components/smartthings/binary_sensor.py index 376232c..c27867e 100644 --- a/custom_components/smartthings/binary_sensor.py +++ b/custom_components/smartthings/binary_sensor.py @@ -10,17 +10,10 @@ import asyncio from homeassistant.components.binary_sensor import ( - DEVICE_CLASS_DOOR, - DEVICE_CLASS_MOISTURE, - DEVICE_CLASS_MOTION, - DEVICE_CLASS_MOVING, - DEVICE_CLASS_OPENING, - DEVICE_CLASS_PRESENCE, - DEVICE_CLASS_PROBLEM, - DEVICE_CLASS_SOUND, + BinarySensorDeviceClass, BinarySensorEntity, ) -from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC +from homeassistant.const import EntityCategory from . import SmartThingsEntity from .const import DATA_BROKERS, DOMAIN @@ -37,18 +30,18 @@ Capability.water_sensor: Attribute.water, } ATTRIB_TO_CLASS = { - Attribute.acceleration: DEVICE_CLASS_MOVING, - Attribute.contact: DEVICE_CLASS_OPENING, - Attribute.filter_status: DEVICE_CLASS_PROBLEM, - Attribute.motion: DEVICE_CLASS_MOTION, - Attribute.presence: DEVICE_CLASS_PRESENCE, - Attribute.sound: DEVICE_CLASS_SOUND, - Attribute.tamper: DEVICE_CLASS_PROBLEM, - Attribute.valve: DEVICE_CLASS_OPENING, - Attribute.water: DEVICE_CLASS_MOISTURE, + Attribute.acceleration: BinarySensorDeviceClass.MOVING, + Attribute.contact: BinarySensorDeviceClass.OPENING, + Attribute.filter_status: BinarySensorDeviceClass.PROBLEM, + Attribute.motion: BinarySensorDeviceClass.MOTION, + Attribute.presence: BinarySensorDeviceClass.PRESENCE, + Attribute.sound: BinarySensorDeviceClass.SOUND, + Attribute.tamper: BinarySensorDeviceClass.PROBLEM, + Attribute.valve: BinarySensorDeviceClass.OPENING, + Attribute.water: BinarySensorDeviceClass.MOISTURE, } ATTRIB_TO_ENTTIY_CATEGORY = { - Attribute.tamper: ENTITY_CATEGORY_DIAGNOSTIC, + Attribute.tamper: EntityCategory.DIAGNOSTIC, } @@ -84,7 +77,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): "/door/cooler/0", "Open", "Closed", - DEVICE_CLASS_DOOR, + BinarySensorDeviceClass.DOOR, ), SamsungOcfDoorBinarySensor( device, @@ -92,7 +85,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): "/door/freezer/0", "Open", "Closed", - DEVICE_CLASS_DOOR, + BinarySensorDeviceClass.DOOR, ), SamsungOcfDoorBinarySensor( device, @@ -100,7 +93,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): "/door/cvroom/0", "Open", "Closed", - DEVICE_CLASS_DOOR, + BinarySensorDeviceClass.DOOR, ), ] ) diff --git a/custom_components/smartthings/climate.py b/custom_components/smartthings/climate.py index 9313b3b..a6c537a 100644 --- a/custom_components/smartthings/climate.py +++ b/custom_components/smartthings/climate.py @@ -12,22 +12,8 @@ ATTR_HVAC_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - CURRENT_HVAC_COOL, - CURRENT_HVAC_FAN, - CURRENT_HVAC_HEAT, - CURRENT_HVAC_IDLE, - HVAC_MODE_AUTO, - HVAC_MODE_COOL, - HVAC_MODE_DRY, - HVAC_MODE_FAN_ONLY, - HVAC_MODE_HEAT, - HVAC_MODE_HEAT_COOL, - HVAC_MODE_OFF, - SUPPORT_FAN_MODE, - SUPPORT_SWING_MODE, - SUPPORT_TARGET_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE_RANGE, - SUPPORT_PRESET_MODE, + HVACAction, + HVACMode, ) from homeassistant.const import ATTR_TEMPERATURE @@ -36,50 +22,50 @@ ATTR_OPERATION_STATE = "operation_state" MODE_TO_STATE = { - "auto": HVAC_MODE_HEAT_COOL, - "cool": HVAC_MODE_COOL, - "eco": HVAC_MODE_AUTO, - "rush hour": HVAC_MODE_AUTO, - "emergency heat": HVAC_MODE_HEAT, - "heat": HVAC_MODE_HEAT, - "off": HVAC_MODE_OFF, - "wind": HVAC_MODE_FAN_ONLY, + "auto": HVACMode.HEAT_COOL, + "cool": HVACMode.COOL, + "eco": HVACMode.AUTO, + "rush hour": HVACMode.AUTO, + "emergency heat": HVACMode.HEAT, + "heat": HVACMode.HEAT, + "off": HVACMode.OFF, + "wind": HVACMode.FAN_ONLY, } STATE_TO_MODE = { - HVAC_MODE_HEAT_COOL: "auto", - HVAC_MODE_COOL: "cool", - HVAC_MODE_HEAT: "heat", - HVAC_MODE_OFF: "off", - HVAC_MODE_FAN_ONLY: "wind", + HVACMode.HEAT_COOL: "auto", + HVACMode.COOL: "cool", + HVACMode.HEAT: "heat", + HVACMode.OFF: "off", + HVACMode.FAN_ONLY: "wind", } OPERATING_STATE_TO_ACTION = { - "cooling": CURRENT_HVAC_COOL, - "fan only": CURRENT_HVAC_FAN, - "heating": CURRENT_HVAC_HEAT, - "idle": CURRENT_HVAC_IDLE, - "pending cool": CURRENT_HVAC_COOL, - "pending heat": CURRENT_HVAC_HEAT, - "vent economizer": CURRENT_HVAC_FAN, + "cooling": HVACAction.COOLING, + "fan only": HVACAction.FAN, + "heating": HVACAction.HEATING, + "idle": HVACAction.IDLE, + "pending cool": HVACAction.COOLING, + "pending heat": HVACAction.HEATING, + "vent economizer": HVACAction.FAN, } AC_MODE_TO_STATE = { - "auto": HVAC_MODE_HEAT_COOL, - "cool": HVAC_MODE_COOL, - "dry": HVAC_MODE_DRY, - "coolClean": HVAC_MODE_COOL, - "dryClean": HVAC_MODE_DRY, - "heat": HVAC_MODE_HEAT, - "heatClean": HVAC_MODE_HEAT, - "fanOnly": HVAC_MODE_FAN_ONLY, - "wind": HVAC_MODE_FAN_ONLY, + "auto": HVACMode.HEAT_COOL, + "cool": HVACMode.COOL, + "dry": HVACMode.DRY, + "coolClean": HVACMode.COOL, + "dryClean": HVACMode.DRY, + "heat": HVACMode.HEAT, + "heatClean": HVACMode.HEAT, + "fanOnly": HVACMode.FAN_ONLY, + "wind": HVACMode.FAN_ONLY, } STATE_TO_AC_MODE = { - HVAC_MODE_HEAT_COOL: "auto", - HVAC_MODE_COOL: "cool", - HVAC_MODE_DRY: "dry", - HVAC_MODE_HEAT: "heat", - HVAC_MODE_FAN_ONLY: "wind", + HVACMode.HEAT_COOL: "auto", + HVACMode.COOL: "cool", + HVACMode.DRY: "dry", + HVACMode.HEAT: "heat", + HVACMode.FAN_ONLY: "wind", } @@ -162,11 +148,11 @@ def __init__(self, device): self._hvac_modes = None def _determine_features(self): - flags = SUPPORT_TARGET_TEMPERATURE | SUPPORT_TARGET_TEMPERATURE_RANGE + flags = ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE if self._device.get_capability( Capability.thermostat_fan_mode, Capability.thermostat ): - flags |= SUPPORT_FAN_MODE + flags |= ClimateEntityFeature.FAN_MODE return flags async def async_set_fan_mode(self, fan_mode): @@ -197,9 +183,9 @@ async def async_set_temperature(self, **kwargs): # Heat/cool setpoint heating_setpoint = None cooling_setpoint = None - if self.hvac_mode == HVAC_MODE_HEAT: + if self.hvac_mode == HVACMode.HEAT: heating_setpoint = kwargs.get(ATTR_TEMPERATURE) - elif self.hvac_mode == HVAC_MODE_COOL: + elif self.hvac_mode == HVACMode.COOL: cooling_setpoint = kwargs.get(ATTR_TEMPERATURE) else: heating_setpoint = kwargs.get(ATTR_TARGET_TEMP_LOW) @@ -302,23 +288,23 @@ def supported_features(self): @property def target_temperature(self): """Return the temperature we try to reach.""" - if self.hvac_mode == HVAC_MODE_COOL: + if self.hvac_mode == HVACMode.COOL: return self._device.status.cooling_setpoint - if self.hvac_mode == HVAC_MODE_HEAT: + if self.hvac_mode == HVACMode.HEAT: return self._device.status.heating_setpoint return None @property def target_temperature_high(self): """Return the highbound target temperature we try to reach.""" - if self.hvac_mode == HVAC_MODE_HEAT_COOL: + if self.hvac_mode == HVACMode.HEAT_COOL: return self._device.status.cooling_setpoint return None @property def target_temperature_low(self): """Return the lowbound target temperature we try to reach.""" - if self.hvac_mode == HVAC_MODE_HEAT_COOL: + if self.hvac_mode == HVACMode.HEAT_COOL: return self._device.status.heating_setpoint return None @@ -379,7 +365,7 @@ async def async_set_swing_mode(self, swing_mode): async def async_set_hvac_mode(self, hvac_mode): """Set new target operation mode.""" - if hvac_mode == HVAC_MODE_OFF: + if hvac_mode == HVACMode.OFF: await self.async_turn_off() return tasks = [] @@ -401,7 +387,7 @@ async def async_set_temperature(self, **kwargs): tasks = [] # operation mode if operation_mode := kwargs.get(ATTR_HVAC_MODE): - if operation_mode == HVAC_MODE_OFF: + if operation_mode == HVACMode.OFF: tasks.append(self._device.switch_off(set_status=True)) else: if not self._device.status.switch: @@ -432,7 +418,7 @@ async def async_turn_off(self): async def async_update(self): """Update the calculated fields of the AC.""" - modes = {HVAC_MODE_OFF} + modes = {HVACMode.OFF} for mode in self._device.status.supported_ac_modes: if (state := AC_MODE_TO_STATE.get(mode)) is not None: modes.add(state) @@ -542,7 +528,7 @@ def preset_modes(self): def hvac_mode(self): """Return current operation ie. heat, cool, idle.""" if not self._device.status.switch: - return HVAC_MODE_OFF + return HVACMode.OFF return AC_MODE_TO_STATE.get(self._device.status.air_conditioner_mode) @property @@ -559,15 +545,15 @@ def supported_features(self): ] if len(supported_ac_optional_modes) == 1 and supported_ac_optional_modes[0] == "off": return ( - SUPPORT_TARGET_TEMPERATURE - | SUPPORT_FAN_MODE - | SUPPORT_SWING_MODE + ClimateEntityFeature.TARGET_TEMPERATURE + | ClimateEntityFeature.FAN_MODE + | ClimateEntityFeature.SWING_MODE ) return ( - SUPPORT_TARGET_TEMPERATURE - | SUPPORT_FAN_MODE - | SUPPORT_SWING_MODE - | SUPPORT_PRESET_MODE + ClimateEntityFeature.TARGET_TEMPERATURE + | ClimateEntityFeature.FAN_MODE + | ClimateEntityFeature.SWING_MODE + | ClimateEntityFeature.PRESET_MODE ) @property diff --git a/custom_components/smartthings/const.py b/custom_components/smartthings/const.py index 45f9929..0b9bc1e 100644 --- a/custom_components/smartthings/const.py +++ b/custom_components/smartthings/const.py @@ -3,11 +3,10 @@ import re from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, + UnitOfElectricPotential, PERCENTAGE, - POWER_WATT, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfPower, + UnitOfTemperature, ) DOMAIN = "smartthings" @@ -60,13 +59,13 @@ ] UNIT_MAP = { - "C": TEMP_CELSIUS, - "F": TEMP_FAHRENHEIT, + "C": UnitOfTemperature.CELSIUS, + "F": UnitOfTemperature.FAHRENHEIT, "Hour": "Hour", "minute": "Minute", "%": PERCENTAGE, - "W": POWER_WATT, - "V": ELECTRIC_POTENTIAL_VOLT, + "W": UnitOfPower.WATT, + "V": UnitOfElectricPotential.VOLT, } TOKEN_REFRESH_INTERVAL = timedelta(days=14) diff --git a/custom_components/smartthings/cover.py b/custom_components/smartthings/cover.py index 66715ed..bec26e3 100644 --- a/custom_components/smartthings/cover.py +++ b/custom_components/smartthings/cover.py @@ -7,17 +7,13 @@ from homeassistant.components.cover import ( ATTR_POSITION, - DEVICE_CLASS_DOOR, - DEVICE_CLASS_GARAGE, - DEVICE_CLASS_SHADE, + CoverEntityFeature, + CoverDeviceClass, DOMAIN as COVER_DOMAIN, STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING, - SUPPORT_CLOSE, - SUPPORT_OPEN, - SUPPORT_SET_POSITION, CoverEntity, ) from homeassistant.const import ATTR_BATTERY_LEVEL @@ -72,9 +68,9 @@ def __init__(self, device): self._device_class = None self._state = None self._state_attrs = None - self._supported_features = SUPPORT_OPEN | SUPPORT_CLOSE + self._supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE if Capability.switch_level in device.capabilities: - self._supported_features |= SUPPORT_SET_POSITION + self._supported_features |= CoverEntityFeature.SET_POSITION async def async_close_cover(self, **kwargs): """Close cover.""" @@ -94,7 +90,7 @@ async def async_open_cover(self, **kwargs): async def async_set_cover_position(self, **kwargs): """Move the cover to a specific position.""" - if not self._supported_features & SUPPORT_SET_POSITION: + if not self._supported_features & CoverEntityFeature.SET_POSITION: return # Do not set_status=True as device will report progress. await self._device.set_level(kwargs[ATTR_POSITION], 0) @@ -103,13 +99,13 @@ async def async_update(self): """Update the attrs of the cover.""" value = None if Capability.door_control in self._device.capabilities: - self._device_class = DEVICE_CLASS_DOOR + self._device_class = CoverEntityFeature.DOOR value = self._device.status.door elif Capability.window_shade in self._device.capabilities: - self._device_class = DEVICE_CLASS_SHADE + self._device_class = CoverEntityFeature.SHADE value = self._device.status.window_shade elif Capability.garage_door_control in self._device.capabilities: - self._device_class = DEVICE_CLASS_GARAGE + self._device_class = CoverEntityFeature.GARAGE value = self._device.status.door self._state = VALUE_TO_STATE.get(value) @@ -139,7 +135,7 @@ def is_closed(self): @property def current_cover_position(self): """Return current position of cover.""" - if not self._supported_features & SUPPORT_SET_POSITION: + if not self._supported_features & CoverEntityFeature.SET_POSITION: return None return self._device.status.level diff --git a/custom_components/smartthings/fan.py b/custom_components/smartthings/fan.py index 62b84b1..d006c5f 100644 --- a/custom_components/smartthings/fan.py +++ b/custom_components/smartthings/fan.py @@ -6,7 +6,7 @@ from pysmartthings import Capability -from homeassistant.components.fan import SUPPORT_SET_SPEED, FanEntity +from homeassistant.components.fan import FanEntityFeature, FanEntity from homeassistant.util.percentage import ( int_states_in_range, percentage_to_ranged_value, @@ -90,4 +90,4 @@ def speed_count(self) -> int: @property def supported_features(self) -> int: """Flag supported features.""" - return SUPPORT_SET_SPEED + return FanEntityFeature.SET_SPEED diff --git a/custom_components/smartthings/sensor.py b/custom_components/smartthings/sensor.py index 28c5c88..fa7cb03 100644 --- a/custom_components/smartthings/sensor.py +++ b/custom_components/smartthings/sensor.py @@ -20,13 +20,13 @@ from homeassistant.const import ( AREA_SQUARE_METERS, CONCENTRATION_PARTS_PER_MILLION, - ELECTRIC_POTENTIAL_VOLT, - ENERGY_KILO_WATT_HOUR, + UnitOfElectricPotential, + UnitOfEnergy, LIGHT_LUX, - MASS_KILOGRAMS, + UnitOfMass, PERCENTAGE, - POWER_WATT, - VOLUME_CUBIC_METERS, + UnitOfPower, + UnitOfVolume, ) from homeassistant.helpers.entity import EntityCategory @@ -88,7 +88,7 @@ Map( Attribute.bmi_measurement, "Body Mass Index", - f"{MASS_KILOGRAMS}/{AREA_SQUARE_METERS}", + f"{UnitOfMass.KILOGRAMS}/{AREA_SQUARE_METERS}", None, SensorStateClass.MEASUREMENT, None, @@ -98,7 +98,7 @@ Map( Attribute.body_weight_measurement, "Body Weight", - MASS_KILOGRAMS, + UnitOfMass.KILOGRAMS, None, SensorStateClass.MEASUREMENT, None, @@ -199,7 +199,7 @@ Map( Attribute.energy, "Energy Meter", - ENERGY_KILO_WATT_HOUR, + UnitOfEnergy.KILO_WATT_HOUR, SensorDeviceClass.ENERGY, SensorStateClass.TOTAL_INCREASING, None, @@ -229,7 +229,7 @@ Map( Attribute.gas_meter, "Gas Meter", - ENERGY_KILO_WATT_HOUR, + UnitOfEnergy.KILO_WATT_HOUR, None, SensorStateClass.MEASUREMENT, None, @@ -248,7 +248,7 @@ Map( Attribute.gas_meter_volume, "Gas Meter Volume", - VOLUME_CUBIC_METERS, + UnitOfVolume.CUBIC_METERS, None, SensorStateClass.MEASUREMENT, None, @@ -337,7 +337,7 @@ Map( Attribute.power, "Power Meter", - POWER_WATT, + UnitOfPower.WATT, SensorDeviceClass.POWER, SensorStateClass.MEASUREMENT, None, @@ -523,7 +523,7 @@ Map( Attribute.voltage, "Voltage Measurement", - ELECTRIC_POTENTIAL_VOLT, + UnitOfElectricPotential.VOLT, SensorDeviceClass.VOLTAGE, SensorStateClass.MEASUREMENT, None, @@ -823,8 +823,8 @@ def device_class(self): def native_unit_of_measurement(self): """Return the unit this state is expressed in.""" if self.report_name == "power": - return POWER_WATT - return ENERGY_KILO_WATT_HOUR + return UnitOfPower.WATT + return UnitOfEnergy.KILO_WATT_HOUR @property def icon(self) -> str | None: diff --git a/custom_components/smartthings/smartapp.py b/custom_components/smartthings/smartapp.py index 8aab27a..b625e6a 100644 --- a/custom_components/smartthings/smartapp.py +++ b/custom_components/smartthings/smartapp.py @@ -3,6 +3,7 @@ import functools import logging import secrets +from homeassistant.helpers.storage import Store from urllib.parse import urlparse from uuid import uuid4 @@ -209,7 +210,7 @@ async def setup_smartapp_endpoint(hass: HomeAssistant): return # Get/create config to store a unique id for this hass instance. - store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY) + store = Store(hass, STORAGE_VERSION, STORAGE_KEY) config = await store.async_load() if not config: # Create config From e08fe83f72120f5d4aa3d1060c6e1fdcd202ad59 Mon Sep 17 00:00:00 2001 From: cgraf <2675875+cgraf@users.noreply.github.com> Date: Tue, 6 Aug 2024 08:57:52 -0500 Subject: [PATCH 3/3] Update switch.py Add rapid freeze, rapid cool and icemaker to TP1X_REF_21K --- custom_components/smartthings/switch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/smartthings/switch.py b/custom_components/smartthings/switch.py index 58285c6..69f4588 100644 --- a/custom_components/smartthings/switch.py +++ b/custom_components/smartthings/switch.py @@ -146,7 +146,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities): ) ] ) - elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K"): + elif model in ("21K_REF_LCD_FHUB6.0", "ARTIK051_REF_17K","TP1X_REF_21K"): switches.extend( [ SamsungOcfSwitch(