@@ -74,28 +74,36 @@ def check_encoding(self, encoding):
74
74
75
75
async def send (self , command ):
76
76
"""Send a command."""
77
- if self ._encoding == ENC_HEX :
78
- try :
79
- command = binascii .unhexlify (command )
80
- command = b64encode (command ).decode ('utf-8' )
81
- except :
82
- raise Exception ("Error while converting "
83
- "Hex to Base64 encoding" )
84
-
85
- if self ._encoding == ENC_PRONTO :
86
- try :
87
- command = command .replace (' ' , '' )
88
- command = bytearray .fromhex (command )
89
- command = Helper .pronto2lirc (command )
90
- command = Helper .lirc2broadlink (command )
91
- command = b64encode (command ).decode ('utf-8' )
92
- except :
93
- raise Exception ("Error while converting "
94
- "Pronto to Base64 encoding" )
77
+ commands = []
78
+
79
+ if not isinstance (command , list ):
80
+ command = [command ]
81
+
82
+ for _command in command :
83
+ if self ._encoding == ENC_HEX :
84
+ try :
85
+ _command = binascii .unhexlify (_command )
86
+ _command = b64encode (_command ).decode ('utf-8' )
87
+ except :
88
+ raise Exception ("Error while converting "
89
+ "Hex to Base64 encoding" )
90
+
91
+ if self ._encoding == ENC_PRONTO :
92
+ try :
93
+ _command = _command .replace (' ' , '' )
94
+ _command = bytearray .fromhex (_command )
95
+ _command = Helper .pronto2lirc (_command )
96
+ _command = Helper .lirc2broadlink (_command )
97
+ _command = b64encode (_command ).decode ('utf-8' )
98
+ except :
99
+ raise Exception ("Error while converting "
100
+ "Pronto to Base64 encoding" )
101
+
102
+ commands .append ('b64:' + _command )
95
103
96
104
service_data = {
97
105
ATTR_ENTITY_ID : self ._controller_data ,
98
- 'command' : 'b64:' + command
106
+ 'command' : commands
99
107
}
100
108
101
109
await self .hass .services .async_call (
@@ -173,4 +181,4 @@ async def send(self, command):
173
181
service_data = {'command' : json .loads (command )}
174
182
175
183
await self .hass .services .async_call (
176
- 'esphome' , self ._controller_data , service_data )
184
+ 'esphome' , self ._controller_data , service_data )
0 commit comments