Skip to content

Commit

Permalink
Fix alarm_state deprecation for HA Core 2025.11
Browse files Browse the repository at this point in the history
  • Loading branch information
andreapier committed Nov 11, 2024
1 parent 5b07471 commit 65118ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/econnect_metronet/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def icon(self):
return "hass:shield-home"

@property
def state(self):
def alarm_state(self):
"""Return the state of the device."""
return self._device.state

Expand Down
3 changes: 1 addition & 2 deletions custom_components/econnect_metronet/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
ParseError,
)
from homeassistant.components.alarm_control_panel import AlarmControlPanelState
from homeassistant.const import STATE_UNAVAILABLE
from requests.exceptions import HTTPError

from .const import (
Expand Down Expand Up @@ -64,7 +63,7 @@ def __init__(self, connection, config=None):
self._sectors_vacation = config.get(CONF_AREAS_ARM_VACATION) or []

# Alarm state
self.state = STATE_UNAVAILABLE
self.state = None

def _register_sector(self, entity):
"""Register a sector entity in the device's internal inventory."""
Expand Down
7 changes: 3 additions & 4 deletions tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from elmo import query as q
from elmo.api.exceptions import CodeError, CredentialError, LockError, ParseError
from homeassistant.components.alarm_control_panel import AlarmControlPanelState
from homeassistant.const import STATE_UNAVAILABLE
from requests.exceptions import HTTPError
from requests.models import Response

Expand Down Expand Up @@ -34,7 +33,7 @@ def test_device_constructor(client):
assert device._sectors_home == []
assert device._sectors_night == []
assert device._sectors_vacation == []
assert device.state == STATE_UNAVAILABLE
assert device.state is None


def test_device_constructor_with_config(client):
Expand All @@ -58,7 +57,7 @@ def test_device_constructor_with_config(client):
assert device._sectors_home == [3, 4]
assert device._sectors_night == [1, 2, 3]
assert device._sectors_vacation == [5, 3]
assert device.state == STATE_UNAVAILABLE
assert device.state is None


def test_device_constructor_with_config_empty(client):
Expand All @@ -82,7 +81,7 @@ def test_device_constructor_with_config_empty(client):
assert device._sectors_home == []
assert device._sectors_night == []
assert device._sectors_vacation == []
assert device.state == STATE_UNAVAILABLE
assert device.state is None


class TestItemInputs:
Expand Down

0 comments on commit 65118ca

Please sign in to comment.