Skip to content

Commit 49144cf

Browse files
authored
Fully removes scene support, fixing unknown device errors. (#136)
1 parent 58a4b0a commit 49144cf

File tree

7 files changed

+2
-115
lines changed

7 files changed

+2
-115
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ Pyalarmdotcomajax supports core features (monitoring and using actions) of the d
5252
| Light | `brightness` | turn_on (with brightness), turn_off | No support for RGB/W, effects, temperature, etc. |
5353
| Locks | | lock, unlock | |
5454
| Partition | `uncleared_issues` | arm away, arm stay, arm night, disarm | |
55-
| Scene | | execute | |
5655
| Sensor | `device_subtype` | (none) | |
5756
| System | `unit_id` | (none) | |
5857
| Thermostat | `temp_average`, `temp_at_tstat`, `step_value`, `supports_fan_mode`, `supports_fan_indefinite`, `supports_fan_circulate_when_off`, `supported_fan_durations`, `fan_mode`, `supports_heat`, `supports_heat_aux`, `supports_cool`, `supports_auto`, `min_heat_setpoint`, `min_cool_setpoint`, `max_heat_setpoint`, `max_cool_setpoint`, `heat_setpoint`, `cool_setpoint`, `supports_humidity`, `humidity`, `supports_schedules`, `supports_schedules_smart`, `schedule_mode` | set_attribute | |

pyalarmdotcomajax/__init__.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
)
4949
from pyalarmdotcomajax.websockets.client import WebSocketClient, WebSocketState
5050

51-
__version__ = "0.5.10"
51+
__version__ = "0.5.11"
5252

5353
log = logging.getLogger(__name__)
5454

@@ -98,8 +98,6 @@ class AlarmController:
9898
KEEP_ALIVE_SIGNAL_INTERVAL_S = 60
9999
SESSION_REFRESH_DEFAULT_INTERVAL_MS = 780000 # 13 minutes. Sessions expire at 15.
100100

101-
SCENE_REFRESH_INTERVAL_M = 60
102-
103101
# LOGIN & SESSION: END
104102

105103
def __init__(
@@ -163,13 +161,6 @@ def __init__(
163161
self._last_session_refresh: datetime = datetime.now()
164162
self._session_timer: SessionTimer | None = None
165163

166-
#
167-
# SCENE REFRESH ATTRIBUTES
168-
#
169-
170-
self._last_scene_update: datetime | None = None
171-
self._scene_object_cache: list[dict] = []
172-
173164
#
174165
# CLI ATTRIBUTES
175166
#
@@ -236,14 +227,12 @@ async def async_update(self) -> None:
236227
log.debug("Calling update on Alarm.com")
237228

238229
has_image_sensors: bool = False
239-
has_scenes: bool = False
240230

241231
if not self._active_system_id:
242232
self._active_system_id = await self._async_get_active_system()
243233
has_image_sensors = await self._async_device_type_present(
244234
self._active_system_id, DeviceType.IMAGE_SENSOR
245235
)
246-
has_scenes = await self._async_device_type_present(self._active_system_id, DeviceType.SCENE)
247236

248237
await self._async_get_trouble_conditions()
249238

@@ -261,21 +250,6 @@ async def async_update(self) -> None:
261250

262251
extension_results = await self._async_update__query_multi_device_extensions(raw_devices)
263252

264-
#
265-
# QUERY SCENES
266-
#
267-
# Scenes have no state, so we only need to update for new/deleted scenes. We refresh less frequently than we do for stateful devices to save time.
268-
269-
if has_scenes:
270-
# Refresh scene cache if stale.
271-
if not self._last_scene_update or (
272-
datetime.now() > self._last_scene_update + timedelta(minutes=self.SCENE_REFRESH_INTERVAL_M)
273-
):
274-
self._scene_object_cache = await self._async_get_devices_by_device_type(DeviceType.SCENE)
275-
self._last_scene_update = datetime.now()
276-
277-
raw_devices.extend(self._scene_object_cache)
278-
279253
#
280254
# QUERY IMAGE SENSORS
281255
#

pyalarmdotcomajax/devices/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class DeviceType(ExtendedEnumMixin):
3434
LIGHT = "lights"
3535
LOCK = "locks"
3636
PARTITION = "partitions"
37-
SCENE = "scenes"
3837
SENSOR = "sensors"
3938
SYSTEM = "systems"
4039
THERMOSTAT = "thermostats"
@@ -50,6 +49,7 @@ class DeviceType(ExtendedEnumMixin):
5049
GEO_DEVICE = "geoDevices"
5150
IQ_ROUTER = "iqRouters"
5251
REMOTE_TEMP = "remoteTemperatureSensors"
52+
SCENE = "scenes"
5353
SHADE = "shades"
5454
SMART_CHIME = "smartChimeDevices"
5555
SUMP_PUMP = "sumpPumps"

pyalarmdotcomajax/devices/registry.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from pyalarmdotcomajax.devices.light import Light
1515
from pyalarmdotcomajax.devices.lock import Lock
1616
from pyalarmdotcomajax.devices.partition import Partition
17-
from pyalarmdotcomajax.devices.scene import Scene
1817
from pyalarmdotcomajax.devices.sensor import Sensor
1918
from pyalarmdotcomajax.devices.system import System
2019
from pyalarmdotcomajax.devices.thermostat import Thermostat
@@ -32,7 +31,6 @@
3231
| Light
3332
| Lock
3433
| Partition
35-
| Scene
3634
| Sensor
3735
| System
3836
| Thermostat
@@ -47,7 +45,6 @@
4745
| type[Light]
4846
| type[Lock]
4947
| type[Partition]
50-
| type[Scene]
5148
| type[Sensor]
5249
| type[System]
5350
| type[Thermostat]
@@ -63,7 +60,6 @@
6360
| list[Light]
6461
| list[Lock]
6562
| list[Partition]
66-
| list[Scene]
6763
| list[Sensor]
6864
| list[System]
6965
| list[Thermostat]
@@ -78,7 +74,6 @@
7874
| dict[str, Light]
7975
| dict[str, Lock]
8076
| dict[str, Partition]
81-
| dict[str, Scene]
8277
| dict[str, Sensor]
8378
| dict[str, System]
8479
| dict[str, Thermostat]
@@ -140,10 +135,8 @@
140135
},
141136
DeviceType.SCENE: {
142137
"endpoints": {"primary": "{}web/api/automation/scenes/{}"},
143-
"class_": Scene,
144138
"rel_id": "automation/scene",
145139
"type_id": "scenes",
146-
"device_registry_property": "scenes",
147140
},
148141
DeviceType.SENSOR: {
149142
"endpoints": {"primary": "{}web/api/devices/sensors/{}"},
@@ -343,11 +336,6 @@ def partitions(self) -> dict[str, Partition]:
343336
"""Return partitions."""
344337
return {device_id: device for device_id, device in self._devices.items() if type(device) == Partition}
345338

346-
@property
347-
def scenes(self) -> dict[str, Scene]:
348-
"""Return sensors."""
349-
return {device_id: device for device_id, device in self._devices.items() if type(device) == Scene}
350-
351339
@property
352340
def sensors(self) -> dict[str, Sensor]:
353341
"""Return sensors."""

pyalarmdotcomajax/devices/scene.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

tests/conftest.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ def _load_mocks(repeat: bool = True) -> None:
9292
repeat=repeat,
9393
)
9494

95-
response_mocker.get(
96-
url=AttributeRegistry.get_endpoints(DeviceType.SCENE)["primary"].format(c.URL_BASE, ""),
97-
status=200,
98-
body=get_http_body_json("scenes_ok"),
99-
repeat=repeat,
100-
)
101-
10295
response_mocker.get(
10396
url=AlarmController.ALL_DEVICES_URL_TEMPLATE.format(c.URL_BASE, "id-system"),
10497
status=200,

tests/test_controller.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ async def test__device_storage(
4141
assert adc_client.devices.lights.values()
4242
assert adc_client.devices.thermostats.values()
4343
assert adc_client.devices.water_sensors.values()
44-
assert adc_client.devices.scenes.values()
4544

4645

4746
@pytest.mark.asyncio

0 commit comments

Comments
 (0)