Error trying to retrieve a single day’s production from Solplanet/AISWEI Cloud API

Based on the very useful answers by @Rik to this question: AISWEI Solar API – Get Plant List, I am able to read my solar panels’ daily and monthly power production (somewhat confusing referred to as “bymonth” and “byyear”, respectively) from AISWEI’s cloud API. Total production (“bytotal”) also works nicely.
However, the “bydays” option, which is supposed to return the output at 20 minutes interval (I do not have the “pro” version), returns a timeout server error (504). I have tried both the Python and the PHP approach, and the issue applies to both. Has anyone experienced the same issue? Perhaps I have introduced a bug somewhere in the process, but I am unable to spot it.

My Python version is shown below. Basically, I have simplified @Rik’s code by removing the “pro” option and making getPlantOutput a function for all “period” parameter cases (bydays, bymonth, byyear, bytotal).

import requests
import json
import os
import hmac
import hashlib
import base64
from datetime import datetime

os.environ['TZ'] = 'Europe/Amsterdam'  # Setting the default timezone
crlf = "n"  # Line break

host = 'https://eu-api-genergal.aisweicloud.com'

ApiKey = '...'   
AppKey = '...'    
AppSecret = '...' 

today = datetime.today().strftime('%Y-%m-%d')
month = datetime.today().strftime('%Y-%m')

def getfromapi(url):
    global host, AppKey, AppSecret, ApiKey

    method = "GET"
    accept = "application/json"
    content_type = "application/json; charset=UTF-8"

    key = f"key={ApiKey}"
    url += ('&' if '?' in url else '?') + key
    s1 = url.split('?')
    s2 = sorted(s1[1].split('&'))
    url = s1[0] + '?' + '&'.join(s2)

    header = {
        "User-Agent": "app 1.0",
        "Content-Type": content_type,
        "Accept": accept,
        "X-Ca-Signature-Headers": "X-Ca-Key",
        "X-Ca-Key": AppKey
    }

    str_sign = f"{method}n{accept}nn{content_type}nnX-Ca-Key:{AppKey}n{url}"
    sign = base64.b64encode(hmac.new(AppSecret.encode('utf-8'), str_sign.encode('utf-8'), hashlib.sha256).digest())
    header['X-Ca-Signature'] = sign

    response = requests.get(f"{host}{url}", headers=header)
    
    data = response.text

    try:
        json_data = json.loads(data)
    except:
        json_data = {}

    json_data['status'] = response.status_code
    json_data['headers'] = response.headers

    return json_data

def getPlantOutput(period, date):
    url = "/getPlantOutput?period=" + period + "&date=" + date
    json1 = getfromapi(url)
    
    if json1['status'] == 200:
        return json1
    else:
        msg = f"Error retrieving data: {json1['status']}n{json1['headers']}"
        return msg

Now, calling getPlantOutput("bymonth", month), for instance, returns something like

{'key': '4b5102e528db40009b1a237f04a32663', 'dataunit': 'KWh', 'data': [{'time': '2024-05-01', 'no': '1', 'value': '59.8'}, {'time': '2024-05-02', 'no': '2', 'value': '59.0'}, {'time': '2024-05-03', 'no': '3', 'value': '57.8'}, {'time': '2024-05-04', 'no': '4', 'value': '47.1'}, {'time': '2024-05-05', 'no': '5', 'value': '28.1'}, {'time': '2024-05-06', 'no': '6', 'value': '16.5'}, {'time': '2024-05-07', 'no': '7', 'value': '62.2'}, {'time': '2024-05-08', 'no': '8', 'value': '52.6'}, {'time': '2024-05-09', 'no': '9', 'value': '47.6'}, {'time': '2024-05-10', 'no': '10', 'value': '12.1'}, {'time': '2024-05-11', 'no': '11', 'value': '28.9'}, {'time': '2024-05-12', 'no': '12', 'value': '62.8'}, {'time': '2024-05-13', 'no': '13', 'value': '62.3'}, {'time': '2024-05-14', 'no': '14', 'value': '61.4'}, {'time': '2024-05-15', 'no': '15', 'value': '60.6'}, {'time': '2024-05-16', 'no': '16', 'value': '61.3'}, {'time': '2024-05-17', 'no': '17', 'value': '62.6'}, {'time': '2024-05-18', 'no': '18', 'value': '60.0'}, {'time': '2024-05-19', 'no': '19', 'value': '50.1'}, {'time': '2024-05-20', 'no': '20', 'value': '43.8'}, {'time': '2024-05-21', 'no': '21', 'value': '57.4'}, {'time': '2024-05-22', 'no': '22', 'value': '56.5'}, {'time': '2024-05-23', 'no': '23', 'value': '26.0'}, {'time': '2024-05-24', 'no': '24', 'value': '55.2'}, {'time': '2024-05-25', 'no': '25', 'value': '47.7'}, {'time': '2024-05-26', 'no': '26', 'value': '38.9'}, {'time': '2024-05-27', 'no': '27', 'value': '35.5'}, {'time': '2024-05-28', 'no': '28', 'value': '0.0'}, {'time': '2024-05-29', 'no': '29', 'value': '0.0'}, {'time': '2024-05-30', 'no': '30', 'value': '0.0'}, {'time': '2024-05-31', 'no': '31', 'value': '0.0'}], 'status': 200, 'headers': {'Date': 'Tue, 28 May 2024 19:57:28 GMT', 'Content-Type': 'text/plain;charset=UTF-8', 'Content-Length': '1512', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=25', 'Server': 'Kaede/3.5.3.777 (ec3d9i5ys)', 'X-Ca-Request-Id': '791B21C1-BD4C-4E4B-916F-A78FEE5A5684'}}

that is, each day’s total production this month. However, calling getPlantOutput("bydays", today) or, say, getPlantOutput("bydays", "2024-05-10") returns

Error retrieving data: 504
{'Date': 'Tue, 28 May 2024 20:00:55 GMT', 'Content-Type': 'application/oct-stream', 'Content-Length': '0', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=25', 'X-Ca-Error-Message': 'Backend service request timeout', 'Server': 'Kaede/3.5.3.777 (ec3d9z7df)', 'X-Ca-Error-Code': 'D504TO', 'X-Ca-Request-Id': '56DF2B30-8A1B-4F18-98A3-10EC0ED7741C'}

I also tried using the host https://api.general.aisweicloud.com instead of https://eu-api-genergal.aisweicloud.com, but I don’t know if my data would be available there at all, and also I don’t seem to be able to connect to it:

HTTPSConnectionPool(host='api.general.aisweicloud.com', port=443): Max retries exceeded with url: /getPlantOutput?date=2024-05-28&key=4b5102e528db40009b1a237f04a32663&period=bydays (Caused by SSLError(CertificateError("hostname 'api.general.aisweicloud.com' doesn't match either of '*.aisweicloud.com', 'aisweicloud.com'")))

Any thoughts?

New contributor

Axel Geertinger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật