2
2
3
3
from paradox .config import config as cfg
4
4
from paradox .event import Event , EventLevel , Notification
5
+ from paradox .exceptions import InvalidCommand
5
6
from paradox .interfaces import AsyncInterface
6
7
from paradox .lib import ps
7
8
from paradox .lib .event_filter import EventFilter , EventTagFilter , LiveEventRegexpFilter
@@ -61,7 +62,7 @@ async def handle_command(self, message_raw):
61
62
62
63
element_type = tokens [0 ].lower ()
63
64
element = tokens [1 ]
64
- command = self .normalize_payload (tokens [2 ].lower ())
65
+ command = self .normalize_command (tokens [2 ].lower ())
65
66
66
67
# Process a Zone Command
67
68
if element_type == "zone" :
@@ -91,16 +92,15 @@ async def handle_command(self, message_raw):
91
92
logger .info (f"OK: { message_raw } " )
92
93
return "OK"
93
94
94
- # TODO: Remove this (to panels?)
95
95
@staticmethod
96
- def normalize_payload ( message ):
97
- message = message .strip ().lower ()
96
+ def normalize_command ( command ):
97
+ command = command .strip ().lower ()
98
98
99
- if message in ["true" , "on" , "1" , "enable" ]:
99
+ if command in ["true" , "on" , "1" , "enable" ]:
100
100
return "on"
101
- elif message in ["false" , "off" , "0" , "disable" ]:
101
+ elif command in ["false" , "off" , "0" , "disable" ]:
102
102
return "off"
103
- elif message in [
103
+ elif command in [
104
104
"pulse" ,
105
105
"arm" ,
106
106
"disarm" ,
@@ -109,9 +109,9 @@ def normalize_payload(message):
109
109
"bypass" ,
110
110
"clear_bypass" ,
111
111
]:
112
- return message
112
+ return command
113
113
114
- return None
114
+ raise InvalidCommand ( f'Invalid command: " { command } "' )
115
115
116
116
117
117
class ConfiguredAbstractTextInterface (AbstractTextInterface ):
0 commit comments