async def preheat_stop(self, vin: str): LOGGER.info("Start preheat_stop for vin %s", vin) message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.zev_preconditioning_stop.type = pb2_commands.ZEVPreconditioningType.now await self.websocket.call(message.SerializeToString()) LOGGER.info("End preheat_stop for vin %s", vin)
async def doors_lock(self, vin: str): LOGGER.info("Start Doors_lock for vin %s", vin) message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.doors_lock.doors.extend([]) await self.websocket.call(message.SerializeToString()) LOGGER.info("End Doors_lock for vin %s", vin)
async def engine_stop(self, vin: str): LOGGER.info("Start engine_stop for vin %s", vin) message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) engine_stop = pb2_commands.EngineStop() message.commandRequest.engine_stop.CopyFrom(engine_stop) await self.websocket.call(message.SerializeToString()) LOGGER.info("End engine_stop for vin %s", vin)
async def windows_close(self, vin: str): LOGGER.info("Start windows_close for vin %s", vin) message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) windows_close = pb2_commands.WindowsClose() message.commandRequest.windows_close.CopyFrom(windows_close) await self.websocket.call(message.SerializeToString()) LOGGER.info("End windows_close for vin %s", vin)
async def preheat_start_departure_time(self, vin: str, departure_time: int): LOGGER.info("Start preheat_start_departure_time for vin %s", vin) message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.zev_preconditioning_start.departure_time = departure_time message.commandRequest.zev_preconditioning_start.type = pb2_commands.ZEVPreconditioningType.departure await self.websocket.call(message.SerializeToString()) LOGGER.info("End preheat_start_departure_time for vin %s", vin)
async def windows_open(self, vin: str): LOGGER.info("Start windows_open for vin %s", vin) message = client_pb2.ClientMessage() if self.pin is None: LOGGER.warn( f"Can't open the windows - car {vin}. PIN not set. Please set the PIN -> Integration, Options " ) return message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.windows_open.pin = self.pin await self.websocket.call(message.SerializeToString()) LOGGER.info("End windows_open for vin %s", vin)
async def preheat_stop(self, vin: str): LOGGER.info("Start preheat_stop for vin %s", vin) if not self.is_car_feature_available(vin, "ZEV_PRECONDITIONING_STOP"): LOGGER.warning( f"Can't stop PreCond for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.zev_preconditioning_stop.type = pb2_commands.ZEVPreconditioningType.now await self.websocket.call(message.SerializeToString()) LOGGER.info("End preheat_stop for vin %s", vin)
async def doors_unlock(self, vin: str): if not self.is_car_feature_available(vin, "DOORS_UNLOCK"): LOGGER.warning( f"Can't unlock car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() if self.pin is None: LOGGER.warning( f"Can't unlock car {vin}. PIN not set. Please set the PIN -> Integration, Options " ) return await self.doors_unlock_with_pin(vin, self.pin)
async def doors_lock(self, vin: str): LOGGER.info("Start Doors_lock for vin %s", vin) if not self.is_car_feature_available(vin, "DOORS_LOCK"): LOGGER.warning( f"Can't lock car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.doors_lock.doors.extend([]) await self.websocket.call(message.SerializeToString()) LOGGER.info("End Doors_lock for vin %s", vin)
async def auxheat_start(self, vin: str): LOGGER.info("Start auxheat start for vin %s", vin) if not self.is_car_feature_available(vin, "AUXHEAT_START"): LOGGER.warning( f"Can't start auxheat for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) auxheat_start = pb2_commands.AuxheatStart() message.commandRequest.auxheat_start.CopyFrom(auxheat_start) await self.websocket.call(message.SerializeToString()) LOGGER.info("End auxheat start for vin %s", vin)
async def engine_stop(self, vin: str): LOGGER.info("Start engine_stop for vin %s", vin) if not self.is_car_feature_available(vin, "ENGINE_STOP"): LOGGER.warning( f"Can't stop engine for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) engine_stop = pb2_commands.EngineStop() message.commandRequest.engine_stop.CopyFrom(engine_stop) await self.websocket.call(message.SerializeToString()) LOGGER.info("End engine_stop for vin %s", vin)
async def windows_close(self, vin: str): LOGGER.info("Start windows_close for vin %s", vin) if not self.is_car_feature_available(vin, "WINDOWS_CLOSE"): LOGGER.warning( f"Can't close the windows for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) windows_close = pb2_commands.WindowsClose() message.commandRequest.windows_close.CopyFrom(windows_close) await self.websocket.call(message.SerializeToString()) LOGGER.info("End windows_close for vin %s", vin)
async def sigpos_start(self, vin: str): LOGGER.info("Start sigpos_start for vin %s", vin) if not self.is_car_feature_available(vin, "SIGPOS_START"): LOGGER.warning( f"Can't start signaling for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.sigpos_start.light_type = 1 message.commandRequest.sigpos_start.sigpos_type = 0 await self.websocket.call(message.SerializeToString()) LOGGER.info("End sigpos_start for vin %s", vin)
async def battery_max_soc_configure(self, vin: str, max_soc: int): LOGGER.info("Start battery_max_soc_configure to %s for vin %s", max_soc, vin) if not self.is_car_feature_available(vin, "BATTERY_MAX_SOC_CONFIGURE"): LOGGER.warning( f"Can't configure battery_max_soc for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) charge_program_config = pb2_commands.ChargeProgramConfigure() charge_program_config.max_soc.value = max_soc message.commandRequest.charge_program_configure.CopyFrom( charge_program_config) await self.websocket.call(message.SerializeToString()) LOGGER.info("End battery_max_soc_configure for vin %s", vin)
async def windows_open(self, vin: str): LOGGER.info("Start windows_open for vin %s", vin) if not self.is_car_feature_available(vin, "WINDOWS_OPEN"): LOGGER.warning( f"Can't open the windows for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() if self.pin is None: LOGGER.warning( f"Can't open the windows - car {vin}. PIN not set. Please set the PIN -> Integration, Options " ) return message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.windows_open.pin = self.pin await self.websocket.call(message.SerializeToString()) LOGGER.info("End windows_open for vin %s", vin)
async def auxheat_configure(self, vin: str, time_selection: int, time_1: int, time_2: int, time_3: int): LOGGER.info("Start auxheat_configure for vin %s", vin) if not self.is_car_feature_available(vin, "AUXHEAT_START"): LOGGER.warning( f"Can't start auxheat for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) auxheat_configure = pb2_commands.AuxheatConfigure() auxheat_configure.time_selection = time_selection auxheat_configure.time_1 = time_1 auxheat_configure.time_2 = time_2 auxheat_configure.time_3 = time_3 message.commandRequest.auxheat_configure.CopyFrom(auxheat_configure) await self.websocket.call(message.SerializeToString()) LOGGER.info("End auxheat_configure for vin %s", vin)
async def engine_start(self, vin: str): LOGGER.info("Start engine start for vin %s", vin) if not self.is_car_feature_available(vin, "ENGINE_START"): LOGGER.warning( f"Can't start engine for car {vin}. VIN unknown or feature not availabe for this car." ) return message = client_pb2.ClientMessage() if self.pin is None: LOGGER.warning( f"Can't start the car {vin}. PIN not set. Please set the PIN -> Integration, Options " ) return message.commandRequest.vin = vin message.commandRequest.request_id = str(uuid.uuid4()) message.commandRequest.engine_start.pin = self.pin await self.websocket.call(message.SerializeToString()) LOGGER.info("End engine start for vin %s", vin)
def on_data(data): """Define a handler to fire when the data is received.""" msg_type = data.WhichOneof('msg') if (msg_type == "vepUpdate"): #VEPUpdate LOGGER.debug("vepUpdate") return if (msg_type == "vepUpdates"): #VEPUpdatesByVIN self._process_vep_updates(data) sequence_number = data.vepUpdates.sequence_number LOGGER.debug(f"vepUpdates Sequence: {sequence_number}") ack_command = client_pb2.ClientMessage() ack_command.acknowledge_vep_updates_by_vin.sequence_number = sequence_number return ack_command if (msg_type == "debugMessage"): #DebugMessage if data.debugMessage: LOGGER.debug( f"debugMessage - Data: {data.debugMessage.message}") return if (msg_type == "service_status_update"): LOGGER.debug( f"service_status_update - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) return if (msg_type == "user_data_update"): LOGGER.debug( f"user_data_update - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) return if (msg_type == "user_vehicle_auth_changed_update"): LOGGER.debug( f"user_vehicle_auth_changed_update - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) return if (msg_type == "user_picture_update"): LOGGER.debug( f"user_picture_update - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) return if (msg_type == "user_pin_update"): LOGGER.debug( f"user_pin_update - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) return if (msg_type == "vehicle_updated"): LOGGER.debug( f"vehicle_updated - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) return if (msg_type == "preferred_dealer_change"): LOGGER.debug( f"preferred_dealer_change - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) return if (msg_type == "apptwin_command_status_updates_by_vin"): LOGGER.debug( f"apptwin_command_status_updates_by_vin - Data: {MessageToJson(data, preserving_proto_field_name=True)}" ) sequence_number = data.apptwin_command_status_updates_by_vin.sequence_number LOGGER.debug("apptwin_command_status_updates_by_vin: %s", sequence_number) ack_command = client_pb2.ClientMessage() ack_command.acknowledge_apptwin_command_status_update_by_vin.sequence_number = sequence_number return ack_command if (msg_type == "apptwin_pending_command_request"): #LOGGER.debug(f"apptwin_pending_command_request - Data: {MessageToJson(data, preserving_proto_field_name=True)}") return if (msg_type == "assigned_vehicles"): LOGGER.debug("assigned_vehicles") self._process_assigned_vehicles(data) return LOGGER.debug(f"Message Type not implemented - {msg_type}")