Skip to content

Commit

Permalink
Support Ahoy >= V0.8.39
Browse files Browse the repository at this point in the history
## V1.63
### script
* support Ahoy Versions >= V 0.8.39 ( #116 )
  • Loading branch information
reserve85 authored Jan 2, 2024
1 parent 258f2ec commit 2356a84
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## V1.63
### script
* support Ahoy Versions >= V 0.8.39 ( https://github.com/reserve85/HoymilesZeroExport/issues/116 )

## V1.62
### script
* added package argparse, install it with "pip3 install argparse" or "pip3 install -r requirements.txt"
Expand Down
15 changes: 13 additions & 2 deletions HoymilesZeroExport.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

__author__ = "Tobias Kraft"
__version__ = "1.62"
__version__ = "1.63"

import requests
import time
Expand Down Expand Up @@ -108,7 +108,7 @@ def SetLimitOpenDTU(pInverterId, pLimit):

def SetLimitAhoy(pInverterId, pLimit):
url = f"http://{AHOY_IP}/api/ctrl"
data = f'''{{"id": {pInverterId}, "cmd": "limit_nonpersistent_absolute", "val": {pLimit}}}'''
data = f'''{{"id": {pInverterId}, "cmd": "limit_nonpersistent_absolute", "val": {pLimit*AHOY_FACTOR}}}'''
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
logger.info('Ahoy: Inverter "%s": setting new limit from %s Watt to %s Watt',NAME[pInverterId],CastToInt(CURRENT_LIMIT[pInverterId]),CastToInt(pLimit))
requests.post(url, data=data, headers=headers)
Expand Down Expand Up @@ -315,6 +315,16 @@ def CheckAhoyVersion():
logger.error('Error: Your AHOY Version is too old! Please update at least to Version %s - you can find the newest dev-releases here: https://github.com/lumapu/ahoy/actions',MinVersion)
quit()

def GetAhoyLimitFactor():
Version = '0.8.39'
url = f'http://{AHOY_IP}/api/system'
ParsedData = requests.get(url, timeout=10).json()
AhoyVersion = str((ParsedData["version"]))
if version.parse(AhoyVersion) < version.parse(Version):
return 1
else:
return 10

def GetHoymilesInfoOpenDTU(pInverterId):
url = f'http://{OPENDTU_IP}/api/livedata/status/inverters'
ParsedData = requests.get(url, auth=HTTPBasicAuth(OPENDTU_USER, OPENDTU_PASS), timeout=10).json()
Expand Down Expand Up @@ -1083,6 +1093,7 @@ def GetPriorityMode():
newLimitSetpoint = 0
if USE_AHOY:
CheckAhoyVersion()
AHOY_FACTOR = GetAhoyLimitFactor()
if GetHoymilesAvailable():
for i in range(INVERTER_COUNT):
SetHoymilesPowerStatus(i, True)
Expand Down

0 comments on commit 2356a84

Please sign in to comment.