22
33from paradox .config import config as cfg
44from paradox .event import Event , EventLevel , Notification
5+ from paradox .exceptions import InvalidCommand
56from paradox .interfaces import AsyncInterface
67from paradox .lib import ps
78from paradox .lib .event_filter import EventFilter , EventTagFilter , LiveEventRegexpFilter
@@ -61,7 +62,7 @@ async def handle_command(self, message_raw):
6162
6263 element_type = tokens [0 ].lower ()
6364 element = tokens [1 ]
64- command = self .normalize_payload (tokens [2 ].lower ())
65+ command = self .normalize_command (tokens [2 ].lower ())
6566
6667 # Process a Zone Command
6768 if element_type == "zone" :
@@ -91,16 +92,15 @@ async def handle_command(self, message_raw):
9192 logger .info (f"OK: { message_raw } " )
9293 return "OK"
9394
94- # TODO: Remove this (to panels?)
9595 @staticmethod
96- def normalize_payload ( message ):
97- message = message .strip ().lower ()
96+ def normalize_command ( command ):
97+ command = command .strip ().lower ()
9898
99- if message in ["true" , "on" , "1" , "enable" ]:
99+ if command in ["true" , "on" , "1" , "enable" ]:
100100 return "on"
101- elif message in ["false" , "off" , "0" , "disable" ]:
101+ elif command in ["false" , "off" , "0" , "disable" ]:
102102 return "off"
103- elif message in [
103+ elif command in [
104104 "pulse" ,
105105 "arm" ,
106106 "disarm" ,
@@ -109,9 +109,9 @@ def normalize_payload(message):
109109 "bypass" ,
110110 "clear_bypass" ,
111111 ]:
112- return message
112+ return command
113113
114- return None
114+ raise InvalidCommand ( f'Invalid command: " { command } "' )
115115
116116
117117class ConfiguredAbstractTextInterface (AbstractTextInterface ):
0 commit comments