diff --git a/examples/main.py b/examples/main.py index b95a137..3db8ad3 100644 --- a/examples/main.py +++ b/examples/main.py @@ -1,4 +1,5 @@ """Test-module for pyCheckwatt.""" + import argparse import json import os diff --git a/pycheckwatt/__init__.py b/pycheckwatt/__init__.py index 7b065cb..e014623 100644 --- a/pycheckwatt/__init__.py +++ b/pycheckwatt/__init__.py @@ -31,6 +31,7 @@ _LOGGER = logging.getLogger(__name__) + class CheckwattManager: """CheckWatt manager.""" @@ -288,7 +289,6 @@ async def get_customer_details(self): except (ClientResponseError, ClientError) as error: return await self.handle_client_error(endpoint, headers, error) - async def get_battery_peak_data(self): """Fetch battery peak data from CheckWatt.""" try: @@ -332,8 +332,12 @@ async def get_battery_peak_data(self): self.battery_charge_peak_ac = charging_meter.get("PeakAcKw") print(self.battery_charge_peak_ac) self.battery_charge_peak_dc = charging_meter.get("PeakDcKw") - self.battery_discharge_peak_ac = discharging_meter.get("PeakAcKw") - self.battery_discharge_peak_dc = discharging_meter.get("PeakDcKw") + self.battery_discharge_peak_ac = discharging_meter.get( + "PeakAcKw" + ) + self.battery_discharge_peak_dc = discharging_meter.get( + "PeakDcKw" + ) return True @@ -347,26 +351,25 @@ async def get_battery_peak_data(self): except (ClientResponseError, ClientError) as error: return await self.handle_client_error(endpoint, headers, error) - - - async def get_fcrd_month_net_revenue(self): """Fetch FCR-D revenues from checkwatt.""" misseddays = 0 try: from_date = datetime.now().strftime("%Y-%m-01") to_date = datetime.now() + timedelta(days=1) -# to_date = datetime.now() + # to_date = datetime.now() to_date = to_date.strftime("%Y-%m-%d") lastday_date = datetime.now() + relativedelta(months=1) - lastday_date = datetime(year=lastday_date.year, month=lastday_date.month, day=1) + lastday_date = datetime( + year=lastday_date.year, month=lastday_date.month, day=1 + ) lastday_date = lastday_date - timedelta(days=1) lastday = lastday_date.strftime("%d") dayssofar = datetime.now() -# dayssofar = datetime.now() + timedelta(days=1) + # dayssofar = datetime.now() + timedelta(days=1) dayssofar = dayssofar.strftime("%d") daysleft = int(lastday) - int(dayssofar) @@ -391,8 +394,9 @@ async def get_fcrd_month_net_revenue(self): dayswithmoney = int(dayssofar) - int(misseddays) if response.status == 200: self.dailyaverage = self.revenuemonth / int(dayswithmoney) - self.monthestimate = ((self.dailyaverage * daysleft) - + self.revenuemonth) + self.monthestimate = ( + self.dailyaverage * daysleft + ) + self.revenuemonth return True _LOGGER.error( @@ -790,7 +794,12 @@ def battery_peak_data(self): if self.battery_discharge_peak_dc is not None: battery_discharge_peak_dc = self.battery_discharge_peak_dc - return battery_charge_peak_ac,battery_charge_peak_dc,battery_discharge_peak_ac,battery_discharge_peak_dc + return ( + battery_charge_peak_ac, + battery_charge_peak_dc, + battery_discharge_peak_ac, + battery_discharge_peak_dc, + ) @property def electricity_provider(self): @@ -864,16 +873,16 @@ def fcrd_today_net_revenue(self): return revenue -# @property -# def tomorrow_revenue(self): -# """Property for tomorrow's revenue.""" -# revenue = 0 -# if self.revenue is not None: -# if len(self.revenue) > 1: -# if "NetRevenue" in self.revenue[1]: -# revenue = self.revenue[1]["NetRevenue"] + # @property + # def tomorrow_revenue(self): + # """Property for tomorrow's revenue.""" + # revenue = 0 + # if self.revenue is not None: + # if len(self.revenue) > 1: + # if "NetRevenue" in self.revenue[1]: + # revenue = self.revenue[1]["NetRevenue"] -# return revenue + # return revenue def _get_meter_total(self, meter_type): """Solar, Charging, Discharging, EDIEL_E17, EDIEL_E18, Soc meter summary.""" diff --git a/pycheckwatt/const.py b/pycheckwatt/const.py index 210828c..25d6de7 100644 --- a/pycheckwatt/const.py +++ b/pycheckwatt/const.py @@ -1,4 +1,5 @@ """Docstring.""" + SENSOR = "SENSOR" diff --git a/setup.py b/setup.py index d9bd158..2dc9e20 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """Setup script for pyCheckwatt module.""" + from setuptools import find_packages, setup MIN_PY_VERSION = "3.10"