Skip to content

Commit

Permalink
Merge pull request #86 from tadasdanielius/85-deprication-warnings-wi…
Browse files Browse the repository at this point in the history
…th-ha-20241

Fix depricated constants
  • Loading branch information
tadasdanielius authored Jan 3, 2024
2 parents 84d6305 + baca2d7 commit fa1fc92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
11 changes: 5 additions & 6 deletions custom_components/daikin_altherma/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""The Daikin Altherma integration."""
from __future__ import annotations

import async_timeout
import json
import logging
import os
from aiohttp import ClientConnectionError, ServerTimeoutError
from asyncio import CancelledError
from datetime import timedelta

import async_timeout
from aiohttp import ClientConnectionError, ServerTimeoutError
from homeassistant.components.water_heater import STATE_OFF, STATE_ON, STATE_PERFORMANCE
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST
Expand Down Expand Up @@ -35,12 +34,12 @@ async def setup_api_instance(hass, host):
unit_profiles = device.profiles

# Uncomment this if you want to store profile info in json files.
#try:
# try:
# for profile in unit_profiles:
# filepath: str = os.path.join(hass.config.config_dir, f'daikin_altherma_{profile["idx"]}.json')
# with open(filepath, 'w') as f:
# f.write(json.dumps(profile['profile']))
#except Exception as e:
# except Exception as e:
# _LOGGER.warning(f'Failed to save profile state to file {filepath}. It does not affect the operation of the integration.', exc_info=True)

api = AlthermaAPI(device)
Expand Down
6 changes: 3 additions & 3 deletions custom_components/daikin_altherma/number.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from homeassistant.components.number import NumberEntity
from homeassistant.const import TEMP_CELSIUS
from homeassistant.const import UnitOfTemperature
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
)
Expand Down Expand Up @@ -74,7 +74,7 @@ def __init__(self, coordinator, api: AlthermaAPI, name: str, operation: str, pro
self._attr_device_info = api.space_heating_device_info
self._attr_unique_id = f"{self._api.info['serial_number']}-{operation}-SpaceHeating-control"
self._attr_icon = 'mdi:sun-thermometer-outline'
self._attr_native_unit_of_measurement = TEMP_CELSIUS
self._attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS

@property
def native_value(self) -> float:
Expand Down Expand Up @@ -131,7 +131,7 @@ def __init__(self, coordinator, api: AlthermaAPI):
self._attr_unique_id = f"{self._api.info['serial_number']}-SpaceHeating-temp-control"
self._attr_options = [x.value for x in list(ClimateControlMode)]
self._attr_icon = 'mdi:sun-thermometer-outline'
self._attr_native_unit_of_measurement = TEMP_CELSIUS
self._attr_native_unit_of_measurement = UnitOfTemperature.CELSIUS

@property
def native_value(self) -> float:
Expand Down
9 changes: 4 additions & 5 deletions custom_components/daikin_altherma/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
STATE_OFF,
STATE_ON,
STATE_PERFORMANCE,
SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE,
WaterHeaterEntity,
WaterHeaterEntityFeature
)
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.const import UnitOfTemperature, ATTR_TEMPERATURE
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
)
Expand All @@ -20,7 +19,7 @@

OPERATION_LIST_NO_PERF = [STATE_OFF, STATE_ON]

SUPPORT_FLAGS_HEATER = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE
SUPPORT_FLAGS_HEATER = WaterHeaterEntityFeature.TARGET_TEMPERATURE | WaterHeaterEntityFeature.OPERATION_MODE


async def async_setup_entry(hass, entry, async_add_entities):
Expand All @@ -34,7 +33,7 @@ async def async_setup_entry(hass, entry, async_add_entities):


class AlthermaWaterHeater(WaterHeaterEntity, CoordinatorEntity):
_attr_temperature_unit = TEMP_CELSIUS
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_operation_list = OPERATION_LIST
_attr_supported_features = SUPPORT_FLAGS_HEATER

Expand Down

0 comments on commit fa1fc92

Please sign in to comment.