Skip to content

Commit

Permalink
Merge pull request #14 from ckvsoft/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ckvsoft authored Jan 28, 2024
2 parents 5782d18 + 04c6179 commit d9e4611
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ For those who prefer to work in a config file, there is config.toml
| `primary` | If this market is enabled this point sets it as the primary market |
| `enabled` | To use this entry it must be `enabled`. Otherwise `disabled` |

## PV Panells
## PV Panels
| Setting | Meaning |
|:-------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `LocLat` | Latitude |
Expand Down
1 change: 1 addition & 0 deletions core/mqttclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def subscribe(self, mqtt_result, query_topic):
raise TimeoutError
time.sleep(1)

time.sleep(1)
payload = self.response_payload
mqtt_result.result = payload
self.logger.log_debug(f"result {payload}")
Expand Down
1 change: 1 addition & 0 deletions core/seusscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def get_total_solar_yield(self, essunit):
return total_solar

def process_solar_forecast(self, total_solar):
test = StatsManager.update_percent_status_data('solar', 'efficiency', 22.4)
forecast = Forecastsolar()
total_forecast = forecast.forecast()

Expand Down
26 changes: 19 additions & 7 deletions core/statsmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,32 @@ def update_percent_status_data(cls, group, key, new_value):
date_key = f"date_{key}"
today = datetime.now().strftime('%Y-%m-%d')

if group not in StatsManager.data:
if group not in cls.data:
cls.insert_new_status_data(group, key, new_value)

cls.data[group][date_key] = today
value = new_value

if key in cls.data[group]:
value = cls.data[group][key]
value = (value + new_value) / 2
cls.data[group][key] = value
if isinstance(cls.data[group][key], list):
value, count = cls.data[group][key]
if count == 1000:
e_value =value * count
e_value = (e_value - value)
count -= 1
value = e_value / count
else:
count = 1

value = (count * value + new_value) / (count + 1)
count += 1
cls.data[group][key] = (value, count)
else:
value = new_value
cls.data[group][key] = value
cls.data[group][key] = (new_value, 1)

cls.save_data()

return value
return round(value, 2)

@classmethod
def cleanup_old_entries(cls):
Expand Down
2 changes: 1 addition & 1 deletion core/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
# Project: [SEUSS -> Smart Ess Unit Spotmarket Switcher
#

__version__ = "0.1.4"
__version__ = "0.1.7"

0 comments on commit d9e4611

Please sign in to comment.