@@ -201,17 +201,18 @@ def power_data_local_format(attrs, key_string, val):
201201
202202def power_data_energy_diff (measurement , net_string , f_val , direct_data ):
203203 """Calculate differential energy."""
204- diff = 1
205- if "produced" in measurement :
206- diff = - 1
207- if net_string not in direct_data :
208- direct_data [net_string ] = 0
209-
210- if isinstance (f_val , int ):
211- direct_data [net_string ] += f_val * diff
212- else :
213- direct_data [net_string ] += float (f_val * diff )
214- direct_data [net_string ] = float (f"{ round (direct_data [net_string ], 3 ):.3f} " )
204+ if "electricity" in measurement and "interval" not in net_string :
205+ diff = 1
206+ if "produced" in measurement :
207+ diff = - 1
208+ if net_string not in direct_data :
209+ direct_data [net_string ] = 0
210+
211+ if isinstance (f_val , int ):
212+ direct_data [net_string ] += f_val * diff
213+ else :
214+ direct_data [net_string ] += float (f_val * diff )
215+ direct_data [net_string ] = float (f"{ round (direct_data [net_string ], 3 ):.3f} " )
215216
216217 return direct_data
217218
@@ -925,7 +926,6 @@ def _heating_valves(self):
925926 def _power_data_peak_value (self , loc ):
926927 """Helper-function for _power_data_from_location()."""
927928 loc .found = True
928- loc .net_string = "dummy"
929929
930930 # Only once try to find P1 Legacy values
931931 if loc .logs .find (loc .locator ) is None and self .smile_type == "power" :
@@ -950,9 +950,7 @@ def _power_data_peak_value(self, loc):
950950 loc .key_string = f"{ loc .measurement } _{ peak } _{ log_found } "
951951 if "gas" in loc .measurement :
952952 loc .key_string = f"{ loc .measurement } _{ log_found } "
953- # Don't create net_elec_interval sensor
954- if "electricity" in loc .measurement and "interval" not in log_found :
955- loc .net_string = f"net_electricity_{ log_found } "
953+ loc .net_string = f"net_electricity_{ log_found } "
956954 val = loc .logs .find (loc .locator ).text
957955 log_date = parse (loc .logs .find (loc .locator ).get ("log_date" ))
958956 loc .log_date = log_date .astimezone (tz .gettz ("UTC" )).replace (tzinfo = None )
@@ -1005,7 +1003,6 @@ def _power_data_from_location(self, loc_id):
10051003 direct_data [loc .key_string ] = [loc .f_val , loc .log_date ]
10061004
10071005 if direct_data != {}:
1008- direct_data .pop ("dummy" )
10091006 return direct_data
10101007
10111008 def _preset (self , loc_id ):
0 commit comments