From 97dc9b1a8585e1e9d67348ec024e05339052a8a2 Mon Sep 17 00:00:00 2001 From: Ian Connor Date: Fri, 30 Aug 2024 09:52:31 +1000 Subject: [PATCH 1/2] Update script.py Sunrise and sunset are passed in based on your location in your user profile now --- script.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/script.py b/script.py index 525c072..df83061 100644 --- a/script.py +++ b/script.py @@ -91,15 +91,6 @@ def update_reason(buy_price, sell_price, lowest_buy_price, highest_sell_price, # Margin between min / max buy & sell prices price_margin = min_sell_price - max_buy_price # noqa -# Determine today's date -today = local_time.date() - -# Calculate the sunrise and sunset times using astral (assumed to be in UTC and converted to local) -# location.observer comes from isolarcloud and is provided by Powston -s = sun(location.observer, date=today) -sunrise = s['sunrise'] # + timedelta(hours=timezone) -sunset = s['sunset'] # + timedelta(hours=timezone) - # Adjusted sunrise and sunset times with solar active hours sunrise_plus_active = sunrise + timedelta(hours=solar_active_hours) sunset_minus_active = sunset - timedelta(hours=solar_active_hours) From 2ad519b51204acb785bd3bc9ca29e5a9d232d9c8 Mon Sep 17 00:00:00 2001 From: Ian Connor Date: Thu, 29 Aug 2024 23:58:54 +0000 Subject: [PATCH 2/2] Update tests to show error an add back full_battery --- script.py | 2 +- test_script.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/script.py b/script.py index df83061..72162dd 100644 --- a/script.py +++ b/script.py @@ -80,7 +80,7 @@ def update_reason(buy_price, sell_price, lowest_buy_price, highest_sell_price, local_time = interval_time # + timedelta(hours=timezone) # Calculate the energy required to reach full charge (in kWh) -remaining_energy_kWh = ( - battery_soc) / 100 * battery_capacity_kWh +remaining_energy_kWh = (full_battery - battery_soc) / 100 * battery_capacity_kWh # Calculate the time required to charge the battery to full (in hours) time_to_full_charge = remaining_energy_kWh / max_charge_rate_kW diff --git a/test_script.py b/test_script.py index efb3fd4..365cd92 100644 --- a/test_script.py +++ b/test_script.py @@ -28,7 +28,7 @@ def test_script(self): "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } - + response_json = '' try: check_code_response = requests.post(powston_api_test_code_endpoint, json=body, headers=header) check_code_response.raise_for_status() @@ -36,7 +36,7 @@ def test_script(self): response_json = check_code_response.json() self.assertEqual(check_code_response.status_code, 200, "Expected status code 200") self.assertIn('Success', response_json['problems'], "Expected 'Success' in problems") - self.assertTrue(response_json['status'], "Expected status to be True") + self.assertTrue(response_json['status'], f"Expected status to be True: {response_json}") except requests.RequestException as e: self.fail(f"Request failed: {str(e)}") except KeyError as e: