Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def execute_service(self, service: UserService, data: dict):
self._check_authenticated()
req = pb.ExecuteServiceRequest()
req.key = service.key
args = []
for arg_desc in service.args:
arg = pb.ExecuteServiceArgument()
val = data[arg_desc.name]
int_type = 'int_' if self.api_version >= APIVersion(
1, 3) else 'legacy_int'
map_single = {
UserServiceArgType.BOOL: 'bool_',
UserServiceArgType.INT: int_type,
UserServiceArgType.FLOAT: 'float_',
UserServiceArgType.STRING: 'string_',
}
map_array = {
UserServiceArgType.BOOL_ARRAY: 'bool_array',
UserServiceArgType.INT_ARRAY: 'int_array',
27: pb.TextSensorStateResponse,
28: pb.SubscribeLogsRequest,
29: pb.SubscribeLogsResponse,
30: pb.CoverCommandRequest,
31: pb.FanCommandRequest,
32: pb.LightCommandRequest,
33: pb.SwitchCommandRequest,
34: pb.SubscribeHomeassistantServicesRequest,
35: pb.HomeassistantServiceResponse,
36: pb.GetTimeRequest,
37: pb.GetTimeResponse,
38: pb.SubscribeHomeAssistantStatesRequest,
39: pb.SubscribeHomeAssistantStateResponse,
40: pb.HomeAssistantStateResponse,
41: pb.ListEntitiesServicesResponse,
42: pb.ExecuteServiceRequest,
43: pb.ListEntitiesCameraResponse,
44: pb.CameraImageResponse,
45: pb.CameraImageRequest,
46: pb.ListEntitiesClimateResponse,
47: pb.ClimateStateResponse,
48: pb.ClimateCommandRequest,
}