Giter VIP home page Giter VIP logo

py-senertec's Introduction

py-senertec

License: MIT PyPI version

Description

The py-senertec library provides a way to communicate with Senertec Dachsportal2 to monitor your energy unit. This library supports read-only communication. So changing values for your energy unit isn't implemented and not planned yet.

Requirements

  • Python 3.10+
  • Account for Senertec Dachsportal2/Remeha KWK

Tested with this devices

I could test with this devices but others should also work:

  • Senertec Dachs 0.8
  • Senertec Dachs InnoGen
  • Senertec Dachs Gen2 F5.5
  • Remeha eLecta 300 (technically same as Senertec Dachs 0.8)

Installation

$ pip install py-senertec

Usage

Login and initialization

from senertec.client import senertec
from senertec.canipValue import canipValue
import json
import os

#this example uses no filtering, read below how to use a filter instead of None as first parameter.
senertec = senertec(None)
#set your callback function for messages
senertec.messagecallback = self.output
senertec.login("username", "password")
senertec.init()

Requesting data

units = senertec.getUnits()
senertec.connectUnit(units[0].serial)
# request all available data from all boards
for points in senertec.boards:
            ids = points.getFullDataPointIds()
            # result will be received through callback function which was set above
            senertec.request(ids)
senertec.logout()

Using callback function

Once the websocket has been started, data will be transmitted through the websocket. To get the websocket data, you need to add a callback which was done above. The callback function could look like this:

def output(self, value: canipValue):
        print(value.friendlyDataName + ": " +
              value.dataValue.__str__() + value.dataUnit)

Errors of energy unit

Errors can also be read out with a simple function. The errors are read out on the connect function and will only be refreshed on a reconnect.

# values are returned directly from function
errors = senertec.getErrors()

A full example can be found here

Filtering (recommended)

If you specify a json string in the senertec contructor you can limit what datapoints should be received. This is pretty usefull if you know what data you want from your heating system e.g. power, temperature. By default all datapoints are included which are more than 400 in most cases and receiving them takes some time. This json string should look like this. The json string contains the productGroup at the top and below the datapoints which should be included. You get the productGroup from the getUnits() function.

What are these datapoints?

Take a look at this manual from Remeha (Page 39). There is already a good explanation of how these datapoints are composed.

py-senertec's People

Contributors

kleinrotti avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

mulles

py-senertec's Issues

BM001 values

I uninstalled version 0.3.0 and installed version 0.5.0.
I mainly want to read out the values ​​BM001. Unfortunately, they arrive randomly. sometimes no values ​​sometimes all.
can you send me an example script where the problem is solved?
Thanks

Add source of API documentation used by the python lib

Did you reverse engineer something or is there documentation about the websocket (wss://dachsconnect.senertec.com/ws) used within the lib? Do you use an official API provided by senerectec for https://dachsconnect.senertec.com/) ?

I am currently developing a programm which calculated how much money you will get per month from grid provider, based on energy prices on EPEX energy exchange and production scrapped with help of selenium python lib from dachsportal.senertec.com.

The programm will be publised under open source software soon and maybe I can use a defined API instead of scrapping from a web page?

Adjustable time period for the getChart() function

Since in the current configuration only the values from "Fri Jan 07 2022" to "Sat Jan 08 2022" are retrieved during chart retrieval, I suggest that you can also add the start and end time.

Proposal:
File: senertec.client

 def getChart(self, chartname: str,starttime: int= 1641596400000 ,endtime: int= 1641682800000):
    """Get a history chart of the connected unit.
    """
    sn = self.__connectedUnit__["seriennummer"]
    response = self.__post__(
        f"/rest/charts/{sn}/data", json.dumps(
            {"start": starttime, "end": endtime, "parameters": {}, "chartName": chartname, "sn": sn}))
            # {"start": 1641596400000, "end": None, "parameters": {}, "chartName": chartname, "sn": sn}))

Innogen

Hallo,
Ich besitze den Vorgänger von Senertec Dachs 0.8
das ist der Dachs InnoGen.
Kann die Daten aber genauso übers Dachsportal 2 auslesen.
Bekomm hier aber das Python-Script nur teilweise zum laufen.
Es gibt mir keine Werte aus.
Kann das angepasst werden?
Vielen Dank

Error when API request responds without units

$ python output_data.py
py-senertec: 2024-07-11 19:26:21 INFO Logging in..
py-senertec: 2024-07-11 19:26:21 INFO Login was successful.
py-senertec: 2024-07-11 19:26:21 INFO Initializing senertec platform...
Traceback (most recent call last):
File "/var/home/VENV_BHWK_Senertec_Dachs2API/output_data.py", line 106, in
start()
File "/var/home/VENV_BHWK_Senertec_Dachs2API/output_data.py", line 42, in start
if senertecClient.connectUnit(units[0].serial) is False:
~~~~~^^^
IndexError: list index out of range

I am not able to get any "names" for the units?
Even though there are 3 units shown on dachsconnect.senertec.com, see the following screenshot:

Screenshot from 2024-07-11 19-40-40

If you want I can create a pull request for better error messaging in case no units are returned by the API:

Screenshot

Alle Datenpunkte auslesen

Hallo,
Möchte alle Datenpunkte auslesen bekomm mit diesem Script aber immer einen Fehler.
Vielleicht kann mir jemand helfen.

Benutzername Passwort hab ich richtig eingetragen

`

#

#
This example outputs all values to the console window with a list of errors of your energy unit.
#

#

from senertec.client import senertec
from senertec.canipValue import canipValue
import json
from time import sleep
import os


result = []


def start():
# you can use the example file datapointFilter.json to fetch only datapoints you really want!
# edit the file as your needs, this is highly recommended.
file = open(os.getcwd() + "\\datapointFilter.json")
filter = json.load(file)
file.close()
# create a new senertec object with filter
senertecClient = senertec(filter)
global result
totalDataPoints = 0
timeoutCounter = 0

# to get all possible datapoints you can specify None
senertec = senertec(None)

# set your callback function where received data should go to
senertecClient.messagecallback = output

# login to dachsportal2 with email and password
if senertecClient.login("username", "password") is False:
    return
# if login was successful you need to initialize the platform.
if senertecClient.init() is False:
    return
# get all energy units/heating systems from your account.
units = senertecClient.getUnits()
# connect to first unit
if senertecClient.connectUnit(units[0].serial) is False:
    return
print(f"Connected to unit: {units[0].model} with serial: {units[0].serial}")
# get errors to output them below
errors = senertecClient.getErrors()

# request all datapoints.
for board in senertecClient.boards:
    ids = board.getFullDataPointIds()
    senertecClient.request(ids)
    totalDataPoints += len(board.datapoints)

# if you want specific datapoints you can loop through the boards to find it and request it then
#for board in senertecClient.boards:
#    datapoint = board.getFullDatapointIdByName("MM011")
#    if(datapoint):
#        senertecClient.request(datapoint)
#        totalDataPoints += 1
#        break


# loop wait 2 seconds and checks if all points get received
while (len(result) < totalDataPoints):
    # break after 60sec timeout
    if timeoutCounter > 30:
        break
    sleep(2)
    timeoutCounter += 1
# logout after all datapoints get received or timeout was reached
senertecClient.logout()

# print all values
for value in result:
    print("Source: " + value.sourceDatapoint + "\nName: " + value.friendlyDataName + "\nValue: " +
          value.dataValue.__str__() + value.dataUnit + "\n")

#print total count of received values  
print(f"Received {len(result)} values.")

# print all errors
print("\n-----Device errors-----")
for e in errors:
    if (e.code != ""):
        print(
            f"\nError: {e.code} in Board: {e.boardName} \nCategorie: {e.errorCategory} \nMessage: {e.errorTranslation}")


 # this is the callback function to get the requested data from the websocket connection.
 def output(value: canipValue):
 global result
 temp = next(
    (
        x
        for x in result
        if x.sourceDatapoint == value.sourceDatapoint
    ),
    None,
)
# sometimes we get values twice, so we filter it
if not temp:
    result.append(value)


 start()`

Differenzierte Datapoint Namen bei Array Werten

Um die Datenverarbeitung für die lib und für HA zu verbessern schlage ich vor bei werden die in einem Array geliefert werden diese verschieden zu benennen.

Beispiel die Speichertemperaturen:
Source: BM001 Name: Gem.PuSpTemp Value: 0.05°C SCB-06
Source: BM001 Name: Gem.PuSpTemp Value: 55.2°C SCB-06 Wert vom Screenshot
Source: BM001 Name: Gem.PuSpTemp Value: 39.4°C SCB-06
Source: BM001 Name: Gem.PuSpTemp Value: -2.5°C SCB-06
Source: BM001 Name: Gem.PuSpTemp Value: 19.59°C SCB-06
Source: BM001 Name: Gem.PuSpTemp Value: 0.05°C EM-FC01
Source: BM001 Name: Gem.PuSpTemp Value: 0.05°C SCB-06

ggf. mit _1 _2 _3 _4 etc. oder ähnlich

Screenshot 2023-04-02 222737

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.