diff --git a/meshai/connector.py b/meshai/connector.py index 2778b0a..c0d8d4e 100644 --- a/meshai/connector.py +++ b/meshai/connector.py @@ -229,10 +229,13 @@ class MeshConnector: try: if destination: - # DM to specific node - # Convert hex string to int if needed - if destination.startswith("!"): + # DM to specific node - handle int or string + if isinstance(destination, int): + dest_num = destination + elif destination.startswith("!"): dest_num = int(destination[1:], 16) + elif destination.isdigit(): + dest_num = int(destination) else: dest_num = int(destination, 16) diff --git a/meshai/notifications/channels.py b/meshai/notifications/channels.py index 4739a74..98b4b6d 100644 --- a/meshai/notifications/channels.py +++ b/meshai/notifications/channels.py @@ -168,8 +168,8 @@ class MeshDMChannel(NotificationChannel): for node_id in self._node_ids: try: - dest = int(node_id[1:], 16) if node_id.startswith("!") else (int(node_id) if node_id.isdigit() else int(node_id, 16)) - self._connector.send_message(text=message, destination=dest, channel=0) + node_id = str(node_id) + self._connector.send_message(text=message, destination=node_id, channel=0) except Exception as e: logger.error("Failed to DM %s: %s", node_id, e) success = False @@ -199,10 +199,10 @@ class MeshDMChannel(NotificationChannel): for node_id in self._node_ids: try: - dest = int(node_id[1:], 16) if node_id.startswith("!") else (int(node_id) if node_id.isdigit() else int(node_id, 16)) + node_id = str(node_id) self._connector.send_message( text="MeshAI DM test", - destination=dest, + destination=node_id, channel=0, ) results.append({"node": node_id, "success": True}) @@ -249,8 +249,8 @@ class MeshDMChannel(NotificationChannel): for node_id in self._node_ids: try: - dest = int(node_id[1:], 16) if node_id.startswith("!") else (int(node_id) if node_id.isdigit() else int(node_id, 16)) - self._connector.send_message(text=message, destination=dest, channel=0) + node_id = str(node_id) + self._connector.send_message(text=message, destination=node_id, channel=0) success_count += 1 except Exception as e: errors.append(f"{node_id}: {e}") diff --git a/meshai/notifications/router.py b/meshai/notifications/router.py index 9eee87d..689219e 100644 --- a/meshai/notifications/router.py +++ b/meshai/notifications/router.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) SEVERITY_ORDER = ["routine", "priority", "immediate"] # State file for rule statistics -RULE_STATS_FILE = "/opt/meshai/data/rule_stats.json" +RULE_STATS_FILE = "/data/rule_stats.json" class NotificationRouter: