-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEMS Requests combined to avoid timeouts #1262
Conversation
packages/modules/devices/fems/bat.py
Outdated
# response = session.get( | ||
# "http://" + self.ip_address + | ||
# ":8084/rest/channel/_sum/(GridActivePower|ProductionActivePower|ConsumptionActivePower)", | ||
# timeout=2).json() | ||
# for singleValue in response: | ||
# address = singleValue["address"] | ||
# if (address == "_sum/GridActivePower"): | ||
# grid = scale_metric(singleValue['value'], singleValue.get('unit'), 'W') | ||
# elif address == "_sum/ProductionActivePower": | ||
# pv = scale_metric(singleValue['value'], singleValue.get('unit'), 'W') | ||
# elif address == "_sum/ConsumptionActivePower": | ||
# haus = scale_metric(singleValue['value'], singleValue.get('unit'), 'W') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# response = session.get( | |
# "http://" + self.ip_address + | |
# ":8084/rest/channel/_sum/(GridActivePower|ProductionActivePower|ConsumptionActivePower)", | |
# timeout=2).json() | |
# for singleValue in response: | |
# address = singleValue["address"] | |
# if (address == "_sum/GridActivePower"): | |
# grid = scale_metric(singleValue['value'], singleValue.get('unit'), 'W') | |
# elif address == "_sum/ProductionActivePower": | |
# pv = scale_metric(singleValue['value'], singleValue.get('unit'), 'W') | |
# elif address == "_sum/ConsumptionActivePower": | |
# haus = scale_metric(singleValue['value'], singleValue.get('unit'), 'W') |
Please remove, GitHub is already tracking changes
# Grid total energy sums | ||
# response = session.get( | ||
# 'http://'+self.ip_address+':8084/rest/channel/_sum/Grid.+ActiveEnergy', | ||
# timeout=1).json() | ||
|
||
# for singleValue in response: | ||
# address = singleValue['address'] | ||
# if (address == '_sum/GridBuyActiveEnergy'): | ||
# imported = scale_metric(singleValue['value'], singleValue.get('unit'), 'Wh') | ||
# elif (address == '_sum/GridSellActiveEnergy'): | ||
# exported = scale_metric(singleValue['value'], singleValue.get('unit'), 'Wh') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Grid total energy sums | |
# response = session.get( | |
# 'http://'+self.ip_address+':8084/rest/channel/_sum/Grid.+ActiveEnergy', | |
# timeout=1).json() | |
# for singleValue in response: | |
# address = singleValue['address'] | |
# if (address == '_sum/GridBuyActiveEnergy'): | |
# imported = scale_metric(singleValue['value'], singleValue.get('unit'), 'Wh') | |
# elif (address == '_sum/GridSellActiveEnergy'): | |
# exported = scale_metric(singleValue['value'], singleValue.get('unit'), 'Wh') |
|
||
# power = scale_metric(response["value"], response.get("unit"), 'W') * -1 | ||
|
||
# response = session.get( | ||
# 'http://'+self.ip_address+':8084/rest/channel/_sum/ProductionActiveEnergy', | ||
# timeout=2).json() | ||
# exported = scale_metric(response["value"], response.get("unit"), 'Wh') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# power = scale_metric(response["value"], response.get("unit"), 'W') * -1 | |
# response = session.get( | |
# 'http://'+self.ip_address+':8084/rest/channel/_sum/ProductionActiveEnergy', | |
# timeout=2).json() | |
# exported = scale_metric(response["value"], response.get("unit"), 'Wh') |
Changes completed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitte noch die Flake8-Änderungen vornehmen, damit der Test durchläuft.
Danke für den Hinweis, die Korrekturen sind gemacht. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Der Test muss noch angepasst werden. Hast Du eine Beispiel-Antwort für die neue Abfrage?
Die Antworten von meinem FEMS stehen jeweils unter der Abfrage: inverter.py:
counter.py:
|
Sorry, ich habe mich lange nicht gemeldet. Ich habe die Tests erstellt bzw angepasst und war so frei, sie in Deinen Branch zu pushen. Danke für deine Beispieldaten! |
@@ -20,7 +20,8 @@ def update(self, session: Session) -> None: | |||
else: | |||
data = "ess2" | |||
response = session.get( | |||
"http://" + self.ip_address + ":8084/rest/channel/"+data+"/(Soc|DcChargeEnergy|DcDischargeEnergy)", | |||
"http://" + self.ip_address + ":8084/rest/channel/(" + data + "|_sum)/" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but this change breaks queries on older FEMS versions.
At least on my FEMS v 2022.12.5 a query with Regex in any "segment" other than the last one is NOT supported. FEMS just returns:
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://<IP>:8084/rest/channel/(meter0%7C_sum)/(ActivePower.*%7CVoltageL.%7CFrequency%7CGrid.+ActiveEnergy)
I also see the optimization done here. But I might not be the only one with older version. Actually I have no control on if and when Fenecon updates my FEMS.
So I have no other idea but reverting this!
At least older FEMS seem not to support Regex in any path fragment other than the very last one.
My FEMS (Fenecon Home 10, Version 2022 and later) is very sensitive with answering requests at the REST/JSON interface. Too many requests lead to very long answering times (30 s or more) and therefore to timeouts in the OpenWB. In the OpenEMS community you can find that there is indeed a limitation for not overloading the FEMS. The impact on the OpenWB is shown on the attached picture.
With my modifications (combining of the requests in inverter.py, bat.py, counter.py) and increasing the timeout value in counter.py to 6 almost all of the peaks (occurences of timeouts that lead to the wrong calculation of the consumption) disappear. They aren't gone totally, but reduced to a very small quantity.