Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Deprecated Constants or Remove Unused Ones #219

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions custom_components/ge_home/devices/cooktop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List
from gehomesdk.erd.erd_data_type import ErdDataType

from homeassistant.const import DEVICE_CLASS_POWER_FACTOR
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.helpers.entity import Entity
from gehomesdk import (
ErdCode,
Expand Down Expand Up @@ -44,7 +44,7 @@ def get_all_entities(self) -> List[Entity]:
cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, prop+".on"))
cooktop_entities.append(GeErdPropertyBinarySensor(self, ErdCode.COOKTOP_STATUS, prop+".synchronized"))
if not v.on_off_only:
cooktop_entities.append(GeErdPropertySensor(self, ErdCode.COOKTOP_STATUS, prop+".power_pct", icon_override="mdi:fire", device_class_override=DEVICE_CLASS_POWER_FACTOR, data_type_override=ErdDataType.INT))
cooktop_entities.append(GeErdPropertySensor(self, ErdCode.COOKTOP_STATUS, prop+".power_pct", icon_override="mdi:fire", device_class_override=SensorDeviceClass.POWER_FACTOR, data_type_override=ErdDataType.INT))

return base_entities + cooktop_entities

Expand Down
4 changes: 2 additions & 2 deletions custom_components/ge_home/devices/fridge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from homeassistant.components.binary_sensor import DEVICE_CLASS_PROBLEM
from homeassistant.const import DEVICE_CLASS_TEMPERATURE
from homeassistant.components.sensor import SensorDeviceClass
import logging
from typing import List

Expand Down Expand Up @@ -129,7 +129,7 @@ def get_all_entities(self) -> List[Entity]:
GeErdSensor(self, ErdCode.HOT_WATER_SET_TEMP),
GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "status", icon_override="mdi:information-outline"),
GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "time_until_ready", icon_override="mdi:timer-outline"),
GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "current_temp", device_class_override=DEVICE_CLASS_TEMPERATURE, data_type_override=ErdDataType.INT),
GeErdPropertySensor(self, ErdCode.HOT_WATER_STATUS, "current_temp", device_class_override=SensorDeviceClass.TEMPERATURE, data_type_override=ErdDataType.INT),
GeErdPropertyBinarySensor(self, ErdCode.HOT_WATER_STATUS, "faulted", device_class_override=DEVICE_CLASS_PROBLEM),
GeDispenser(self)
])
Expand Down
4 changes: 2 additions & 2 deletions custom_components/ge_home/devices/oven.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List
from gehomesdk.erd.erd_data_type import ErdDataType

from homeassistant.const import DEVICE_CLASS_POWER_FACTOR
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.helpers.entity import Entity
from gehomesdk import (
ErdCode,
Expand Down Expand Up @@ -120,7 +120,7 @@ def get_all_entities(self) -> List[Entity]:
cooktop_entities.append(GeErdPropertyBinarySensor(self, cooktop_status_erd, prop+".on"))
cooktop_entities.append(GeErdPropertyBinarySensor(self, cooktop_status_erd, prop+".synchronized"))
if not v.on_off_only:
cooktop_entities.append(GeErdPropertySensor(self, cooktop_status_erd, prop+".power_pct", icon_override="mdi:fire", device_class_override=DEVICE_CLASS_POWER_FACTOR, data_type_override=ErdDataType.INT))
cooktop_entities.append(GeErdPropertySensor(self, cooktop_status_erd, prop+".power_pct", icon_override="mdi:fire", device_class_override=SensorDeviceClass.POWER_FACTOR, data_type_override=ErdDataType.INT))

return base_entities + oven_entities + cooktop_entities

Expand Down
5 changes: 0 additions & 5 deletions custom_components/ge_home/entities/ac/fan_mode_options.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import logging
from typing import Any, List, Optional

from homeassistant.components.climate.const import (
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_FAN_ONLY,
)
from gehomesdk import ErdAcFanSetting
from ..common import OptionsConverter

Expand Down
24 changes: 10 additions & 14 deletions custom_components/ge_home/entities/ac/ge_biac_climate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import logging
from typing import Any, List, Optional

from homeassistant.components.climate.const import (
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_FAN_ONLY,
)
from homeassistant.components.climate import HVACMode
from gehomesdk import ErdAcOperationMode
from ...devices import ApplianceApi
from ..common import GeClimate, OptionsConverter
Expand All @@ -16,28 +12,28 @@
class BiacHvacModeOptionsConverter(OptionsConverter):
@property
def options(self) -> List[str]:
return [HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_FAN_ONLY]
return [HVACMode.AUTO, HVACMode.COOL, HVACMode.FAN_ONLY]
def from_option_string(self, value: str) -> Any:
try:
return {
HVAC_MODE_AUTO: ErdAcOperationMode.ENERGY_SAVER,
HVAC_MODE_COOL: ErdAcOperationMode.COOL,
HVAC_MODE_FAN_ONLY: ErdAcOperationMode.FAN_ONLY
HVACMode.AUTO: ErdAcOperationMode.ENERGY_SAVER,
HVACMode.COOL: ErdAcOperationMode.COOL,
HVACMode.FAN_ONLY: ErdAcOperationMode.FAN_ONLY
}.get(value)
except:
_LOGGER.warn(f"Could not set HVAC mode to {value.upper()}")
return ErdAcOperationMode.COOL
def to_option_string(self, value: Any) -> Optional[str]:
try:
return {
ErdAcOperationMode.ENERGY_SAVER: HVAC_MODE_AUTO,
ErdAcOperationMode.AUTO: HVAC_MODE_AUTO,
ErdAcOperationMode.COOL: HVAC_MODE_COOL,
ErdAcOperationMode.FAN_ONLY: HVAC_MODE_FAN_ONLY
ErdAcOperationMode.ENERGY_SAVER: HVACMode.AUTO,
ErdAcOperationMode.AUTO: HVACMode.AUTO,
ErdAcOperationMode.COOL: HVACMode.COOL,
ErdAcOperationMode.FAN_ONLY: HVACMode.FAN_ONLY
}.get(value)
except:
_LOGGER.warn(f"Could not determine operation mode mapping for {value}")
return HVAC_MODE_COOL
return HVACMode.COOL

class GeBiacClimate(GeClimate):
"""Class for Built-In AC units"""
Expand Down
36 changes: 13 additions & 23 deletions custom_components/ge_home/entities/ac/ge_pac_climate.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import logging
from typing import Any, List, Optional


from homeassistant.const import (
TEMP_FAHRENHEIT
)
from homeassistant.components.climate.const import (
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_DRY,
HVAC_MODE_FAN_ONLY,
HVAC_MODE_HEAT,
)
from homeassistant.components.climate import HVACMode
from gehomesdk import ErdCode, ErdAcOperationMode, ErdSacAvailableModes, ErdSacTargetTemperatureRange
from ...devices import ApplianceApi
from ..common import GeClimate, OptionsConverter
Expand All @@ -25,34 +15,34 @@ def __init__(self, available_modes: ErdSacAvailableModes):

@property
def options(self) -> List[str]:
modes = [HVAC_MODE_COOL, HVAC_MODE_FAN_ONLY]
modes = [HVACMode.COOL, HVACMode.FAN_ONLY]
if self._available_modes and self._available_modes.has_heat:
modes.append(HVAC_MODE_HEAT)
modes.append(HVACMode.HEAT)
if self._available_modes and self._available_modes.has_dry:
modes.append(HVAC_MODE_DRY)
modes.append(HVACMode.DRY)
return modes
def from_option_string(self, value: str) -> Any:
try:
return {
HVAC_MODE_COOL: ErdAcOperationMode.COOL,
HVAC_MODE_HEAT: ErdAcOperationMode.HEAT,
HVAC_MODE_FAN_ONLY: ErdAcOperationMode.FAN_ONLY,
HVAC_MODE_DRY: ErdAcOperationMode.DRY
HVACMode.COOL: ErdAcOperationMode.COOL,
HVACMode.HEAT: ErdAcOperationMode.HEAT,
HVACMode.FAN_ONLY: ErdAcOperationMode.FAN_ONLY,
HVACMode.DRY: ErdAcOperationMode.DRY
}.get(value)
except:
_LOGGER.warn(f"Could not set HVAC mode to {value.upper()}")
return ErdAcOperationMode.COOL
def to_option_string(self, value: Any) -> Optional[str]:
try:
return {
ErdAcOperationMode.COOL: HVAC_MODE_COOL,
ErdAcOperationMode.HEAT: HVAC_MODE_HEAT,
ErdAcOperationMode.DRY: HVAC_MODE_DRY,
ErdAcOperationMode.FAN_ONLY: HVAC_MODE_FAN_ONLY
ErdAcOperationMode.COOL: HVACMode.COOL,
ErdAcOperationMode.HEAT: HVACMode.HEAT,
ErdAcOperationMode.DRY: HVACMode.DRY,
ErdAcOperationMode.FAN_ONLY: HVACMode.FAN_ONLY
}.get(value)
except:
_LOGGER.warn(f"Could not determine operation mode mapping for {value}")
return HVAC_MODE_COOL
return HVACMode.COOL

class GePacClimate(GeClimate):
"""Class for Portable AC units"""
Expand Down
43 changes: 17 additions & 26 deletions custom_components/ge_home/entities/ac/ge_sac_climate.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import logging
from typing import Any, List, Optional

from homeassistant.const import (
TEMP_FAHRENHEIT
)
from homeassistant.components.climate.const import (
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_DRY,
HVAC_MODE_FAN_ONLY,
HVAC_MODE_HEAT,
)
from homeassistant.components.climate import HVACMode
from gehomesdk import ErdCode, ErdAcOperationMode, ErdSacAvailableModes, ErdSacTargetTemperatureRange
from ...devices import ApplianceApi
from ..common import GeClimate, OptionsConverter
Expand All @@ -24,38 +15,38 @@ def __init__(self, available_modes: ErdSacAvailableModes):

@property
def options(self) -> List[str]:
modes = [HVAC_MODE_COOL, HVAC_MODE_FAN_ONLY]
modes = [HVACMode.COOL, HVACMode.FAN_ONLY]
if self._available_modes and self._available_modes.has_heat:
modes.append(HVAC_MODE_HEAT)
modes.append(HVAC_MODE_AUTO)
modes.append(HVACMode.HEAT)
modes.append(HVACMode.AUTO)
if self._available_modes and self._available_modes.has_dry:
modes.append(HVAC_MODE_DRY)
modes.append(HVACMode.DRY)
return modes
def from_option_string(self, value: str) -> Any:
try:
return {
HVAC_MODE_AUTO: ErdAcOperationMode.AUTO,
HVAC_MODE_COOL: ErdAcOperationMode.COOL,
HVAC_MODE_HEAT: ErdAcOperationMode.HEAT,
HVAC_MODE_FAN_ONLY: ErdAcOperationMode.FAN_ONLY,
HVAC_MODE_DRY: ErdAcOperationMode.DRY
HVACMode.AUTO: ErdAcOperationMode.AUTO,
HVACMode.COOL: ErdAcOperationMode.COOL,
HVACMode.HEAT: ErdAcOperationMode.HEAT,
HVACMode.FAN_ONLY: ErdAcOperationMode.FAN_ONLY,
HVACMode.DRY: ErdAcOperationMode.DRY
}.get(value)
except:
_LOGGER.warn(f"Could not set HVAC mode to {value.upper()}")
return ErdAcOperationMode.COOL
def to_option_string(self, value: Any) -> Optional[str]:
try:
return {
ErdAcOperationMode.ENERGY_SAVER: HVAC_MODE_AUTO,
ErdAcOperationMode.AUTO: HVAC_MODE_AUTO,
ErdAcOperationMode.COOL: HVAC_MODE_COOL,
ErdAcOperationMode.HEAT: HVAC_MODE_HEAT,
ErdAcOperationMode.DRY: HVAC_MODE_DRY,
ErdAcOperationMode.FAN_ONLY: HVAC_MODE_FAN_ONLY
ErdAcOperationMode.ENERGY_SAVER: HVACMode.AUTO,
ErdAcOperationMode.AUTO: HVACMode.AUTO,
ErdAcOperationMode.COOL: HVACMode.COOL,
ErdAcOperationMode.HEAT: HVACMode.HEAT,
ErdAcOperationMode.DRY: HVACMode.DRY,
ErdAcOperationMode.FAN_ONLY: HVACMode.FAN_ONLY
}.get(value)
except:
_LOGGER.warn(f"Could not determine operation mode mapping for {value}")
return HVAC_MODE_COOL
return HVACMode.COOL

class GeSacClimate(GeClimate):
"""Class for Split AC units"""
Expand Down
24 changes: 10 additions & 14 deletions custom_components/ge_home/entities/ac/ge_wac_climate.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import logging
from typing import Any, List, Optional

from homeassistant.components.climate.const import (
HVAC_MODE_AUTO,
HVAC_MODE_COOL,
HVAC_MODE_FAN_ONLY,
)
from homeassistant.components.climate import HVACMode
from gehomesdk import ErdAcOperationMode
from ...devices import ApplianceApi
from ..common import GeClimate, OptionsConverter
Expand All @@ -16,28 +12,28 @@
class WacHvacModeOptionsConverter(OptionsConverter):
@property
def options(self) -> List[str]:
return [HVAC_MODE_AUTO, HVAC_MODE_COOL, HVAC_MODE_FAN_ONLY]
return [HVACMode.AUTO, HVACMode.COOL, HVACMode.FAN_ONLY]
def from_option_string(self, value: str) -> Any:
try:
return {
HVAC_MODE_AUTO: ErdAcOperationMode.ENERGY_SAVER,
HVAC_MODE_COOL: ErdAcOperationMode.COOL,
HVAC_MODE_FAN_ONLY: ErdAcOperationMode.FAN_ONLY
HVACMode.AUTO: ErdAcOperationMode.ENERGY_SAVER,
HVACMode.COOL: ErdAcOperationMode.COOL,
HVACMode.FAN_ONLY: ErdAcOperationMode.FAN_ONLY
}.get(value)
except:
_LOGGER.warn(f"Could not set HVAC mode to {value.upper()}")
return ErdAcOperationMode.COOL
def to_option_string(self, value: Any) -> Optional[str]:
try:
return {
ErdAcOperationMode.ENERGY_SAVER: HVAC_MODE_AUTO,
ErdAcOperationMode.AUTO: HVAC_MODE_AUTO,
ErdAcOperationMode.COOL: HVAC_MODE_COOL,
ErdAcOperationMode.FAN_ONLY: HVAC_MODE_FAN_ONLY
ErdAcOperationMode.ENERGY_SAVER: HVACMode.AUTO,
ErdAcOperationMode.AUTO: HVACMode.AUTO,
ErdAcOperationMode.COOL: HVACMode.COOL,
ErdAcOperationMode.FAN_ONLY: HVACMode.FAN_ONLY
}.get(value)
except:
_LOGGER.warn(f"Could not determine operation mode mapping for {value}")
return HVAC_MODE_COOL
return HVACMode.COOL

class GeWacClimate(GeClimate):
"""Class for Window AC units"""
Expand Down
9 changes: 3 additions & 6 deletions custom_components/ge_home/entities/advantium/const.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
from homeassistant.components.water_heater import (
SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE
)
from homeassistant.components.water_heater import WaterHeaterEntityFeature

SUPPORT_NONE = 0
GE_ADVANTIUM_WITH_TEMPERATURE = (SUPPORT_OPERATION_MODE | SUPPORT_TARGET_TEMPERATURE)
GE_ADVANTIUM = SUPPORT_OPERATION_MODE
GE_ADVANTIUM_WITH_TEMPERATURE = (WaterHeaterEntityFeature.OPERATION_MODE | WaterHeaterEntityFeature.TARGET_TEMPERATURE)
GE_ADVANTIUM = WaterHeaterEntityFeature.OPERATION_MODE
5 changes: 3 additions & 2 deletions custom_components/ge_home/entities/advantium/ge_advantium.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
)
from gehomesdk.erd.values.advantium.advantium_enums import CookAction, CookMode

from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.components.sensor import SensorDeviceClass
from homeassistant.const import ATTR_TEMPERATURE
from ...const import DOMAIN
from ...devices import ApplianceApi
from ..common import GeAbstractWaterHeater
Expand Down Expand Up @@ -272,7 +273,7 @@ async def _ensure_operation_mode(self):
async def _convert_target_temperature(self, temp_120v: int, temp_240v: int):
unit_type = self.unit_type
target_temp_f = temp_240v if unit_type in [ErdUnitType.TYPE_240V_MONOGRAM, ErdUnitType.TYPE_240V_CAFE] else temp_120v
if self.temperature_unit == TEMP_FAHRENHEIT:
if self.temperature_unit == SensorDeviceClass.FAHRENHEIT:
return float(target_temp_f)
else:
return (target_temp_f - 32.0) * (5/9)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from ...devices import ApplianceApi
from ..common import GeErdNumber
from .ge_ccm_cached_value import GeCcmCachedValue
from homeassistant.const import TEMP_FAHRENHEIT

class GeCcmBrewTemperatureNumber(GeErdNumber, GeCcmCachedValue):
def __init__(self, api: ApplianceApi):
Expand Down
Loading