Sign inSign up

boriswde/maplecun-splitproxy

By boriswde

Updated 4 months ago

MapleCUN Proxy: Use your MapleCUN for multiple systems. No Stackable implementation required

Image
Networking
Internet of things
0

603

boriswde/maplecun-splitproxy repository overview

MapleCUN Split Proxy

This proxy was developed to use the radio module of a MapleCUN (using a-culfw) with software that is not cabable of using "stackable" CULs. The proxy splits all the modules into one http port each. Usually a MapleCUN with a-culfw uses multiplexing with asterisk prefixes (*, **, etc.) on a single TCP port. This hides this logic: Each of the modules will get a dedicated TCP port. Applications like Home Assistant, wmbusmeters, Homegear oder FHEM can be configured to use a single port with knowing about stackable CULs. It just looks like 4 different devices (but on a single IP). All devices will see the responses of the radio modules. If there are three clients connected to radio1, all clients will see the responses of this specific radio module.

Features

  • Single connection to MapleCul: Just one connection to MapleCul device. Other connections are handled by proxy and multiplexed.
  • Zero CPU Load: Uses blocking I/O.
  • Debug-Modus: Allows realtime monitoring of command from and to MapleCUL
  • Multi-Arch: Native support for amd64, arm64 (Pi 4/5). Unfortunately arm/v7 (Pi 2/3) is not supported due to their age.

Changelog

  • V 1.1: Version call "V" now appends the string " CUL" to the end to for wmbusmeters

Module mapping

The proxy handles sending the astrisk in both direction hiding the logic from the actual clients (Send/Receive):

Local portModulePrefix (Send)Prefix-Removal (Response)
1080Module 1No PrefixNo change
1081Module 2*First asterisk removed
1082Module 3**First two asterisks removed
1083Module 4***First three asterisks removed

Configuration (Environment variables)

Settings are done purely in environment variables:

VariableDescriptionDefault
MAPLECUN_IPIP-address of MapleCUN hardware192.168.0.1
MAPLECUN_PORTNetwork-Port of MapleCUN hardware2323
DEBUGDebug logging of input/output as true or falsefalse
LOG_FORMATdateformat for logging (Java time format)yyyy-MM-dd HH:mm:ss
RECONNECT_TIMEOUTwhen connection to MapleCul is los reconnect in seconds5

Docker Compose Example

Create a docker-compose.yaml with the following defaults or use the one from the repo:


services:
  maplecun-splitproxy:
    image: boriswde/maplecun-splitproxy:latest
    container_name: maplecun-splitproxy
    restart: unless-stopped
    ports:
      - "1080:1080" # Module 1
      - "1081:1081" # Module 2
      - "1082:1082" # Module 3
      - "1083:1083" # Module 4
    environment:
      - MAPLECUN_IP=192.168.178.50
      - MAPLECUN_PORT=2323
      - DEBUG=true
      - TIMELOG_FORMAT=yyyy-MM-dd HH:mm:ss
      - RECONNECT_TIMEOUT=5

Usage

wmbusmeter

If you would like to use wmbusmeters Wireless M-Bus, please note that you need to use socat for a serial port. In case of a docker-compose.yaml, you can do something like this. This will fix the errournous initialization of wmbusmeters and also make sure that it is reset every 30 seconds.

services:
  wmbusmeters:
    container_name: wmbusmeters
    image: wmbusmeters/wmbusmeters
    stop_grace_period: 10m
    volumes:
      - /your_local_storage/wmbusmeters:/wmbusmeters_data
      - /etc/localtime:/etc/localtime:ro
    command: >
      sh -c "
      apk add --no-cache socat &&
      socat -d -d pty,raw,echo=0,link=/dev/ttyUSB-bridge,mode=777 TCP:hass_maplecun-splitproxy:1082,forever,interval=2,retry=30 &
      echo 'waiting for TCP CUL…' && 
      while [ ! -e /dev/ttyUSB-bridge ]; do sleep 0.2; done &&
      (
        while true; do
          sleep 30;
          echo 'X21' > /dev/ttyUSB-bridge;
          echo 'brt' > /dev/ttyUSB-bridge;
          sleep 3600;
        done
      ) &
      sh /wmbusmeters/docker-entrypoint.sh
      "

Homegear

In homematicbidcos.conf for module 1:

deviceAddress = IP_OF_MAPLECULPROXY:1080

Development & Build

Local compile

javac MapleCunSplitProxy.java

java MapleCunSplitProxy

Multi-Architecture Build

docker buildx build \
  --platform linux/amd64,linux/arm64,linux/arm/v7 \
  -t boriswde/maplecun-splitproxy:latest \
  --push .

Tag summary

Content type

Image

Digest

sha256:bd44332f8

Size

174.8 MB

Last updated

4 months ago

docker pull boriswde/maplecun-splitproxy