mirror of
				https://github.com/python-kasa/python-kasa.git
				synced 2025-11-04 06:32:07 +00:00 
			
		
		
		
	Guard emeter accesses to avoid keyerrors (#304)
Raise an exception to inform the caller that update() is needed
This commit is contained in:
		@@ -219,6 +219,8 @@ class SmartDevice:
 | 
			
		||||
        """Raise an exception if there is no emeter."""
 | 
			
		||||
        if not self.has_emeter:
 | 
			
		||||
            raise SmartDeviceException("Device has no emeter")
 | 
			
		||||
        if self.emeter_type not in self._last_update:
 | 
			
		||||
            raise SmartDeviceException("update() required prior accessing emeter")
 | 
			
		||||
 | 
			
		||||
    async def _query_helper(
 | 
			
		||||
        self, target: str, cmd: str, arg: Optional[Dict] = None, child_ids=None
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user