LeskoIam / kronoterm_cloud_api

GNU General Public License v3.0
3 stars 0 forks source link

Retrieve energy consumption #16

Closed oh-c closed 1 month ago

oh-c commented 1 month ago

Hi,

First of all a big thank you! I've been wanting to integrate my Kronoterm Heat Pump into Home Assistant and your great work has made this possible.

Have you found a way to retrieve the energy consumption trough the Web API? It looks like you can get the data from https://cloud.kronoterm.com/jsoncgi.php?TopPage=4&Subpage=4&Action=4 - but it look like we'll get back aggregated / calculated usage.

LeskoIam commented 1 month ago

Hello!

I was already looking into this, a few things:

Plan is to take a look again, but can't guaranty when.

oh-c commented 1 month ago

Is there any form of documentation on the Cloud API - or are you purely reverse engineering it?

LeskoIam commented 1 month ago

No official documentation. They only support MODBUS on the user side and have documentation for that. So reverse engineering it is.

A few bits of info I already know:

This is my first go at getting consumption data:

    def get_power_consumption(self):
        """
        data = {"year": "2024",
                "d1": "195",     # day of the year
                "d2": "21",      # hour
                "type": "hour",  # year, month, hour, week, day, hour
                "aValues[]": "29"}  # data to graph

        :return:
        """
        # https://cloud.kronoterm.com/jsoncgi.php?TopPage=4&Subpage=1&Action=3
        url = "TopPage=4&Subpage=1&Action=3"
        url = self.base_url + url
        # TODO: research aValues[]!!!

        day_of_year = datetime.now().timetuple().tm_yday

        data = {"year": "2024",
                "d1": str(day_of_year),
                "d2": "18",
                "type": "hour",
                "aValues[]": "29"}
        return requests.post(url, data=data, headers=self.headers).json()
LeskoIam commented 1 month ago

And another tip. Open console on cloud.kronoterm.com and set user_level = 1, navigate (don't reload the page!) to 'Trends' and you'll see you can now plot more data series with added data types.

LeskoIam commented 1 month ago

Hey @oh-c ! New version '0.1.9' with added power consumption endpoint is released. PyPI.