Skip to content

Commit a81952b

Browse files
committed
fix: replace deprecated constants and aliases
1 parent 37919b1 commit a81952b

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

custom_components/bemfa/const.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Final
44

5-
from homeassistant.backports.enum import StrEnum
5+
import enum
66

77
DOMAIN: Final = "bemfa"
88

@@ -33,7 +33,7 @@
3333
OPTIONS_SWING_BOTH_VALUE: Final = "swing_both_value"
3434

3535
# #### MQTT ####
36-
class TopicSuffix(StrEnum):
36+
class TopicSuffix(enum.StrEnum):
3737
"""Suffix for bemfa MQTT topic"""
3838

3939
LIGHT = "002"

custom_components/bemfa/sync_switch.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
from collections.abc import Mapping, Callable
55
from typing import Any
66
from homeassistant.components.automation import DOMAIN as AUTOMATION_DOMAIN
7-
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN, STATE_IDLE
7+
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN, CameraState
88
from homeassistant.components.group import DOMAIN as GROUP_DOMAIN
99
from homeassistant.components.humidifier import DOMAIN as HUMIDIFIER_DOMAIN
1010
from homeassistant.components.input_boolean import DOMAIN as INPUT_BOOLEAN_DOMAIN
11-
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN
11+
from homeassistant.components.lock import DOMAIN as LOCK_DOMAIN, LockState
1212
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
1313
from homeassistant.components.remote import DOMAIN as REMOTE_DOMAIN
1414
from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN
@@ -29,7 +29,6 @@
2929
SERVICE_TURN_ON,
3030
SERVICE_UNLOCK,
3131
SERVICE_LOCK,
32-
STATE_LOCKED,
3332
STATE_ON,
3433
STATE_PLAYING,
3534
)
@@ -120,7 +119,7 @@ def _supported_domain() -> str:
120119
def _msg_generator(
121120
self,
122121
) -> Callable[[str, ReadOnlyDict[Mapping[str, Any]]], str | int]:
123-
return lambda state, attributes: MSG_OFF if state == STATE_IDLE else MSG_ON
122+
return lambda state, attributes: MSG_OFF if state == CameraState.IDLE else MSG_ON
124123

125124

126125
@SYNC_TYPES.register("media_player")
@@ -148,7 +147,7 @@ def _supported_domain() -> str:
148147
def _msg_generator(
149148
self,
150149
) -> Callable[[str, ReadOnlyDict[Mapping[str, Any]]], str | int]:
151-
return lambda state, attributes: MSG_OFF if state == STATE_LOCKED else MSG_ON
150+
return lambda state, attributes: MSG_OFF if state == LockState.LOCKED else MSG_ON
152151

153152
def _service_names(self) -> tuple[str, str]:
154153
return (SERVICE_UNLOCK, SERVICE_LOCK)

0 commit comments

Comments
 (0)