Skip to content

Commit

Permalink
fix: EventType and StrEnum was deprecated
Browse files Browse the repository at this point in the history
Fixes #177
  • Loading branch information
= authored and swingerman committed May 3, 2024
1 parent 2111365 commit 9c6cd5b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
16 changes: 6 additions & 10 deletions custom_components/dual_smart_thermostat/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.core import CoreState, HomeAssistant, ServiceCall, callback
from homeassistant.core import CoreState, Event, HomeAssistant, ServiceCall, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
Expand All @@ -45,7 +45,7 @@
from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.service import extract_entity_ids
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, EventType
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import voluptuous as vol

from custom_components.dual_smart_thermostat.hvac_action_reason.hvac_action_reason_external import (
Expand Down Expand Up @@ -730,9 +730,7 @@ def max_temp(self) -> float:
# Get default temp from super class
return super().max_temp

async def _async_sensor_changed(
self, event: EventType[EventStateChangedData]
) -> None:
async def _async_sensor_changed(self, event: Event[EventStateChangedData]) -> None:
"""Handle temperature changes."""
new_state = event.data.get("new_state")
_LOGGER.info("Sensor change: %s", new_state)
Expand All @@ -747,7 +745,7 @@ async def _async_sensor_changed(
self.async_write_ha_state()

async def _async_sensor_floor_changed(
self, event: EventType[EventStateChangedData]
self, event: Event[EventStateChangedData]
) -> None:
"""Handle floor temperature changes."""
new_state = event.data.get("new_state")
Expand All @@ -768,9 +766,7 @@ async def _check_device_initial_state(self) -> None:
)
await self.hvac_device.async_turn_off()

async def _async_opening_changed(
self, event: EventType[EventStateChangedData]
) -> None:
async def _async_opening_changed(self, event: Event[EventStateChangedData]) -> None:
"""Handle opening changes."""
new_state = event.data.get("new_state")
_LOGGER.info("Opening changed: %s", new_state)
Expand Down Expand Up @@ -832,7 +828,7 @@ def _async_hvac_mode_changed(self, hvac_mode) -> None:
self.async_write_ha_state()

@callback
def _async_switch_changed(self, event: EventType[EventStateChangedData]) -> None:
def _async_switch_changed(self, event: Event[EventStateChangedData]) -> None:
"""Handle heater switch state changes."""
_LOGGER.debug("Switch changed: %s", event.data)
new_state = event.data.get("new_state")
Expand Down
5 changes: 3 additions & 2 deletions custom_components/dual_smart_thermostat/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""const."""

from homeassistant.backports.enum import StrEnum
import enum

from homeassistant.components.climate.const import (
PRESET_ACTIVITY,
PRESET_AWAY,
Expand Down Expand Up @@ -82,7 +83,7 @@
)


class ToleranceDevice(StrEnum):
class ToleranceDevice(enum.StrEnum):
"""Tolerance device for climate devices."""

HEATER = "heater"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import StrEnum
import enum
from itertools import chain

from custom_components.dual_smart_thermostat.hvac_action_reason.hvac_action_reason_external import (
Expand All @@ -12,7 +12,7 @@
SERVICE_SET_HVAC_ACTION_REASON = "set_hvac_action_reason"


class HVACActionReason(StrEnum):
class HVACActionReason(enum.StrEnum):
"""HVAC Action Reason for climate devices."""

_ignore_ = "member cls"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import StrEnum
import enum


class HVACActionReasonExternal(StrEnum):
class HVACActionReasonExternal(enum.StrEnum):
"""External HVAC Action Reason for climate devices."""

PRESENCE = "presence"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import StrEnum
import enum


class HVACActionReasonInternal(StrEnum):
class HVACActionReasonInternal(enum.StrEnum):
"""Internal HVAC Action Reason for climate devices."""

TARGET_TEMP_NOT_REACHED = "target_temp_not_reached"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Opening Manager for Dual Smart Thermostat."""

from enum import StrEnum
import enum
from itertools import chain
import logging
from typing import List
Expand All @@ -27,7 +27,7 @@
_LOGGER = logging.getLogger(__name__)


class OpeningHvacModeScope(StrEnum):
class OpeningHvacModeScope(enum.StrEnum):
"""Opening Scope Options"""

_ignore_ = "member cls"
Expand Down

0 comments on commit 9c6cd5b

Please sign in to comment.