Skip to content

Commit

Permalink
Merge pull request #162 from tahvane1/Compatibility-with-HA-Core-2025.1
Browse files Browse the repository at this point in the history
HA Core 2025.1
  • Loading branch information
tahvane1 authored Jan 27, 2024
2 parents c918682 + d7fc2c4 commit 5b1c0fb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 38 deletions.
17 changes: 7 additions & 10 deletions custom_components/jablotron80/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
from homeassistant.helpers.typing import StateType
from homeassistant.components.alarm_control_panel import (
AlarmControlPanelEntity,
FORMAT_NUMBER,
SUPPORT_ALARM_ARM_HOME,
SUPPORT_ALARM_ARM_AWAY,
SUPPORT_ALARM_ARM_NIGHT,
SUPPORT_ALARM_TRIGGER,
AlarmControlPanelEntityFeature,
CodeFormat,
ATTR_CHANGED_BY,
ATTR_CODE_ARM_REQUIRED
)
Expand Down Expand Up @@ -72,7 +69,7 @@ def code_format(self) -> Optional[str]:
code_required = self.code_arm_required
else:
code_required = self.code_disarm_required
return FORMAT_NUMBER if code_required is True else None
return CodeFormat.NUMBER if code_required is True else None

@staticmethod
def _check_code(code: Optional[str]) -> Optional[str]:
Expand All @@ -82,12 +79,12 @@ def _check_code(code: Optional[str]) -> Optional[str]:
@property
def supported_features(self) -> int:
if self._cu.mode == JA80CentralUnit.SYSTEM_MODE_UNSPLIT:
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_TRIGGER
return AlarmControlPanelEntityFeature.ARM_AWAY | AlarmControlPanelEntityFeature.TRIGGER
elif self._cu.mode == JA80CentralUnit.SYSTEM_MODE_PARTIAL:
return SUPPORT_ALARM_ARM_AWAY|SUPPORT_ALARM_ARM_HOME|SUPPORT_ALARM_ARM_NIGHT | SUPPORT_ALARM_TRIGGER
return AlarmControlPanelEntityFeature.ARM_AWAY| AlarmControlPanelEntityFeature.ARM_HOME | AlarmControlPanelEntityFeature.ARM_NIGHT | AlarmControlPanelEntityFeature.TRIGGER
elif self._cu.mode == JA80CentralUnit.SYSTEM_MODE_SPLIT:
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_TRIGGER
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_TRIGGER
return AlarmControlPanelEntityFeature.ARM_AWAY | AlarmControlPanelEntityFeature.ARM_HOME | AlarmControlPanelEntityFeature.TRIGGER
return AlarmControlPanelEntityFeature.ARM_AWAY | AlarmControlPanelEntityFeature.TRIGGER

@property
def code_arm_required(self) -> bool:
Expand Down
38 changes: 14 additions & 24 deletions custom_components/jablotron80/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.components.binary_sensor import (
BinarySensorEntity,
DEVICE_CLASS_CONNECTIVITY,
DEVICE_CLASS_DOOR,
DEVICE_CLASS_GAS,
DEVICE_CLASS_MOISTURE,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_PROBLEM,
DEVICE_CLASS_SAFETY,
DEVICE_CLASS_SMOKE,
DEVICE_CLASS_WINDOW,
DEVICE_CLASS_LIGHT,
DEVICE_CLASS_POWER,
BinarySensorDeviceClass,
)
from .const import (
DATA_JABLOTRON,
Expand Down Expand Up @@ -62,35 +52,35 @@ def icon(self) -> Optional[str]:
def device_class(self) -> Optional[str]:
if self._object._id <= 0:
if "code" == self._object.type and self._object.reaction == JablotronConstants.REACTION_PANIC:
return DEVICE_CLASS_SAFETY
return BinarySensorDeviceClass.SAFETY
elif "code" == self._object.type and self._object.reaction == JablotronConstants.REACTION_FIRE_ALARM:
return DEVICE_CLASS_SMOKE
return BinarySensorDeviceClass.SMOKE
elif "code" == self._object.type:
return DEVICE_CLASS_MOTION
return BinarySensorDeviceClass.MOTION
elif DEVICE_CONTROL_PANEL == self._object.type:
return DEVICE_CLASS_PROBLEM
return BinarySensorDeviceClass.PROBLEM
elif "power led" == self._object.type:
return DEVICE_CLASS_POWER
return BinarySensorDeviceClass.POWER
elif "armed led" == self._object.type:
return DEVICE_CLASS_LIGHT
return BinarySensorDeviceClass.LIGHT
if self._object.type == DEVICE_MOTION_DETECTOR:
return DEVICE_CLASS_MOTION
return BinarySensorDeviceClass.MOTION
if self._object.type == DEVICE_KEYPAD:
return DEVICE_CLASS_PROBLEM
return BinarySensorDeviceClass.PROBLEM
if self._object.type == DEVICE_WINDOW_OPENING_DETECTOR:
return DEVICE_CLASS_WINDOW
return BinarySensorDeviceClass.WINDOW

if self._object.type == DEVICE_DOOR_OPENING_DETECTOR:
return DEVICE_CLASS_DOOR
return BinarySensorDeviceClass.DOOR

if self._object.type == DEVICE_FLOOD_DETECTOR:
return DEVICE_CLASS_MOISTURE
return BinarySensorDeviceClass.MOISTURE

if self._object.type == DEVICE_GAS_DETECTOR:
return DEVICE_CLASS_GAS
return BinarySensorDeviceClass.GAS

if self._object.type == DEVICE_SMOKE_DETECTOR:
return DEVICE_CLASS_SMOKE
return BinarySensorDeviceClass.SMOKE

return None

Expand Down
8 changes: 4 additions & 4 deletions custom_components/jablotron80/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
DATA_JABLOTRON,
DOMAIN)


from homeassistant.const import (
DEVICE_CLASS_SIGNAL_STRENGTH
from homeassistant.components.sensor import (
SensorDeviceClass
)

import logging
LOGGER = logging.getLogger(__package__)
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities) -> None:
Expand Down Expand Up @@ -64,4 +64,4 @@ def unit_of_measurement(self) -> str:

@property
def device_class(self) -> str:
return DEVICE_CLASS_SIGNAL_STRENGTH
return SensorDeviceClass.SIGNAL_STRENGTH

0 comments on commit 5b1c0fb

Please sign in to comment.