@@ -36,24 +36,22 @@ async def execute_platform_entity_command(
3636 method_name : str ,
3737) -> None :
3838 """Get the platform entity and execute a method based on the command."""
39- try :
40- _LOGGER .debug ("command: %s" , command )
41- if command .group_id :
42- group = gateway .get_group (command .group_id )
43- platform_entity = group .group_entities [command .unique_id ]
44- else :
45- device = gateway .get_device (command .ieee )
46- platform_entity = device .get_platform_entity (
47- command .platform , command .unique_id
48- )
49- except ValueError as err :
50- _LOGGER .exception (
51- "Error executing command: %s method_name: %s" ,
52- command ,
53- method_name ,
54- exc_info = err ,
39+
40+ _LOGGER .debug ("attempting to execute platform entity command: %s" , command )
41+
42+ if command .group_id :
43+ group = gateway .get_group (command .group_id )
44+ platform_entity = group .group_entities [command .unique_id ]
45+ else :
46+ device = gateway .get_device (command .ieee )
47+ platform_entity = device .get_platform_entity (
48+ command .platform , command .unique_id
49+ )
50+
51+ if not platform_entity :
52+ client .send_result_error (
53+ command , "PLATFORM_ENTITY_COMMAND_ERROR" , "platform entity not found"
5554 )
56- client .send_result_error (command , "PLATFORM_ENTITY_COMMAND_ERROR" , str (err ))
5755 return None
5856
5957 try :
@@ -69,7 +67,7 @@ async def execute_platform_entity_command(
6967 else :
7068 action () # the only argument is self
7169
72- except Exception as err :
70+ except Exception as err : # pylint: disable=broad-except
7371 _LOGGER .exception ("Error executing command: %s" , method_name , exc_info = err )
7472 client .send_result_error (command , "PLATFORM_ENTITY_ACTION_ERROR" , str (err ))
7573 return
0 commit comments