Skip to content

Commit

Permalink
Fix 255 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 committed Oct 4, 2024
1 parent 3741378 commit 9875799
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions scripts/generate_multilevel_sensor_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from collections import defaultdict
from collections.abc import Callable, Mapping
import json
import pathlib

from const import AUTO_GEN_POST, AUTO_GEN_PRE
Expand All @@ -28,15 +29,15 @@ def normalize_scale_definition(scale_definitions: dict[str, dict]) -> dict[str,
scale_def_ = {}
for scale_id, scale_props in scale_definitions.items():
scale_name_ = enum_name_format(scale_props["label"], True)
scale_def_[scale_name_] = int(scale_id)
scale_def_[scale_name_] = scale_id

return dict(sorted(scale_def_.items(), key=lambda kv: kv[0]))


scales = {}
sensors = {}

for sensor_props in pathlib.Path("sensors.json").read_text():
for sensor_props in json.loads(pathlib.Path("sensors.json").read_text()):
sensor_id = sensor_props["key"]
scale_def = sensor_props["scales"]
remove_parenthesis_ = True
Expand Down
5 changes: 3 additions & 2 deletions scripts/generate_notification_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from __future__ import annotations

from collections.abc import Callable, Mapping
import json
import pathlib

from const import AUTO_GEN_POST, AUTO_GEN_PRE
Expand All @@ -22,7 +23,7 @@

notifications = {}
params = {}
for notification_payload in pathlib.Path("notifications.json").read_text():
for notification_payload in json.loads(pathlib.Path("notifications.json").read_text()):
notification_type = notification_payload["type"]
notification_name = notification_payload["name"].title()
notifications[notification_name] = {
Expand All @@ -46,7 +47,7 @@
and state_props["parameter"]["type"] == "enum"
):
for enum_id, enum_name in state_props["parameter"]["values"].items():
enum_id = int(enum_id, 16)
enum_id = int(enum_id)
params.setdefault(notification_name, {}).setdefault(state_name, {})[
enum_name.title()
] = enum_id
Expand Down
6 changes: 3 additions & 3 deletions zwave_js_server/const/command_class/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class BarrierPerformingInitializationProcessNotificationEventValue(

# https://github.com/zwave-js/node-zwave-js/blob/master/packages/core/src/registries/Notifications.ts
UNKNOWN = -1
PERFORMING_PROCESS = 597
PERFORMING_PROCESS = 255
PROCESS_COMPLETED = 0

@classmethod
Expand All @@ -153,7 +153,7 @@ class BarrierSafetyBeamObstacleNotificationEventValue(NotificationEventValue):
# https://github.com/zwave-js/node-zwave-js/blob/master/packages/core/src/registries/Notifications.ts
UNKNOWN = -1
NO_OBSTRUCTION = 0
OBSTRUCTION = 597
OBSTRUCTION = 255

@classmethod
def _missing_(
Expand All @@ -169,7 +169,7 @@ class BarrierVacationModeNotificationEventValue(NotificationEventValue):
# https://github.com/zwave-js/node-zwave-js/blob/master/packages/core/src/registries/Notifications.ts
UNKNOWN = -1
MODE_DISABLED = 0
MODE_ENABLED = 597
MODE_ENABLED = 255

@classmethod
def _missing_(
Expand Down

0 comments on commit 9875799

Please sign in to comment.