|  | @ -208,14 +208,10 @@ try: | 
			
		
	
		
		
			
				
					|  |  | except ModuleNotFoundError: |  |  | except ModuleNotFoundError: | 
			
		
	
		
		
			
				
					|  |  |     pass |  |  |     pass | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  | class VolkszaehlerOutputPlugin(OutputPluginFactory): |  |  | class VzInverterOutput: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |     def __init__(self, config, **params): |  |  |     def __init__(self, config, session): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         """ |  |  |         self.session = session | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |         Initialize VolkszaehlerOutputPlugin |  |  |         self.serial = config.get('serial') | 
			
				
				
			
		
	
		
		
			
				
					|  |  |         """ |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         super().__init__(**params) |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         self.session = requests.Session() |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |         self.baseurl = config.get('url', 'http://localhost/middleware/') |  |  |         self.baseurl = config.get('url', 'http://localhost/middleware/') | 
			
		
	
		
		
			
				
					|  |  |         self.channels = dict() |  |  |         self.channels = dict() | 
			
		
	
		
		
			
				
					|  |  |         for channel in config.get('channels', []): |  |  |         for channel in config.get('channels', []): | 
			
		
	
	
		
		
			
				
					|  | @ -224,7 +220,7 @@ class VolkszaehlerOutputPlugin(OutputPluginFactory): | 
			
		
	
		
		
			
				
					|  |  |             if uid and ctype: |  |  |             if uid and ctype: | 
			
		
	
		
		
			
				
					|  |  |                 self.channels[ctype] = uid |  |  |                 self.channels[ctype] = uid | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |     def store_status(self, response, **params): |  |  |     def store_status(self, data, session): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         """ |  |  |         """ | 
			
		
	
		
		
			
				
					|  |  |         Publish StatusResponse object |  |  |         Publish StatusResponse object | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -232,15 +228,9 @@ class VolkszaehlerOutputPlugin(OutputPluginFactory): | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         :raises ValueError: when response is not instance of StatusResponse |  |  |         :raises ValueError: when response is not instance of StatusResponse | 
			
		
	
		
		
			
				
					|  |  |         """ |  |  |         """ | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         if not isinstance(response, StatusResponse): |  |  |  | 
			
		
	
		
		
			
				
					|  |  |             raise ValueError('Data needs to be instance of StatusResponse') |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         if len(self.channels) == 0: |  |  |         if len(self.channels) == 0: | 
			
		
	
		
		
			
				
					|  |  |             return |  |  |             return | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         data = response.__dict__() |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  |  | 
			
		
	
		
		
			
				
					|  |  |         ts = int(round(data['time'].timestamp() * 1000)) |  |  |         ts = int(round(data['time'].timestamp() * 1000)) | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         # AC Data |  |  |         # AC Data | 
			
		
	
	
		
		
			
				
					|  | @ -277,3 +267,37 @@ class VolkszaehlerOutputPlugin(OutputPluginFactory): | 
			
		
	
		
		
			
				
					|  |  |                 raise ValueError('Could not send request (%s)' % url) |  |  |                 raise ValueError('Could not send request (%s)' % url) | 
			
		
	
		
		
			
				
					|  |  |         except ConnectionError as e: |  |  |         except ConnectionError as e: | 
			
		
	
		
		
			
				
					|  |  |             raise ValueError('Could not send request (%s)' % e) |  |  |             raise ValueError('Could not send request (%s)' % e) | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | class VolkszaehlerOutputPlugin(OutputPluginFactory): | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     def __init__(self, config, **params): | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         """ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Initialize VolkszaehlerOutputPlugin | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         """ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         super().__init__(**params) | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         self.session = requests.Session() | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         self.inverters = dict() | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         for inverterconfig in config.get('inverters', []): | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             serial = inverterconfig.get('serial') | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             output = VzInverterOutput(inverterconfig, self.session) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             self.inverters[serial] = output | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     def store_status(self, response, **params): | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         """ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Publish StatusResponse object | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         :param hoymiles.decoders.StatusResponse response: StatusResponse object | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         :raises ValueError: when response is not instance of StatusResponse | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         """ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if not isinstance(response, StatusResponse): | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             raise ValueError('Data needs to be instance of StatusResponse') | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if len(self.inverters) == 0: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         data = response.__dict__() | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         serial = data["inverter_ser"] | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if serial in self.inverters: | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             output = self.inverters[serial] | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             output.store_status(data, self.session) | 
			
		
	
	
		
		
			
				
					|  | 
 |