Skip to main content

xcom-protocol

Python library implementing Studer-Innotec Xcom protocol for Xcom-232i and Xcom-LAN (TCP/UDP).

NOTE: This lib is still WiP, so functionality is still limited, but feel free to create a pull request if you want to contribute ;)

DISCLAIMER: This library is NOT officially made by Studer-Innotec.

The complete official documentation is available on:
Studer-Innotec Download Center -> Software and Updates -> Communication protocol Xcom-232i

Getting Started

Requirements

Hardware

  • Xcom-232i or Xcom-LAN connected to your installation
  • Xcom-232i connected to PC using USB to RS-232 adapter (1) or PC in same local network as Xcom-LAN device
  • PC with at least USB2.0 or faster (works on Raspberry Pi 3/4 as well)

(1) I personally am successfully using an adapter with the PL2303 chipset like this one

Software

  • any Linux based OS (x86 / ARM)
  • python3 >= 3.9
  • python3-pip

Installation

pip install xcom-proto

Important

  • make sure you select the USB to RS-232 adapter as the serialDevice, usually on Linux it is /dev/ttyUSB[0-9]
  • when using Xcom-LAN UDP make sure MOXA is set up properly and reachable via a static IP in the local network
  • when using Xcom-LAN TCP make sure your device IP is static, reachable in the local network and specified in the MOXA

MOXA Setup for Xcom-LAN TCP

moxaTCP

  • address to Studer Portal is optional and can be removed if you don't need their web interface
  • Data Packing has to be set exactly as shown, you will get AssertionError otherwise

Important

If you want Studer Portal to still keep working, make sure you wait for at least 5 - 10 seconds to give it time to send data.

Adressing Devices

Make sure you are setting the correct destination Address dstAddr otherwise read / write operations might not work.

By default getValue and setValue use the address 100, which is a multicast address for all XTH, XTM and XTS devices, it does NOT include VarioTrack, VarioString or BSP.

Furthermore if you have more than one device of each type (VarioString, VarioTrack, XTS etc.) then using the multicast address is probably not desired either.

NOTE: for code examples see below

All used addresses of Studer devices can be found in the Studer documentation (page 8, section 3.5): StuderAddr3.5

Examples

Reading values

from xcom_proto import XcomP as param
from xcom_proto import XcomC
from xcom_proto import XcomRS232
from xcom_proto import XcomLANUDP

xcom = XcomRS232(serialDevice="/dev/ttyUSB0", baudrate=115200)
# OR (default ports are 4002 and 4001)
xcom = XcomLANUDP("192.168.178.110")
# OR overwriting ports
xcom = XcomLANUDP("192.168.178.110", dstPort=4002, srcPort=4001)

boostValue = xcom.getValue(param.SMART_BOOST_LIMIT)

pvmode = xcom.getValue(param.PV_OPERATION_MODE)
pvpower = xcom.getValue(param.PV_POWER) * 1000 # convert from kW to W
sunhours = xcom.getValue(param.PV_SUN_HOURS_CURR_DAY)
energyProd = xcom.getValue(param.PV_ENERGY_CURR_DAY)

soc = xcom.getValue(param.BATT_SOC)
battPhase = xcom.getValue(param.BATT_CYCLE_PHASE)
battCurr = xcom.getValue(param.BATT_CURRENT)
battVolt = xcom.getValue(param.BATT_VOLTAGE)

# please look into the official Studer parameter documentation to find out
# what type a parameter has
pvmode_manual = xcom.getValueByID(11016, XcomC.TYPE_SHORT_ENUM)

# using custom dstAddr (can also be used for getValueByID())
solarPowerVS1 = xcom.getValue(param.VS_PV_POWER, dstAddr=701)
solarPowerVS2 = xcom.getValue(param.VS_PV_POWER, dstAddr=702)

print(boostValue, pvmode, pvpower, sunhours, energyProd, soc, battPhase, battCurr, battVolt)

XcomLAN TCP

from xcom_proto import XcomP as param
from xcom_proto import XcomC
from xcom_proto import XcomRS232
from xcom_proto import XcomLANTCP

with XcomLANTCP(port=4001) as xcom:
    boostValue = xcom.getValue(param.SMART_BOOST_LIMIT)
    # same as above

Writing values

IMPORTANT: setValue() and setValueByID() have an optional named parameter propertyID which you can pass either:

  • XcomC.QSP_UNSAVED_VALUE: writes value into RAM only (default when not specified)
  • XcomC.QSP_VALUE: writes value into flash memory; you should write into flash only if you really need it, write cycles are limited!
from xcom_proto import XcomP as param
from xcom_proto import XcomC
from xcom_proto import XcomRS232
from xcom_proto import XcomLANUDP

xcom = XcomRS232(serialDevice="/dev/ttyUSB0", baudrate=115200)
# OR (default ports are 4002 and 4001)
xcom = XcomLANUDP("192.168.178.110")
# OR overwriting ports
xcom = XcomLANUDP("192.168.178.110", dstPort=4002, srcPort=4001)

xcom.setValue(param.SMART_BOOST_LIMIT, 100) # writes into RAM
xcom.setValue(param.FORCE_NEW_CYCLE, 1, propertyID=XcomC.QSP_VALUE) # writes into flash memory

# using custom dstAddr
xcom.setValue(param.BATTERY_CHARGE_CURR, 2, dstAddr=101) # writes into RAM
xcom.setValue(param.BATTERY_CHARGE_CURR, 2, dstAddr=101, propertyID=XcomC.QSP_VALUE) # writes into flash memory

# using custom value by ID
xcom.setValueByID(1107, XcomC.TYPE_FLOAT, 30) # writes into RAM
xcom.setValueByID(1107, XcomC.TYPE_FLOAT, 30, propertyID=XcomC.QSP_VALUE) # writes into flash memory

# using custom value by ID and dstAddr
xcom.setValueByID(1107, XcomC.TYPE_FLOAT, 30, dstAddr=101) # writes into RAM
xcom.setValueByID(1107, XcomC.TYPE_FLOAT, 30, dstAddr=101, propertyID=XcomC.QSP_VALUE) # writes into flash memory

XcomLAN TCP

from xcom_proto import XcomP as param
from xcom_proto import XcomC
from xcom_proto import XcomRS232
from xcom_proto import XcomLANTCP

with XcomLANTCP(port=4001) as xcom:
    xcom.setValue(param.SMART_BOOST_LIMIT, 100) # writes into RAM
    xcom.setValue(param.FORCE_NEW_CYCLE, 1, propertyID=XcomC.QSP_VALUE) # writes into flash memory
    # same as above

Troubleshooting

Writing value returns Permission Denied error

Usually this is caused by using the default multicast address to write values that are not part of the default address range. See above for more information.

AssertionError (invalid header / frame)

Usually this is caused by a wrong MOXA setup when using UDP / TCP, make sure Data Packing is set correctly in the MOXA. See above for more information.

When using Xcom-232i then checksum errors and AssertionErrors can be caused by a bad RS232 connection or a wrong BAUD rate setting.

Release files for xcom_proto 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xcom_proto 0.3.7
File Size Uploaded
xcom_proto-0.3.7.tar.gz 23.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xcom_proto 0.3.7
File Interpreter ABI Platform
xcom_proto-0.3.7-py3-none-any.whl Python 3 none any Details

Total release size: 47.3 kB

Release files / xcom_proto-0.3.7.tar.gz

Download URL xcom_proto-0.3.7.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
53f8d9ce1cabfb59cd9f3a879e65840477ff6a68c91fa771587bd464571ceda0
BLAKE2b-256 checksum
How to use checksums
237e4e0fe48f29a240dbb4be22b71187a88765e184125ea46e8a14b4ec5228de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-49-generic

Release files / xcom_proto-0.3.7-py3-none-any.whl

Download URL xcom_proto-0.3.7-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c75919179d1ffaf164893b574820e642cfe34a791025bb552c5d3c76c53c8638
BLAKE2b-256 checksum
How to use checksums
2042e83cfadb010cfd7770e6770ac38d9ddbfc3fea00960fcc4b7631c1a8b698
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Linux/6.8.0-49-generic

Release history Release notifications | RSS feed

This release

0.3.7 This release

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page