| 
						
						
						
					 | 
					 | 
					@ -1,7 +1,6 @@ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					#!/usr/bin/env python3 | 
					 | 
					 | 
					 | 
					#!/usr/bin/env python3 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import datetime | 
					 | 
					 | 
					 | 
					import datetime | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import os | 
					 | 
					 | 
					 | 
					import os | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import time | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from pathlib import Path | 
					 | 
					 | 
					 | 
					from pathlib import Path | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from typing import Dict, NoReturn, Optional, Tuple | 
					 | 
					 | 
					 | 
					from typing import Dict, NoReturn, Optional, Tuple | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					from collections import namedtuple, OrderedDict | 
					 | 
					 | 
					 | 
					from collections import namedtuple, OrderedDict | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -373,10 +372,8 @@ def thermald_thread() -> NoReturn: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Check if we need to shut down | 
					 | 
					 | 
					 | 
					    # Check if we need to shut down | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if power_monitor.should_shutdown(peripheralState, onroad_conditions["ignition"], in_car, off_ts, started_seen): | 
					 | 
					 | 
					 | 
					    if power_monitor.should_shutdown(peripheralState, onroad_conditions["ignition"], in_car, off_ts, started_seen): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      cloudlog.info(f"shutting device down, offroad since {off_ts}") | 
					 | 
					 | 
					 | 
					      cloudlog.warning(f"shutting device down, offroad since {off_ts}") | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      # TODO: add function for blocking cloudlog instead of sleep | 
					 | 
					 | 
					 | 
					      params.put_bool("DoShutdown", True) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      time.sleep(10) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      HARDWARE.shutdown() | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    msg.deviceState.chargingError = current_filter.x > 0. and msg.deviceState.batteryPercent < 90  # if current is positive, then battery is being discharged | 
					 | 
					 | 
					 | 
					    msg.deviceState.chargingError = current_filter.x > 0. and msg.deviceState.batteryPercent < 90  # if current is positive, then battery is being discharged | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    msg.deviceState.started = started_ts is not None | 
					 | 
					 | 
					 | 
					    msg.deviceState.started = started_ts is not None | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |