Skip to content

Commit

Permalink
updated loxone/README.md; disabled debug parsing output
Browse files Browse the repository at this point in the history
  • Loading branch information
raven-worx committed Jun 22, 2023
1 parent 6680ae0 commit 8b21a9e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ When built with `MBUSPICO_HTTP_ENABLED` option enabled the following HTTP endpoi
| **Method** | **Endpoint URL** | **Description** |
| --------------| --------------------- | ------------------ |
| GET | / | Return last read meter data in JSON format |
| GET | /update | Reboot device into USB bootloader for a quick and easy update of MBusPico application |
| GET | /reboot | Reboot device |
| GET | /update | Reboot device into USB bootloader for a quick and easy update of MBusPico application (*only available on Raspberry Pico*) |
| GET | /reboot | Reboot device (*only available on Raspberry Pico*) |

# Hardware wiring / assembly

Expand Down
44 changes: 41 additions & 3 deletions loxone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,51 @@ Visualization in Loxone App:

[<img src="app.png?raw=true" width="200"/>](app.png?raw=true)

## Loxberry
## Raspberry Pi / Loxberry

Since MBusPico v2.0 there is also a Python version available. Including a ready-made Python docker container running MBusPico.

This enables the usage of MBusPico application on your RaspberryPi already running [LoxBerry](https://github.com/mschlenstedt/Loxberry).

After installing the [Loxberry Docker Plugin](https://wiki.loxberry.de/plugins/docker/start) you can run the MBusPico docker container with the following settings:
## Enable serial port

On an generic Raspberry Pi (for example running Raspian) execute `sudo raspi-config` and enable the serial port in
`(3) Interface options` -> `(I6) Serial Port`. Just enable the serial port and do not enable the console on it.
Afterwards reboot the device.

On a Loxberry this can be done directly in the web UI. From `System settings` select `Loxberry services` and `More options`:

[TODO]
[<img src="loxberry_enable_serialport.png?raw=true" width="300"/>](loxberry_enable_serialport.png?raw=true)

Again reboot the device after saving the settings.

## Loxberry

Install the [Loxberry Docker Plugin](https://wiki.loxberry.de/plugins/docker/start). In the portainer web UI you can create
a MBusPico docker container from `Containers` and hit the `Add container` button.

Make sure that you set some mandatory options:

* the `Network mode` must be `host`
* the serial port `device` (in most cases `/dev/ttyS0`) must be mapped to the docker container
* MBusPico options (like at least the decryption key `MBUSPICO_DEVICE_KEY`) can be set via `environment variables`

## Running manually

Extract the `python.zip` archive of an MBusPico release and execute it directly with Python:
```sh
cd /path/to/extracted
python3 main.py
```

Example docker run call:
```sh
docker run --name MBusPico \
--network host \
--device=/dev/ttyS0 \
-e MBUSPICO_DEVICE_KEY=XXXXXXXXXXXXXXXXXXXX \
-e MBUSPICO_HTTP_SERVER_PORT=8080 \
-e MBUSPICO_HTTP_ENABLED=1 \
-e MBUSPICO_SERIAL_PORT=/dev/ttyS0 \
ravenworx/mbuspico:latest
```
Binary file modified loxone/loxberry_enable_serialport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions python/dist/mbus/devices/kaifa_ma309m_netznoe.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@ def parse_data(self,data):
currentPosition = _DECODER_START_OFFSET # Offset for start of OBIS decoding, skip header, timestamp and break block

while True:
print("currentPosition:", currentPosition)
print("OBIS header type:", plaintext[currentPosition + _OBIS_TYPE_OFFSET])
#print("currentPosition:", currentPosition)
#print("OBIS header type:", plaintext[currentPosition + _OBIS_TYPE_OFFSET])
if plaintext[currentPosition + _OBIS_TYPE_OFFSET] != _DataType_OctetString:
print("Unsupported OBIS header type")
return False

obisCodeLength = plaintext[currentPosition + _OBIS_LENGTH_OFFSET]
print("OBIS code/header length:", obisCodeLength)
#print("OBIS code/header length:", obisCodeLength)

if obisCodeLength != 0x06 and obisCodeLength != 0x0C:
print("Unsupported OBIS header length")
Expand All @@ -197,8 +197,8 @@ def parse_data(self,data):

codeType = _CodeType_Unknown

print("obisCode (OBIS_A):", obisCode[_OBIS_A])
print("currentPosition:", currentPosition)
#print("obisCode (OBIS_A):", obisCode[_OBIS_A])
#print("currentPosition:", currentPosition)

if obisCode[_OBIS_A] == _Medium_Electricity:
# Compare C and D against code
Expand Down Expand Up @@ -291,8 +291,8 @@ def parse_data(self,data):
elif codeType == _CodeType_PowerFactor:
meter.powerFactor = dataValue
elif dataType == _DataType_OctetString:
print("Arrived on OctetString")
print("currentPosition:", currentPosition, "plaintext:", plaintext[currentPosition])
#print("Arrived on OctetString")
#print("currentPosition:", currentPosition, "plaintext:", plaintext[currentPosition])

dataLength = plaintext[currentPosition]
currentPosition += 1 # Advance past string length
Expand Down

0 comments on commit 8b21a9e

Please sign in to comment.