Giter VIP home page Giter VIP logo

sml2mqtt's People

Contributors

spacemanspiff2007 avatar tobiaseckl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sml2mqtt's Issues

0100020800ff (1-0:2.8.0*255) not reported to MQTT Broker

My device reports (via -a option):

[2022-06-30 15:45:58,026] [sml.serial0            ] INFO     |     val_list:
[2022-06-30 15:45:58,026] [sml.serial0            ] INFO     |       <SmlListEntry>
[2022-06-30 15:45:58,027] [sml.serial0            ] INFO     |         obis           : 010060320101 (1-0:96.50.1*1)
[2022-06-30 15:45:58,027] [sml.serial0            ] INFO     |         status         : None
[2022-06-30 15:45:58,027] [sml.serial0            ] INFO     |         val_time       : None
[2022-06-30 15:45:58,028] [sml.serial0            ] INFO     |         unit           : None
[2022-06-30 15:45:58,028] [sml.serial0            ] INFO     |         scaler         : None
[2022-06-30 15:45:58,029] [sml.serial0            ] INFO     |         value          : ISK
[2022-06-30 15:45:58,029] [sml.serial0            ] INFO     |         value_signature: None
[2022-06-30 15:45:58,030] [sml.serial0            ] INFO     |       <SmlListEntry>
[2022-06-30 15:45:58,030] [sml.serial0            ] INFO     |         obis           : 0100600100ff (1-0:96.1.0*255)
[2022-06-30 15:45:58,030] [sml.serial0            ] INFO     |         status         : None
[2022-06-30 15:45:58,031] [sml.serial0            ] INFO     |         val_time       : None
[2022-06-30 15:45:58,031] [sml.serial0            ] INFO     |         unit           : None
[2022-06-30 15:45:58,031] [sml.serial0            ] INFO     |         scaler         : None
[2022-06-30 15:45:58,032] [sml.serial0            ] INFO     |         value          : 0a0149534b0005020de2
[2022-06-30 15:45:58,032] [sml.serial0            ] INFO     |         value_signature: None
[2022-06-30 15:45:58,032] [sml.serial0            ] INFO     |       <SmlListEntry>
[2022-06-30 15:45:58,033] [sml.serial0            ] INFO     |         obis           : 0100010800ff (1-0:1.8.0*255)
[2022-06-30 15:45:58,033] [sml.serial0            ] INFO     |         status         : 1835268
[2022-06-30 15:45:58,033] [sml.serial0            ] INFO     |         val_time       : None
[2022-06-30 15:45:58,033] [sml.serial0            ] INFO     |         unit           : 30
[2022-06-30 15:45:58,034] [sml.serial0            ] INFO     |         scaler         : -1
[2022-06-30 15:45:58,034] [sml.serial0            ] INFO     |         value          : 7335755
[2022-06-30 15:45:58,034] [sml.serial0            ] INFO     |         value_signature: None
[2022-06-30 15:45:58,035] [sml.serial0            ] INFO     |         -> 733575.5Wh (Zählerstand Total)
[2022-06-30 15:45:58,035] [sml.serial0            ] INFO     |       <SmlListEntry>
[2022-06-30 15:45:58,035] [sml.serial0            ] INFO     |         obis           : 0100020800ff (1-0:2.8.0*255)
[2022-06-30 15:45:58,036] [sml.serial0            ] INFO     |         status         : None
[2022-06-30 15:45:58,036] [sml.serial0            ] INFO     |         val_time       : None
[2022-06-30 15:45:58,036] [sml.serial0            ] INFO     |         unit           : 30
[2022-06-30 15:45:58,037] [sml.serial0            ] INFO     |         scaler         : -1
[2022-06-30 15:45:58,037] [sml.serial0            ] INFO     |         value          : 0
[2022-06-30 15:45:58,037] [sml.serial0            ] INFO     |         value_signature: None
[2022-06-30 15:45:58,037] [sml.serial0            ] INFO     |         -> 0.0Wh
[2022-06-30 15:45:58,038] [sml.serial0            ] INFO     |       <SmlListEntry>
[2022-06-30 15:45:58,038] [sml.serial0            ] INFO     |         obis           : 0100100700ff (1-0:16.7.0*255)
[2022-06-30 15:45:58,038] [sml.serial0            ] INFO     |         status         : None
[2022-06-30 15:45:58,039] [sml.serial0            ] INFO     |         val_time       : None
[2022-06-30 15:45:58,039] [sml.serial0            ] INFO     |         unit           : 27
[2022-06-30 15:45:58,039] [sml.serial0            ] INFO     |         scaler         : 0
[2022-06-30 15:45:58,039] [sml.serial0            ] INFO     |         value          : 433
[2022-06-30 15:45:58,040] [sml.serial0            ] INFO     |         value_signature: None
[2022-06-30 15:45:58,040] [sml.serial0            ] INFO     |         -> 433W (aktuelle Wirkleistung)

however, I never see: obis : 0100020800ff (1-0:2.8.0*255) being sent to mqtt

my config has defined the following under "devices":

devices:
  /dev/serial0:

    mqtt:
      topic: myTopic

    skip:
      - '010060320101'
      - '0100600100ff'

    values:

      0100100700ff:
        mqtt:
          topic: power
        filters:
          - diff: 500
          - every: 60

      0100010800ff:
        mqtt:
          topic: energy
        filters:
          - diff: 1
          - every: 300

      0100020800ff:
        mqtt:
          topic: outbound
        filters:
          - diff: 1
          - every: 300

Default behaviour for publishing over MQTT

Recently when expermimenting with the config, I had removed the diff filter accidentally and I had assumed that the every: 30 I had set would result in one packet every 30s delivered to MQTT. To my surprise, I got 1 packet per second! As it seems, without a diff filter, packets get emitted "on change". That means, even when the power reading, for instance, changes by 1 Watt, a packet goes out. Is that really a meaningful default behaviour? I am now back to setting: diff: 10000. All I want is a periodic sample rate, no exceptions, therefore the large value on diff now.

        # Filters control how often a value is published over mqtt.
        # If one filter is true the value will be published
        filters:
        - diff: 10      # report if value difference is >= 10
        - perc: 10      # report if percentage change is >= 10%
        - every: 120    # report at least every 120 secs (overrides the value from general)

Not able to get analysis of telegram

Hi spacemanspiff2007,
I'm not able to get an analysis of telegram but don't know whats wrong.

Receive following log:
[2023-01-28 10:53:01,675] [sml ] INFO | Starting V1.2.2
[2023-01-28 10:53:01,676] [asyncio ] DEBUG | Using selector: EpollSelector
[2023-01-28 10:53:01,677] [sml.mqtt ] DEBUG | Connecting to 192.168.0.1:1883
[2023-01-28 10:53:01,683] [sml.mqtt ] DEBUG | Success!
[2023-01-28 10:53:01,683] [sml.mqtt.pub ] INFO | sml2mqtt/status: ONLINE (QOS: 0, retain: False)
[2023-01-28 10:53:01,779] [sml.serial ] DEBUG | Port /dev/ttyUSB0 successfully opened
[2023-01-28 10:53:01,780] [sml.ttyUSB0.status ] INFO | PORT_OPENED
[2023-01-28 10:53:01,800] [sml.serial ] INFO | Port /dev/ttyUSB0 was closed
[2023-01-28 10:53:01,800] [sml.ttyUSB0.status ] INFO | PORT_CLOSED
[2023-01-28 10:53:01,801] [sml.mqtt.pub ] INFO | sml2mqtt//dev/ttyUSB0/status: PORT_CLOSED (QOS: 0, retain: False)
[2023-01-28 10:53:01,801] [sml ] INFO | Shutting down ...

When I make a cat on /dev/ttyUSB0 I see there are telegrams comming in.

Because I have an EasyMeter energy meter, I use following config-section for port:

ports:
- url: /dev/ttyUSB0   # Device path
  timeout: 30        # Seconds after which a timeout will be detected (default=3)
  baudrate: 9600
  parity: E
  stop bits: 1
  byte size: 7

Thanks for your effort,
Hardy

Only some OBIS Data Fields are available ISKRA MT175

Hello Team,

First of all many thanks for this great tool :)

running sml2mqtt -c path_to_my_config_file -a results in

| <SmlMessage>
|   transaction_id: 05b61be4
|   group_no      : 0
|   abort_on_error: 0
|   message_body <SmlOpenResponse>
|     codepage   : None
|     client_id  : None
|     req_file_id: 01e75ea2
|     server_id  : 090149534b0004812d55
|     ref_time   : None
|     sml_version: None
|   crc16         : 25225
| <SmlMessage>
|   transaction_id: 05b61be5
|   group_no      : 0
|   abort_on_error: 0
|   message_body <SmlGetListResponse>
|     client_id       : None
|     sever_id        : 090149534b0004812d55
|     list_name       : 0100620affff
|     act_sensor_time : 42350284
|     val_list:
|       <SmlListEntry>
|         obis           : 8181c78203ff (129-129:199.130.3*255)
|         status         : None
|         val_time       : None
|         unit           : None
|         scaler         : None
|         value          : ISK
|         value_signature: None
|         -> (Hersteller-Identifikation)
|       <SmlListEntry>
|         obis           : 0100000009ff (1-0:0.0.9*255)
|         status         : None
|         val_time       : None
|         unit           : None
|         scaler         : None
|         value          : 090149534b0004812d55
|         value_signature: None
|         -> (Geräteeinzelidentifikation)
|       <SmlListEntry>
|         obis           : 0100010800ff (1-0:1.8.0*255)
|         status         : 65920
|         val_time       : None
|         unit           : 30
|         scaler         : -1
|         value          : 56718296
|         value_signature: None
|         -> 5671829.6Wh (Zählerstand Total)
|       <SmlListEntry>
|         obis           : 0100010801ff (1-0:1.8.1*255)
|         status         : None
|         val_time       : None
|         unit           : 30
|         scaler         : -1
|         value          : 56718296
|         value_signature: None
|         -> 5671829.6Wh (Zählerstand Tarif 1)
|       <SmlListEntry>
|         obis           : 0100010802ff (1-0:1.8.2*255)
|         status         : None
|         val_time       : None
|         unit           : 30
|         scaler         : -1
|         value          : 0
|         value_signature: None
|         -> 0.0Wh (Zählerstand Tarif 2)
|       <SmlListEntry>
|         obis           : 0100020800ff (1-0:2.8.0*255)
|         status         : None
|         val_time       : None
|         unit           : 30
|         scaler         : -1
|         value          : 54219342
|         value_signature: None
|         -> 5421934.2Wh
|       <SmlListEntry>
|         obis           : 0100020801ff (1-0:2.8.1*255)
|         status         : None
|         val_time       : None
|         unit           : 30
|         scaler         : -1
|         value          : 54219342
|         value_signature: None
|         -> 5421934.2Wh
|       <SmlListEntry>
|         obis           : 0100020802ff (1-0:2.8.2*255)
|         status         : None
|         val_time       : None
|         unit           : 30
|         scaler         : -1
|         value          : 0
|         value_signature: None
|         -> 0.0Wh
|       <SmlListEntry>
|         obis           : 0100100700ff (1-0:16.7.0*255)
|         status         : None
|         val_time       : None
|         unit           : 27
|         scaler         : 0
|         value          : 23
|         value_signature: None
|         -> 23W (aktuelle Wirkleistung)
|       <SmlListEntry>
|         obis           : 8181c78205ff (129-129:199.130.5*255)
|         status         : None
|         val_time       : None
|         unit           : None
|         scaler         : None
|         value          : 55ee18e385e7aa763de1b81508f198e40e495f1ef707f779be518456b0f293674b06d0ea4060f11f2b6f6fb5d1c7ae62
|         value_signature: None
|         -> (Öffentlicher Schlüssel)
|     list_signature  : None
|     act_gateway_time: None
|   crc16         : 53301
| <SmlMessage>
|   transaction_id: 05b61be6
|   group_no      : 0
|   abort_on_error: 0
|   message_body <SmlCloseResponse>
|     global_signature: None
|   crc16         : 19825
|

cut something out in between here !


| sml2mqtt/ISKRA MT175 Main/0100010800ff (0100010800ff):
|   raw value: 5671.8296
|   pub value: 5671.8296
|   filters:
|     - <Every: 120>
|     - <OnChange>
| sml2mqtt/ISKRA MT175 Main/0100020800ff (0100020800ff):
|   raw value: 5421.9342
|   pub value: 5421.9342
|     - <Every: 120>
|     - <OnChange>
| sml2mqtt/ISKRA MT175 Main/0100100700ff (0100100700ff):
|   raw value: 23
|   pub value: 23
|     - <Every: 120>
|     - <OnChange>

We found 3 issues for this specific SMA meter

  1. the obis field name contains spaces i.e
    obis : 8181c78205ff (129-129:199.130.5*255)

acces to these datafields seems only be possible via config.yml file is we use the first part
before the 'space'

  1. there are only mqtt-events generated for the following fields
    sml2mqtt/ISKRA MT175 Main/0100010800ff (0100010800ff):
    sml2mqtt/ISKRA MT175 Main/0100020800ff (0100020800ff):
    sml2mqtt/ISKRA MT175 Main/0100100700ff (0100100700ff):

We have NO filters inside our config file
Is there a "hidden filter" somewhere else ?

We are interested in some more information, it looks like they are available but not accessable

  1. installation on latest raspiban 64bit bullseye required some extra installation of python libraries
python3 -m pip install --upgrade pip sml2mqtt
python3 -m pip install typing-extensions --upgrade
python3 -m pip install ruamel_yaml
python3 -m pip install smllib
python3 -m pip install asyncio_mqtt
python3 -m pip install pyserial_asyncio

br hp

Various problems, as with issue #11

I recently installed the SmartMeter to MQTT bridge "sml2mqtt".
The Python application is running on a RPI3-B (OS Buster) on which I previously installed Python V3.8.
As can be seen in the message log, the SML messages of the EasyMeter Q3A are read, recognized and displayed correctly.

Really good programming and implementation of the MQTT bridge. Many thanks to this site.

Note: Meter number, DeviceId, user and password have been anonymized!

Now to the problems:

  1. Mapping OBIS to plaintext does not work for me (see issue #11). The OBIS device identification (0100000009ff) is delivered by the ESY Q3A. It is inserted as first topic after "LeupoldsPub/Stromzähler" in the tree. I don't want to see it at all (but skip doesn't work or I do something wrong). It is a combination of ServerId and serial number of the meter. I have made the appropriate corrections from issue #11, without success. It would be nice if I could see the tree structure in the MQTT broker in plain text and not as HEX string (see tree structure and datapoints).

Extension:
Is it possible to send the timestamp (per SML file) as a data point to the MQTT broker. The timestamps of the Datapoints themselves are registered in the Broker.
If that's too much effort, I'm fine with that.

Tree structure and data points:

LeupoldPuB
    Stromzähler
        Zählernummer     0ESY0123456789
        Geräte-ID        01234553590a30b1338c    
        Verbrauch kWh    6274.4246279
        Wirkleistung Wh  2431.7
        Wirklst. L1  Wh  2195.52
        Wirklst. L2  Wh  91.42
        Wirklst. L3  Wh  144.75
        Spannung U-L1 V  229.8
        Spannung U L2 V  231.2
        Spannung U L3 V  231.4
        status           OK
    Zeitstempel 2023-01-04 12:59:50,483
    status      ONLINE|OFFLINE
  1. The adjustments of the time intervals, when data should be sent again, are not considered.
    Data is always sent to the MQTT broker every one second.

  2. The login to the productive MQTT broker fails (see MQTT log).
    It works on the test server because no ClientID is required there.

I can't solve the problem on my own and would like to ask for support.
Thanks in advance.

`
Problem 1 documemtation:

Run with parameter -a
(venv) pi@:/opt/sml2mqtt/venv $
sml2mqtt -c /opt/sml2mqtt/config.yml -a

logging:
  level: INFO
  file: sml2mqtt.log

mqtt:
  connection:
    client id: sml2mqtt
    host: 'MyIpAdress'
    port: '1883'
    user: 'xxxxxxxxxx'
    password: '*****************'
    tls: False
    tls insecure: False

  defaults:
    qos: 0
    retain: False
    
  topic prefix: LeupoldsPub/Stromzähler

  last will:
    topic: status
    retain: False

general:
  Wh in kWh: true
  republish after: 120

ports:
 - url: /dev/ttyUSB0
   timeout: 3

devices:

 /dev/ttyUSB0:

    values:
      0100000000ff:
        mqtt:
          topic: Zählernummer
          retain: True

      0100000009ff:
        mqtt:
          topic: Geräte-ID
          retain: True

      0100010800ff:
        mqtt:
          topic: 'Verbrauch kWh'
        filters:
          - every: 3600
        workarounds:
          - negative on energy meter status: False

      0100100700ff:
        mqtt:
          topic: 'Wirkleistung  Wh'
        filters:
          - every: 10

      0100240700ff:
        mqtt:
          topic: 'Wirklst. L1   Wh'
        filters:
          - every: 10

      0100380700ff:
        mqtt:
          topic: 'Wirklst. L2   Wh'
        filters:
          - every: 10

      01004c0700ff:
        mqtt:
          topic: 'Wirklst. L3   Wh'
        filters:
          - every: 10

      0100200700ff:
        mqtt:
          topic: 'Spannung U-L1 V'
        filters:
          - every: 60

      0100340700ff:
        mqtt:
          topic: 'Spannung U-L2 V'
        filters:
          - every: 60

      0100480700ff:
        mqtt:
          topic: 'Spannung U-L3 V'
        filters:
          - every: 60

---------- config end -------------

`

`
#--------- MQTT mosquitto log --------begin----
Logon ok with clientId, Username / Password .... Exsample
2023-01-04T00:46:05: New client connected from :65144 as (p2, c1, k727, u'xxxxxxxxxx').

Logon from sml2mqtt without ClientId faild
2023-01-04T00:57:36: New connection from 192.:33087 on port 1883.
2023-01-04T00:57:36: Client disconnected due to protocol error.
#--------- MQTT mosquitto log -------- end ----

(venv) pi@leuvorpi3-01:/opt/sml2mqtt/venv $ sml2mqtt -c /opt/sml2mqtt/config.yml -a

[2023-01-04 12:59:48,695] [sml                    ] INFO     | Starting V1.2.2
[2023-01-04 12:59:48,717] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/status: ONLINE (QOS: 0, retain: False)
[2023-01-04 12:59:48,803] [sml.ttyUSB0.status     ] INFO     | PORT_OPENED
[2023-01-04 12:59:50,471] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,472] [sml.ttyUSB0            ] INFO     | Received Frame
[2023-01-04 12:59:50,473] [sml.ttyUSB0            ] INFO     |  -> b'760b45535941b78a08c7016362006 [===>Output shortened<===]'
[2023-01-04 12:59:50,474] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,483] [sml.ttyUSB0            ] INFO     | <SmlMessage>
[2023-01-04 12:59:50,484] [sml.ttyUSB0            ] INFO     |   transaction_id: 45535941b78a08c70163
[2023-01-04 12:59:50,485] [sml.ttyUSB0            ] INFO     |   group_no      : 0
[2023-01-04 12:59:50,485] [sml.ttyUSB0            ] INFO     |   abort_on_error: 0
[2023-01-04 12:59:50,486] [sml.ttyUSB0            ] INFO     |   message_body <SmlOpenResponse>
[2023-01-04 12:59:50,487] [sml.ttyUSB0            ] INFO     |     codepage   : None
[2023-01-04 12:59:50,488] [sml.ttyUSB0            ] INFO     |     client_id  : 455359
[2023-01-04 12:59:50,488] [sml.ttyUSB0            ] INFO     |     req_file_id: 455359007b0163
[2023-01-04 12:59:50,489] [sml.ttyUSB0            ] INFO     |     server_id  : 01234553590a30b1338c
[2023-01-04 12:59:50,490] [sml.ttyUSB0            ] INFO     |     ref_time   : None
[2023-01-04 12:59:50,491] [sml.ttyUSB0            ] INFO     |     sml_version: None
[2023-01-04 12:59:50,491] [sml.ttyUSB0            ] INFO     |   crc16         : 52297
[2023-01-04 12:59:50,496] [sml.ttyUSB0            ] INFO     | <SmlMessage>
[2023-01-04 12:59:50,496] [sml.ttyUSB0            ] INFO     |   transaction_id: 45535941b78a08c70164
[2023-01-04 12:59:50,497] [sml.ttyUSB0            ] INFO     |   group_no      : 0
[2023-01-04 12:59:50,498] [sml.ttyUSB0            ] INFO     |   abort_on_error: 0
[2023-01-04 12:59:50,499] [sml.ttyUSB0            ] INFO     |   message_body <SmlGetListResponse>
[2023-01-04 12:59:50,499] [sml.ttyUSB0            ] INFO     |     client_id       : None
[2023-01-04 12:59:50,500] [sml.ttyUSB0            ] INFO     |     server_id       : 01234553590a30b1338c
[2023-01-04 12:59:50,501] [sml.ttyUSB0            ] INFO     |     list_name       : 0100620affff
[2023-01-04 12:59:50,502] [sml.ttyUSB0            ] INFO     |     act_sensor_time : 49086587
[2023-01-04 12:59:50,502] [sml.ttyUSB0            ] INFO     |     val_list:
[2023-01-04 12:59:50,503] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,504] [sml.ttyUSB0            ] INFO     |         obis           : 8181c78203ff (129-129:199.130.3*255)
[2023-01-04 12:59:50,505] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,505] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,506] [sml.ttyUSB0            ] INFO     |         unit           : None
[2023-01-04 12:59:50,507] [sml.ttyUSB0            ] INFO     |         scaler         : None
[2023-01-04 12:59:50,507] [sml.ttyUSB0            ] INFO     |         value          : ESY
[2023-01-04 12:59:50,508] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,509] [sml.ttyUSB0            ] INFO     |         -> (Hersteller-Identifikation)
[2023-01-04 12:59:50,510] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,510] [sml.ttyUSB0            ] INFO     |         obis           : 0100000009ff (1-0:0.0.9*255)
[2023-01-04 12:59:50,511] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,512] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,512] [sml.ttyUSB0            ] INFO     |         unit           : None
[2023-01-04 12:59:50,513] [sml.ttyUSB0            ] INFO     |         scaler         : None
[2023-01-04 12:59:50,514] [sml.ttyUSB0            ] INFO     |         value          : 01234553590a30b1338c
[2023-01-04 12:59:50,514] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,515] [sml.ttyUSB0            ] INFO     |         -> (Geräteeinzelidentifikation)
[2023-01-04 12:59:50,516] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,517] [sml.ttyUSB0            ] INFO     |         obis           : 0100010800ff (1-0:1.8.0*255)
[2023-01-04 12:59:50,517] [sml.ttyUSB0            ] INFO     |         status         : 128
[2023-01-04 12:59:50,518] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,519] [sml.ttyUSB0            ] INFO     |         unit           : 30
[2023-01-04 12:59:50,520] [sml.ttyUSB0            ] INFO     |         scaler         : -4
[2023-01-04 12:59:50,520] [sml.ttyUSB0            ] INFO     |         value          : 62744246279
[2023-01-04 12:59:50,521] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,522] [sml.ttyUSB0            ] INFO     |         -> 6274424.6279Wh (Zählerstand Total)
[2023-01-04 12:59:50,522] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,523] [sml.ttyUSB0            ] INFO     |         obis           : 0100100700ff (1-0:16.7.0*255)
[2023-01-04 12:59:50,524] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,525] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,525] [sml.ttyUSB0            ] INFO     |         unit           : 27
[2023-01-04 12:59:50,526] [sml.ttyUSB0            ] INFO     |         scaler         : -2
[2023-01-04 12:59:50,527] [sml.ttyUSB0            ] INFO     |         value          : 243170
[2023-01-04 12:59:50,527] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,528] [sml.ttyUSB0            ] INFO     |         -> 2431.7W (aktuelle Wirkleistung)
[2023-01-04 12:59:50,529] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,529] [sml.ttyUSB0            ] INFO     |         obis           : 0100240700ff (1-0:36.7.0*255)
[2023-01-04 12:59:50,530] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,531] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,532] [sml.ttyUSB0            ] INFO     |         unit           : 27
[2023-01-04 12:59:50,532] [sml.ttyUSB0            ] INFO     |         scaler         : -2
[2023-01-04 12:59:50,533] [sml.ttyUSB0            ] INFO     |         value          : 219552
[2023-01-04 12:59:50,534] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,534] [sml.ttyUSB0            ] INFO     |         -> 2195.52W (Wirkleistung L1)
[2023-01-04 12:59:50,535] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,536] [sml.ttyUSB0            ] INFO     |         obis           : 0100380700ff (1-0:56.7.0*255)
[2023-01-04 12:59:50,536] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,537] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,538] [sml.ttyUSB0            ] INFO     |         unit           : 27
[2023-01-04 12:59:50,539] [sml.ttyUSB0            ] INFO     |         scaler         : -2
[2023-01-04 12:59:50,539] [sml.ttyUSB0            ] INFO     |         value          : 9142
[2023-01-04 12:59:50,540] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,541] [sml.ttyUSB0            ] INFO     |         -> 91.42W (Wirkleistung L2)
[2023-01-04 12:59:50,542] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,542] [sml.ttyUSB0            ] INFO     |         obis           : 01004c0700ff (1-0:76.7.0*255)
[2023-01-04 12:59:50,543] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,544] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,544] [sml.ttyUSB0            ] INFO     |         unit           : 27
[2023-01-04 12:59:50,545] [sml.ttyUSB0            ] INFO     |         scaler         : -2
[2023-01-04 12:59:50,546] [sml.ttyUSB0            ] INFO     |         value          : 14475
[2023-01-04 12:59:50,546] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,547] [sml.ttyUSB0            ] INFO     |         -> 144.75W (Wirkleistung L3)
[2023-01-04 12:59:50,548] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,549] [sml.ttyUSB0            ] INFO     |         obis           : 8181c78205ff (129-129:199.130.5*255)
[2023-01-04 12:59:50,549] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,550] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,551] [sml.ttyUSB0            ] INFO     |         unit           : None
[2023-01-04 12:59:50,551] [sml.ttyUSB0            ] INFO     |         scaler         : None
[2023-01-04 12:59:50,552] [sml.ttyUSB0            ] INFO     |         value          : 0c8928e080527854cbd5204ec9baaa3decc9ef4d1e075fb2ddfe143e11c650c2e8dc1370c12bb6d2a51051bf973a0519
[2023-01-04 12:59:50,553] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,554] [sml.ttyUSB0            ] INFO     |         -> (Öffentlicher Schlüssel)
[2023-01-04 12:59:50,554] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,555] [sml.ttyUSB0            ] INFO     |         obis           : 0100000000ff (1-0:0.0.0*255)
[2023-01-04 12:59:50,556] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,556] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,557] [sml.ttyUSB0            ] INFO     |         unit           : None
[2023-01-04 12:59:50,558] [sml.ttyUSB0            ] INFO     |         scaler         : None
[2023-01-04 12:59:50,559] [sml.ttyUSB0            ] INFO     |         value          : 0ESY0123456789
[2023-01-04 12:59:50,560] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,560] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,561] [sml.ttyUSB0            ] INFO     |         obis           : 0100200700ff (1-0:32.7.0*255)
[2023-01-04 12:59:50,562] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,563] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,563] [sml.ttyUSB0            ] INFO     |         unit           : 35
[2023-01-04 12:59:50,564] [sml.ttyUSB0            ] INFO     |         scaler         : -1
[2023-01-04 12:59:50,565] [sml.ttyUSB0            ] INFO     |         value          : 2298
[2023-01-04 12:59:50,566] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,567] [sml.ttyUSB0            ] INFO     |         -> 229.8V (Spannung L1)
[2023-01-04 12:59:50,568] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,568] [sml.ttyUSB0            ] INFO     |         obis           : 0100340700ff (1-0:52.7.0*255)
[2023-01-04 12:59:50,569] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,570] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,570] [sml.ttyUSB0            ] INFO     |         unit           : 35
[2023-01-04 12:59:50,570] [sml.ttyUSB0            ] INFO     |         scaler         : -1
[2023-01-04 12:59:50,571] [sml.ttyUSB0            ] INFO     |         value          : 2312
[2023-01-04 12:59:50,571] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,572] [sml.ttyUSB0            ] INFO     |         -> 231.2V (Spannung L2)
[2023-01-04 12:59:50,572] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,573] [sml.ttyUSB0            ] INFO     |         obis           : 0100480700ff (1-0:72.7.0*255)
[2023-01-04 12:59:50,573] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,574] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,574] [sml.ttyUSB0            ] INFO     |         unit           : 35
[2023-01-04 12:59:50,574] [sml.ttyUSB0            ] INFO     |         scaler         : -1
[2023-01-04 12:59:50,575] [sml.ttyUSB0            ] INFO     |         value          : 2314
[2023-01-04 12:59:50,575] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,576] [sml.ttyUSB0            ] INFO     |         -> 231.4V (Spannung L3)
[2023-01-04 12:59:50,576] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-01-04 12:59:50,577] [sml.ttyUSB0            ] INFO     |         obis           : 8181c7f006ff (129-129:199.240.6*255)
[2023-01-04 12:59:50,577] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-01-04 12:59:50,578] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-01-04 12:59:50,578] [sml.ttyUSB0            ] INFO     |         unit           : None
[2023-01-04 12:59:50,579] [sml.ttyUSB0            ] INFO     |         scaler         : None
[2023-01-04 12:59:50,579] [sml.ttyUSB0            ] INFO     |         value          : 01073e
[2023-01-04 12:59:50,579] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-01-04 12:59:50,580] [sml.ttyUSB0            ] INFO     |     list_signature  : None
[2023-01-04 12:59:50,580] [sml.ttyUSB0            ] INFO     |     act_gateway_time: None
[2023-01-04 12:59:50,581] [sml.ttyUSB0            ] INFO     |   crc16         : 64804
[2023-01-04 12:59:50,581] [sml.ttyUSB0            ] INFO     | <SmlMessage>
[2023-01-04 12:59:50,582] [sml.ttyUSB0            ] INFO     |   transaction_id: 45535941b78a08c70165
[2023-01-04 12:59:50,582] [sml.ttyUSB0            ] INFO     |   group_no      : 0
[2023-01-04 12:59:50,582] [sml.ttyUSB0            ] INFO     |   abort_on_error: 0
[2023-01-04 12:59:50,583] [sml.ttyUSB0            ] INFO     |   message_body <SmlCloseResponse>
[2023-01-04 12:59:50,583] [sml.ttyUSB0            ] INFO     |     global_signature: None
[2023-01-04 12:59:50,584] [sml.ttyUSB0            ] INFO     |   crc16         : 31902
[2023-01-04 12:59:50,584] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,587] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100010800ff
[2023-01-04 12:59:50,588] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100010800ff: 6274.4246279 (QOS: 0, retain: False)
[2023-01-04 12:59:50,589] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100100700ff
[2023-01-04 12:59:50,590] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100100700ff: 2431.7 (QOS: 0, retain: False)
[2023-01-04 12:59:50,590] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100240700ff
[2023-01-04 12:59:50,591] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100240700ff: 2195.52 (QOS: 0, retain: False)
[2023-01-04 12:59:50,591] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100380700ff
[2023-01-04 12:59:50,592] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100380700ff: 91.42 (QOS: 0, retain: False)
[2023-01-04 12:59:50,593] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/01004c0700ff
[2023-01-04 12:59:50,593] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/01004c0700ff: 144.75 (QOS: 0, retain: False)
[2023-01-04 12:59:50,594] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100000000ff
[2023-01-04 12:59:50,595] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100000000ff: 0ESY0123456789 (QOS: 0, retain: False)
[2023-01-04 12:59:50,595] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100200700ff
[2023-01-04 12:59:50,596] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100200700ff: 229.8 (QOS: 0, retain: False)
[2023-01-04 12:59:50,597] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100340700ff
[2023-01-04 12:59:50,597] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100340700ff: 231.2 (QOS: 0, retain: False)
[2023-01-04 12:59:50,598] [sml.values             ] INFO     | Creating default value handler for 01234553590a30b1338c/0100480700ff
[2023-01-04 12:59:50,599] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100480700ff: 231.4 (QOS: 0, retain: False)
[2023-01-04 12:59:50,599] [sml.ttyUSB0.status     ] INFO     | OK
[2023-01-04 12:59:50,600] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/status: OK (QOS: 0, retain: False)
[2023-01-04 12:59:50,600] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,601] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100010800ff (0100010800ff):
[2023-01-04 12:59:50,601] [sml.ttyUSB0            ] INFO     |   raw value: 6274.4246279
[2023-01-04 12:59:50,602] [sml.ttyUSB0            ] INFO     |   pub value: 6274.4246279
[2023-01-04 12:59:50,602] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,603] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,603] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,604] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,604] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100100700ff (0100100700ff):
[2023-01-04 12:59:50,605] [sml.ttyUSB0            ] INFO     |   raw value: 2431.7
[2023-01-04 12:59:50,605] [sml.ttyUSB0            ] INFO     |   pub value: 2431.7
[2023-01-04 12:59:50,606] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,606] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,606] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,607] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,607] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100240700ff (0100240700ff):
[2023-01-04 12:59:50,608] [sml.ttyUSB0            ] INFO     |   raw value: 2195.52
[2023-01-04 12:59:50,608] [sml.ttyUSB0            ] INFO     |   pub value: 2195.52
[2023-01-04 12:59:50,609] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,609] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,610] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,610] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,611] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100380700ff (0100380700ff):
[2023-01-04 12:59:50,611] [sml.ttyUSB0            ] INFO     |   raw value: 91.42
[2023-01-04 12:59:50,612] [sml.ttyUSB0            ] INFO     |   pub value: 91.42
[2023-01-04 12:59:50,612] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,613] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,613] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,613] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,614] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/01004c0700ff (01004c0700ff):
[2023-01-04 12:59:50,614] [sml.ttyUSB0            ] INFO     |   raw value: 144.75
[2023-01-04 12:59:50,615] [sml.ttyUSB0            ] INFO     |   pub value: 144.75
[2023-01-04 12:59:50,615] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,616] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,616] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,617] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,617] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100000000ff (0100000000ff):
[2023-01-04 12:59:50,618] [sml.ttyUSB0            ] INFO     |   raw value: 0ESY0123456789
[2023-01-04 12:59:50,618] [sml.ttyUSB0            ] INFO     |   pub value: 0ESY0123456789
[2023-01-04 12:59:50,619] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,619] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,620] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,620] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,621] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100200700ff (0100200700ff):
[2023-01-04 12:59:50,621] [sml.ttyUSB0            ] INFO     |   raw value: 229.8
[2023-01-04 12:59:50,621] [sml.ttyUSB0            ] INFO     |   pub value: 229.8
[2023-01-04 12:59:50,622] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,622] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,623] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,623] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,624] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100340700ff (0100340700ff):
[2023-01-04 12:59:50,624] [sml.ttyUSB0            ] INFO     |   raw value: 231.2
[2023-01-04 12:59:50,625] [sml.ttyUSB0            ] INFO     |   pub value: 231.2
[2023-01-04 12:59:50,625] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,626] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,626] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,626] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,627] [sml.ttyUSB0            ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/0100480700ff (0100480700ff):
[2023-01-04 12:59:50,627] [sml.ttyUSB0            ] INFO     |   raw value: 231.4
[2023-01-04 12:59:50,628] [sml.ttyUSB0            ] INFO     |   pub value: 231.4
[2023-01-04 12:59:50,628] [sml.ttyUSB0            ] INFO     |   filters:
[2023-01-04 12:59:50,629] [sml.ttyUSB0            ] INFO     |     - <Every: 120>
[2023-01-04 12:59:50,629] [sml.ttyUSB0            ] INFO     |     - <OnChange>
[2023-01-04 12:59:50,630] [sml.ttyUSB0            ] INFO     | 
[2023-01-04 12:59:50,630] [sml.ttyUSB0.status     ] INFO     | SHUTDOWN
[2023-01-04 12:59:50,631] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/status: SHUTDOWN (QOS: 0, retain: False)
[2023-01-04 12:59:50,632] [sml.serial             ] INFO     | Port /dev/ttyUSB0 was closed
[2023-01-04 12:59:50,633] [sml.ttyUSB0.status     ] INFO     | PORT_CLOSED
[2023-01-04 12:59:50,633] [sml.mqtt.pub           ] INFO     | LeupoldsPub/Stromzähler/01234553590a30b1338c/status: PORT_CLOSED (QOS: 0, retain: False)
Shutting down ...
[2023-01-04 12:59:50,635] [sml                    ] INFO     | Shutting down ...

(venv) pi@leuvorpi3-01:/opt/sml2mqtt/venv $
`

config get only partly recognized

Hello and thank you for the project, everything works almost as expected but stable :)
My problem is, that the configuration file i am providing only gets party recognized.
Sorry i cant figure out how to create nice code view block....

I am observing the strange behavior that the config gets syntactically accepted, my mqtt main prefix is also working but the SmlListEntry's hex ID get the COM port prefixed instead of my configured subtopic

here is my configuration

logging:
  level: INFO         # Log level
  file: sml2mqtt.log  # Log file path (absolute or relative to config file)
mqtt:
  connection:
    client id: sml2mqtt
    host: mymqtthost
    port: myport
    user: 'myuser'
    password: 'mypass'
    tls: false
    tls insecure: false
  topic prefix: /max
  defaults:
    qos: 0         # Default value for QOS if no other QOS value in the config entry is set
    retain: false  # Default value for retain if no other retain value in the config entry is set
  last will:
    topic: status
general:
  Wh in kWh: true       # Automatically convert Wh to kWh
  republish after: 120  # Republish automatically after this time (if no other filter configured)
ports:
- url: /dev/ttyUSB0   # Device path
  timeout: 3        # Seconds after which a timeout will be detected (default=3)
devices:   # Device configuration by ID or url
  0a0149545200034bfc38:
    mqtt:
      topic: strom
    skip:    # OBIS codes (HEX) of values that will not be published (optional)
    - 0100600100ff
    values:  # Special configurations for each of the values (optional)
      0100100700ff:
        mqtt:             # Mqtt config for this entry (optional)
         topic: 0100100700ff
        filters:          # Refresh options for the value (optional)
        - perc: 15
      0100010800ff:
        mqtt:
         topic: 0100010800ff
        filters:
        - every: 120

and here is part of the output of the analysis run

[2023-02-05 14:12:23,195] [sml.ttyUSB0            ] INFO     | <SmlMessage>
[2023-02-05 14:12:23,195] [sml.ttyUSB0            ] INFO     |   transaction_id: 1c4d6303002bd02f
[2023-02-05 14:12:23,196] [sml.ttyUSB0            ] INFO     |   group_no      : 0
[2023-02-05 14:12:23,196] [sml.ttyUSB0            ] INFO     |   abort_on_error: 0
[2023-02-05 14:12:23,196] [sml.ttyUSB0            ] INFO     |   message_body <SmlOpenResponse>
[2023-02-05 14:12:23,196] [sml.ttyUSB0            ] INFO     |     codepage   : None
[2023-02-05 14:12:23,197] [sml.ttyUSB0            ] INFO     |     client_id  : None
[2023-02-05 14:12:23,197] [sml.ttyUSB0            ] INFO     |     req_file_id: 000000000371e7d6
[2023-02-05 14:12:23,197] [sml.ttyUSB0            ] INFO     |     server_id  : 0a0149545200034bfc38
[2023-02-05 14:12:23,197] [sml.ttyUSB0            ] INFO     |     ref_time   : 57796578
[2023-02-05 14:12:23,198] [sml.ttyUSB0            ] INFO     |     sml_version: None
[2023-02-05 14:12:23,198] [sml.ttyUSB0            ] INFO     |   crc16         : 55028
[2023-02-05 14:12:23,198] [sml.ttyUSB0            ] INFO     | <SmlMessage>
[2023-02-05 14:12:23,199] [sml.ttyUSB0            ] INFO     |   transaction_id: 1c4d6303002bd030
[2023-02-05 14:12:23,199] [sml.ttyUSB0            ] INFO     |   group_no      : 0
[2023-02-05 14:12:23,199] [sml.ttyUSB0            ] INFO     |   abort_on_error: 0
[2023-02-05 14:12:23,199] [sml.ttyUSB0            ] INFO     |   message_body <SmlGetListResponse>
[2023-02-05 14:12:23,200] [sml.ttyUSB0            ] INFO     |     client_id       : None
[2023-02-05 14:12:23,200] [sml.ttyUSB0            ] INFO     |     server_id       : 0a0149545200034bfc38
[2023-02-05 14:12:23,200] [sml.ttyUSB0            ] INFO     |     list_name       : 0100620affff
[2023-02-05 14:12:23,200] [sml.ttyUSB0            ] INFO     |     act_sensor_time : 57796578
[2023-02-05 14:12:23,201] [sml.ttyUSB0            ] INFO     |     val_list:
[2023-02-05 14:12:23,201] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-02-05 14:12:23,201] [sml.ttyUSB0            ] INFO     |         obis           : 010060320101 (1-0:96.50.1*1)
[2023-02-05 14:12:23,201] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-02-05 14:12:23,201] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-02-05 14:12:23,202] [sml.ttyUSB0            ] INFO     |         unit           : None
[2023-02-05 14:12:23,202] [sml.ttyUSB0            ] INFO     |         scaler         : None
[2023-02-05 14:12:23,202] [sml.ttyUSB0            ] INFO     |         value          : ITR
[2023-02-05 14:12:23,202] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-02-05 14:12:23,203] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-02-05 14:12:23,203] [sml.ttyUSB0            ] INFO     |         obis           : 0100600100ff (1-0:96.1.0*255)
[2023-02-05 14:12:23,203] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-02-05 14:12:23,203] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-02-05 14:12:23,203] [sml.ttyUSB0            ] INFO     |         unit           : None
[2023-02-05 14:12:23,204] [sml.ttyUSB0            ] INFO     |         scaler         : None
[2023-02-05 14:12:23,204] [sml.ttyUSB0            ] INFO     |         value          : 0a0149545200034bfc38
[2023-02-05 14:12:23,204] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-02-05 14:12:23,204] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-02-05 14:12:23,205] [sml.ttyUSB0            ] INFO     |         obis           : 0100010800ff (1-0:1.8.0*255)
[2023-02-05 14:12:23,205] [sml.ttyUSB0            ] INFO     |         status         : 1835268
[2023-02-05 14:12:23,205] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-02-05 14:12:23,205] [sml.ttyUSB0            ] INFO     |         unit           : 30
[2023-02-05 14:12:23,206] [sml.ttyUSB0            ] INFO     |         scaler         : -1
[2023-02-05 14:12:23,206] [sml.ttyUSB0            ] INFO     |         value          : 32410582
[2023-02-05 14:12:23,206] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-02-05 14:12:23,206] [sml.ttyUSB0            ] INFO     |         -> 3241058.2Wh (Zählerstand Total)
[2023-02-05 14:12:23,206] [sml.ttyUSB0            ] INFO     |       <SmlListEntry>
[2023-02-05 14:12:23,207] [sml.ttyUSB0            ] INFO     |         obis           : 0100100700ff (1-0:16.7.0*255)
[2023-02-05 14:12:23,207] [sml.ttyUSB0            ] INFO     |         status         : None
[2023-02-05 14:12:23,207] [sml.ttyUSB0            ] INFO     |         val_time       : None
[2023-02-05 14:12:23,207] [sml.ttyUSB0            ] INFO     |         unit           : 27
[2023-02-05 14:12:23,208] [sml.ttyUSB0            ] INFO     |         scaler         : 0
[2023-02-05 14:12:23,208] [sml.ttyUSB0            ] INFO     |         value          : 278
[2023-02-05 14:12:23,208] [sml.ttyUSB0            ] INFO     |         value_signature: None
[2023-02-05 14:12:23,208] [sml.ttyUSB0            ] INFO     |         -> 278W (aktuelle Wirkleistung)
[2023-02-05 14:12:23,208] [sml.ttyUSB0            ] INFO     |     list_signature  : None
[2023-02-05 14:12:23,209] [sml.ttyUSB0            ] INFO     |     act_gateway_time: None
[2023-02-05 14:12:23,209] [sml.ttyUSB0            ] INFO     |   crc16         : 19136
[2023-02-05 14:12:23,209] [sml.ttyUSB0            ] INFO     | <SmlMessage>

did I make a mistake in the configuraton? i would expect my mqtt topic to be /max/strom/0100100700ff and so on without the COM port

Thank you

Support logging to stdout (to use journalctl for viewing logs)

Could you add support for logging to stdout?

I would prefer to see the logs with journalctl -fu sml2mqtt rather than in a separate log file.

I tried this:

logging:
  level: INFO
  file: /dev/stdout

This works when running the script manually, but not in the systemd context:

Sep 01 22:13:44 stromableser systemd[1]: Started sml2mqtt.
Sep 01 22:13:45 stromableser sml2mqtt[3187]: Traceback (most recent call last):
Sep 01 22:13:45 stromableser sml2mqtt[3187]:   File "/usr/local/lib/python3.9/dist-packages/sml2mqtt/__main__.py", line 57, in main
Sep 01 22:13:45 stromableser sml2mqtt[3187]:     setup_log()
Sep 01 22:13:45 stromableser sml2mqtt[3187]:   File "/usr/local/lib/python3.9/dist-packages/sml2mqtt/__log__.py", line 46, in setup_log
Sep 01 22:13:45 stromableser sml2mqtt[3187]:     handler = MidnightRotatingFileHandler(
Sep 01 22:13:45 stromableser sml2mqtt[3187]:   File "/usr/local/lib/python3.9/dist-packages/sml2mqtt/__log__.py", line 20, in __init__
Sep 01 22:13:45 stromableser sml2mqtt[3187]:     super().__init__(*args, **kwargs)
Sep 01 22:13:45 stromableser sml2mqtt[3187]:   File "/usr/lib/python3.9/logging/handlers.py", line 153, in __init__
Sep 01 22:13:45 stromableser sml2mqtt[3187]:     BaseRotatingHandler.__init__(self, filename, mode, encoding=encoding,
Sep 01 22:13:45 stromableser sml2mqtt[3187]:   File "/usr/lib/python3.9/logging/handlers.py", line 58, in __init__
Sep 01 22:13:45 stromableser sml2mqtt[3187]:     logging.FileHandler.__init__(self, filename, mode=mode,
Sep 01 22:13:45 stromableser sml2mqtt[3187]:   File "/usr/lib/python3.9/logging/__init__.py", line 1142, in __init__
Sep 01 22:13:45 stromableser sml2mqtt[3187]:     StreamHandler.__init__(self, self._open())
Sep 01 22:13:45 stromableser sml2mqtt[3187]:   File "/usr/lib/python3.9/logging/__init__.py", line 1171, in _open
Sep 01 22:13:45 stromableser sml2mqtt[3187]:     return open(self.baseFilename, self.mode, encoding=self.encoding,
Sep 01 22:13:45 stromableser sml2mqtt[3187]: OSError: [Errno 6] No such device or address: '/dev/stdout'
Sep 01 22:13:45 stromableser sml2mqtt[3187]: [Errno 6] No such device or address: '/dev/stdout'

My guess is that it would work when using sys.stdout in the Python script.

Thanks for considering this and thanks for the great work!

AttributeError: 'Client' object has no attribute '_sock'

Hi,

I have been using sml2mqtt for quite some time now without any issues. But recently I had to reinstall my system and therefore upgraded to the latest version. Unfortunately I cant get it to run with the latest version 2.2.

I installed sml2mqtt according the instruction for a venv and I am also able to get a basic sml frame by using

sml2mqtt -c config.ini -a

But when I try to launch it, the following error appears:

Traceback (most recent call last):
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 874, in __del__
    self._reset_sockets()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
    self._sock_close()
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
    if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'

I am using a Raspberry Pi ZeroW with Raspbian 11.

Any idea how this can be fixed?

sml2mqtt can't start with current smllib-version

Hey,
great package 👍. So I can get rid of my own SML-parser (idiot-style bash script).

But installing from scratch with current package versions ends up in error:

(venv) me@pvanlage:/opt/sml2mqtt$ sml2mqtt --config /opt/sml2mqtt
Traceback (most recent call last):
  File "/opt/sml2mqtt/venv/bin/sml2mqtt", line 5, in <module>
    from sml2mqtt.main import main
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/sml2mqtt/main.py", line 13, in <module>
    from sml2mqtt.sml_device import Device
  File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/sml2mqtt/sml_device.py", line 8, in <module>
    from smllib import CrcError, SmlStreamReader
ImportError: cannot import name 'CrcError' from 'smllib' (/opt/sml2mqtt/venv/lib/python3.9/site-packages/smllib/__init__.py)

There seems to have been some code refactoring on smllib side. Version 0.7 is the highest working version.
Installing with pip install smllib==0.7 fixes it for now.
I'm working with Python 3.9.

Configure serial port details

Hi,

is it possible to add serial port connections details (baud, databits, parity and stopbits) in config file?
My smartmeter has different settings as serial-port defaults.

Thanks in advance!

Harry

raw obis frame / data

Hi,

i need the raw obis frame / data in an mqtt topic - would that be possible?

Stefan

New functions

This is actually not an issue, at least not literally.

The devices we're using with sml2mqtt require a PIN to me morsed into the sensor via a flash light. Once that's done, another sequence must be pulsed in to keep the device unlocked. Then a third sequence needs to be pulsed in to enable the extended info record.

Now comes the nightmare: On a powerloss, the device forgets all this and you have to pulse the three sequences in again!

It would be very nice, if sml2mqtt could be extended such that it can pulse these sequences into the device. It could do this hardcoded upon starting the daemon. It could also be done by subscribing to an MQTT topic, perhaps other means too.

Thoughts?

Support for sml raw input as file?

As Background info: I have a tibber pulse as smartmeter reader. when webinterface is enabled you can get the raw sml data via curl/wget.
so now i have a file "sml.raw" can i use this as input somehow instead of a url to a device? Just putting the path to the file there does not work. I would setup an other cronjob tu pull the new data and overwrite the file every few seconds.

My first quick look didn't hint me into the right direction.

Thanks :)

validation error for Settings

I followed the instructions at https://sml2mqtt.readthedocs.io/en/latest/installation.html for running sml2mqtt on an SBC under Armbian. I created the config file based on the example but when running sml2mqtt with it, I always get

(venv) user@mybox:/opt/sml2mqtt/venv$ sml2mqtt --config ../sml2mqtt.conf
1 validation error for Settings
devices -> 11111111111111111111 -> skip -> 0
  str type expected (type=type_error.str)

This happens no matter what I put under "devices" and also when I enclose the value with ""s. An excerpt from my config file:

# Serial port configurations for the sml readers
ports:
- url: /dev/ttyUSB0
  timeout: 3


devices:
  11111111111111111111:
    mqtt:
      topic: house

    skip:
    - 010060320101

    values:

Python version is 3.9.2.

Docker support

I prefer using Docker over installing a package and its dependencies directly to a system. Thus, I wrote a Dockerfile that allows using sml2mqtt without installing it.

Maybe it's useful for someone else, so I'd like to notify you about it. The project is currently hosted on GitHub under git-developer/sml2mqtt. Docker images are available on Docker hub under ckware/sml2mqtt, currently:

  • ckware/sml2mqtt:0.5 - latest stable release from pypi
  • ckware/sml2mqtt:0.6 - built from git commit c981d1b
  • ckware/sml2mqtt:1.0.0 - built from latest git commit

These images are based on latest stable Alpine linux.

For each version, there's another tag prefixed with legacy-:

  • ckware/sml2mqtt:legacy-0.5
  • ckware/sml2mqtt:legacy-0.6
  • ckware/sml2mqtt:legacy-1.0.0

These images are based on Alpine 3.12. They are targeted at hosts with outdated versions of Docker (< 19.03.9) or libseccomp2 (< 2.4.2), e.g. Debian/Raspbian Buster. See time64 requirements for details.

There's an update check running every morning that automatically creates a new image when new commits have been pushed to the main branch of sml2mqtt.

Thanks for maintaining sml2mqtt!

Does not try to reconnect to MQTT when connection is gone

Today I restarted my MQTT broker.

While sml2mqtt detected that it was gone, it apparently did not try to reconnect. A restart of sml2mqtt fixed that:

[2021-10-13 04:21:48,577] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:21:50,385] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:21:51,803] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:21:54,080] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:21:55,505] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:21:57,363] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:21:59,165] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:01,348] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:02,780] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:04,981] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:06,398] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:08,192] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:10,031] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:11,843] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:13,672] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:15,881] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:17,313] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:19,153] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:20,962] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:20,966] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:20,970] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:22,785] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:24,626] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:26,234] [sml2mqtt               ] INFO     | Shutting down ...
[2021-10-13 04:22:26,469] [sml.mqtt               ] ERROR    | [code:4] Could not publish message
[2021-10-13 04:22:34,288] [sml.device.ttyUSB0     ] INFO     | PORT_OPENED
[2021-10-13 04:22:35,497] [sml.device.ttyUSB0     ] INFO     | OK

Feedback on version 1.0

I've stumbled across a discussion on the changes towards version 1.0 in issue #6. I'd like to add a few points but don't want to pollute the existing issue with my comments, so I decided to open this separate issue.

1.) Bug: Indentation of inline comments is changed on program start

I noticed that every time sml2mqtt is started, the configuration is re-written and inline comments are moved 1 space to the right.

  • Before program start:
           0100100700ff:         # 16.7.0  Sum active instantaneous power (A+ - A-) [kW]
  • After program end:
           0100100700ff:          # 16.7.0  Sum active instantaneous power (A+ - A-) [kW]

Negative side effect: the configuration is no longer allowed to be read-only. Up to version 0.6, it was possible to start the program with a read-only configuration file as long as it was complete and correct.

2.) Suggestion: Add support for a simpler configuration syntax

Version 1.0 offers support for value-dependent configuration. A great feature, thanks for that. It has a downside though: the configuration file is getting quite bloated because of mqttand topic properties (already reported here). Example:

devices:
  0123456789abcde01234:
    mqtt:
      topic: power_meter
    status:
      topic: status
    skip:
    - 0100010801ff
    - 0100020801ff
    values:
      0100010800ff:                     # 1.8.0   Positive active energy (A+) total [kWh]
        mqtt:
          topic: total_energy_import
      0100010801ff:                     # 1.8.1   Positive active energy (A+) in tariff T1 [kWh]
        mqtt:
          topic: t1_energy_import
      0100020800ff:                     # 2.8.0   Negative active energy (A+) total [kWh]
        mqtt:
          topic: total_energy_export
      0100020801ff:                     # 2.8.1   Negative active energy (A+) in tariff T1 [kWh]
        mqtt:
          topic: t1_energy_export
      0100100700ff:                     # 16.7.0  Sum active instantaneous power (A+ - A-) [kW]
        mqtt:
          topic: power

My suggestion is to add support for a "shortcut" for mqtt topics. Technically speaking, this means to allow a string value for the mqtt property and parents of an mqtt property when no other child properties are required. This is meant to be in addition to the current syntax, not as a replacement. Example:

  0123456789abcde01234:
    mqtt: power_meter
    status: status
    skip:
    - 0100010801ff
    - 0100020801ff
    values:
      0100010800ff: total_energy_import # 1.8.0   Positive active energy (A+) total [kWh]
      0100010801ff: t1_energy_import    # 1.8.1   Positive active energy (A+) in tariff T1 [kWh]
      0100020800ff: total_energy_export # 2.8.0   Negative active energy (A+) total [kWh]
      0100020801ff: t1_energy_export    # 2.8.1   Negative active energy (A+) in tariff T1 [kWh]
      0100100700ff: power               # 16.7.0  Sum active instantaneous power (A+ - A-) [kW]

3.) Suggestion: Add support for an mqtt topic in skip list

This feature is not really important, but would make the configuration easier to read: The skip property should allow an mqtt topic value additionally to an OBIS value.

Example for current syntax:

devices:
  0123456789abcde01234:
    skip:
    - 0100010801ff
    - 0100020801ff

Example for suggested syntax:

  0123456789abcde01234:
    skip:
    - t1_energy_import
    - t1_energy_export
    values:
      0100010801ff: t1_energy_import
      0100020801ff: t1_energy_export

4.) Suggestion: Label release versions with a Git Tag

Some commits comments start with a version number (0.6 and 1.0). I'd prefer a git tag for each release.

The most important thing comes last: thanks for this great project! It's really helpful and easy to use. Keep up the good work!

No recovery from USB Errors

I am running sml2mqtt on a Raspi, with Debian 11.3. On a regular basis something goes south with USB. dmesg reports:

[225619.631907] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
[1020769.568833] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
[1065317.638338] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
[1070715.658488] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
[1072567.870241] pl2303 ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32

sml2mqtt reports:

[2022-06-16 01:14:23,731] [sml.ttyUSB0            ] ERROR    | Crc error: 13951 != 62811
[2022-06-16 01:14:23,733] [sml.ttyUSB0.status     ] INFO     | CRC_ERROR
[2022-06-16 01:14:24,727] [sml.ttyUSB0.status     ] INFO     | OK
[2022-06-16 04:02:07,774] [sml.ttyUSB0            ] ERROR    | Crc error: 43792 != 8418
[2022-06-16 04:02:07,775] [sml.ttyUSB0.status     ] INFO     | CRC_ERROR
[2022-06-16 04:02:08,779] [sml.ttyUSB0.status     ] INFO     | OK
[2022-06-16 07:26:57,922] [sml.ttyUSB0            ] ERROR    | Crc error: 31688 != 57124
[2022-06-16 07:26:57,924] [sml.ttyUSB0.status     ] INFO     | CRC_ERROR
[2022-06-16 07:26:58,927] [sml.ttyUSB0.status     ] INFO     | OK
[2022-06-16 09:32:46,982] [sml.ttyUSB0            ] ERROR    | Crc error: 42302 != 28876
[2022-06-16 09:32:46,984] [sml.ttyUSB0.status     ] INFO     | CRC_ERROR
[2022-06-16 09:32:47,989] [sml.ttyUSB0.status     ] INFO     | OK
[2022-06-16 09:50:50,987] [sml.ttyUSB0            ] ERROR    | Crc error: 2534 != 4207
[2022-06-16 09:50:50,989] [sml.ttyUSB0.status     ] INFO     | CRC_ERROR

In this situation, no messages are sent to MQTT anymore, eventhough "INFO" seems to report "OK", which would make me believe the tool has recovered the problem successfully but in fact it did not.

The only remedy here is to manually:

service sml2mqtt stop
service sml2mqtt start

I know it is not sml2mqtt's fault in the first place. There is rather something rottin' in the USB susbsystem on that Raspi but let me just ask: Is there any chance sml2mqtt could detect that situation and recover gracefully from it such that it can continue to deliver messages to the MQTT broker?

Feedback rewrite

I've spent the last couple of months completely rewriting sml2mqtt so that it can be extended more easily and customized much better.
The way how values processed is completely configurable. It's possible to create virtual meters, e.g. to get the daily power consumption, min max of day and e.g. mean of an interval. With the new operations there are countless possibilities.

Obviously the configuration format has changed so this requires a new config file.

Installation

python3 -m pip install git+https://github.com/spacemanspiff2007/sml2mqtt.git@tibbr

Documentation

I would like to get some feedback to both the docs and sml2mqtt before publishing a new version on pypi.
I'm pinging some people who were interested in the past - it would be really nice to get feedback.

@the78mole @MC68030 @MrFr33man123 @christiankratzer

@baiti There is now a weighted average available
@aaronk6 stdout can now be used
@hgkdd tls can be configured

"every" does not work

I am trying to limit the frequency at which messages are sent to the MQTT broker .. no success. sml2mqtt sends messages 1/s no matter what I do. I have:

general:
  Wh in kWh: true                 # Automatically convert Wh to kWh
  republish after: 30             # Republish automatically after this time (if no other every filter is configured)

and in the measurements:

   values:

      0100100700ff:
        mqtt:
          topic: power
          filters:
            - every: 30

      0100010800ff:
        mqtt:
          topic: energy

          filters:
            - every: 30

Further, I am unable to remap the topic names. The above, topic: power does not do anything, The topics always look like this:

sml2mqtt//dev/ttyUSB0/0100010800ff 237.3668
sml2mqtt//dev/ttyUSB0/0100100700ff 176

I can hardly believe that these are programming bugs. Much more likely it is my lack of python skills understanding the source code and config meachanism. What is wrong with my config?

sml2mqtt: no negative values for active power

The active power value "01000f0700ff" pushed from sml2mqtt does not differentiate between sending energy to the grid or receiving energy from the grid.
It seems as if this information is encoded in the status field of "0100020801ff" and "0100010801ff" where a value of "418" shows that energy is pushed to the grid, in which case the active power "01000f0700ff" value should be negative.

[2022-03-03 15:15:42,367] [sml.device.ttyUSB0     ] INFO     |             <SmlListEntry>
[2022-03-03 15:15:42,369] [sml.device.ttyUSB0     ] INFO     |                 obis           : 0100010800ff
[2022-03-03 15:15:42,370] [sml.device.ttyUSB0     ] INFO     |                 status         : 418
[2022-03-03 15:15:42,371] [sml.device.ttyUSB0     ] INFO     |                 val_time       : None
[2022-03-03 15:15:42,373] [sml.device.ttyUSB0     ] INFO     |                 unit           : 30
[2022-03-03 15:15:42,374] [sml.device.ttyUSB0     ] INFO     |                 scaler         : -1
[2022-03-03 15:15:42,375] [sml.device.ttyUSB0     ] INFO     |                 value          : 300371964
[2022-03-03 15:15:42,376] [sml.device.ttyUSB0     ] INFO     |                 value_signature: None
[2022-03-03 15:15:42,378] [sml.device.ttyUSB0     ] INFO     |                 -> 30037196.4Wh (Zählerstand Total)
[2022-03-03 15:15:42,379] [sml.device.ttyUSB0     ] INFO     |             <SmlListEntry>
[2022-03-03 15:15:42,380] [sml.device.ttyUSB0     ] INFO     |                 obis           : 0100020800ff
[2022-03-03 15:15:42,382] [sml.device.ttyUSB0     ] INFO     |                 status         : 418
[2022-03-03 15:15:42,383] [sml.device.ttyUSB0     ] INFO     |                 val_time       : None
[2022-03-03 15:15:42,384] [sml.device.ttyUSB0     ] INFO     |                 unit           : 30
[2022-03-03 15:15:42,386] [sml.device.ttyUSB0     ] INFO     |                 scaler         : -1
[2022-03-03 15:15:42,387] [sml.device.ttyUSB0     ] INFO     |                 value          : 691569621
[2022-03-03 15:15:42,389] [sml.device.ttyUSB0     ] INFO     |                 value_signature: None
[2022-03-03 15:15:42,390] [sml.device.ttyUSB0     ] INFO     |                 -> 69156962.1Wh

[2022-03-03 15:15:42,420] [sml.device.ttyUSB0     ] INFO     |             <SmlListEntry>
[2022-03-03 15:15:42,421] [sml.device.ttyUSB0     ] INFO     |                 obis           : 01000f0700ff
[2022-03-03 15:15:42,422] [sml.device.ttyUSB0     ] INFO     |                 status         : None
[2022-03-03 15:15:42,423] [sml.device.ttyUSB0     ] INFO     |                 val_time       : None
[2022-03-03 15:15:42,424] [sml.device.ttyUSB0     ] INFO     |                 unit           : 27
[2022-03-03 15:15:42,425] [sml.device.ttyUSB0     ] INFO     |                 scaler         : -1
[2022-03-03 15:15:42,426] [sml.device.ttyUSB0     ] INFO     |                 value          : 41890
[2022-03-03 15:15:42,427] [sml.device.ttyUSB0     ] INFO     |                 value_signature: None
[2022-03-03 15:15:42,428] [sml.device.ttyUSB0     ] INFO     |                 -> 4189.0W

The value 4189W is the current energy that is delivered to the grid and this value should be negative, i.e. -4189.0W.

After sundown the status value changed from 418 (0x01A2) to 386 (0x0182), which is Bit 5 that seems to be the direction indicator:

[2022-03-03 18:33:30,287] [sml.device.ttyUSB0     ] INFO     |             <SmlListEntry>
[2022-03-03 18:33:30,288] [sml.device.ttyUSB0     ] INFO     |                 obis           : 0100010800ff
[2022-03-03 18:33:30,289] [sml.device.ttyUSB0     ] INFO     |                 status         : 386
[2022-03-03 18:33:30,290] [sml.device.ttyUSB0     ] INFO     |                 val_time       : None
[2022-03-03 18:33:30,291] [sml.device.ttyUSB0     ] INFO     |                 unit           : 30
[2022-03-03 18:33:30,292] [sml.device.ttyUSB0     ] INFO     |                 scaler         : -1
[2022-03-03 18:33:30,293] [sml.device.ttyUSB0     ] INFO     |                 value          : 300377177
[2022-03-03 18:33:30,294] [sml.device.ttyUSB0     ] INFO     |                 value_signature: None
[2022-03-03 18:33:30,295] [sml.device.ttyUSB0     ] INFO     |                 -> 30037717.7Wh (Zählerstand Total)
[2022-03-03 18:33:30,296] [sml.device.ttyUSB0     ] INFO     |             <SmlListEntry>
[2022-03-03 18:33:30,297] [sml.device.ttyUSB0     ] INFO     |                 obis           : 0100020800ff
[2022-03-03 18:33:30,298] [sml.device.ttyUSB0     ] INFO     |                 status         : 386
[2022-03-03 18:33:30,299] [sml.device.ttyUSB0     ] INFO     |                 val_time       : None
[2022-03-03 18:33:30,300] [sml.device.ttyUSB0     ] INFO     |                 unit           : 30
[2022-03-03 18:33:30,301] [sml.device.ttyUSB0     ] INFO     |                 scaler         : -1
[2022-03-03 18:33:30,302] [sml.device.ttyUSB0     ] INFO     |                 value          : 691655821
[2022-03-03 18:33:30,303] [sml.device.ttyUSB0     ] INFO     |                 value_signature: None
[2022-03-03 18:33:30,304] [sml.device.ttyUSB0     ] INFO     |                 -> 69165582.1Wh

[2022-03-03 18:33:30,330] [sml.device.ttyUSB0     ] INFO     |             <SmlListEntry>
[2022-03-03 18:33:30,332] [sml.device.ttyUSB0     ] INFO     |                 obis           : 01000f0700ff
[2022-03-03 18:33:30,332] [sml.device.ttyUSB0     ] INFO     |                 status         : None
[2022-03-03 18:33:30,333] [sml.device.ttyUSB0     ] INFO     |                 val_time       : None
[2022-03-03 18:33:30,334] [sml.device.ttyUSB0     ] INFO     |                 unit           : 27
[2022-03-03 18:33:30,335] [sml.device.ttyUSB0     ] INFO     |                 scaler         : -1
[2022-03-03 18:33:30,336] [sml.device.ttyUSB0     ] INFO     |                 value          : 2649
[2022-03-03 18:33:30,337] [sml.device.ttyUSB0     ] INFO     |                 value_signature: None
[2022-03-03 18:33:30,338] [sml.device.ttyUSB0     ] INFO     |                 -> 264.9W

The issue is also described here for the Tasmota firmware project:
arendst/Tasmota#8001 (comment)

This seems to be an issue only for some older energy meters, in my case an eHz-HW8..., which does not allow to enable extended frames. The option in the menu, after entering the meter PIN, is simply missing.

One idea to solve the issue is to not only write the values into the sml2mqtt/ tree, but also the status:

sml2mqtt/080c2aec2d4c7239/01000f0700ff/value=300377177
sml2mqtt/080c2aec2d4c7239/01000f0700ff/status=386

sml2mqtt/080c2aec2d4c7239/0100010800ff/value=691655821
sml2mqtt/080c2aec2d4c7239/0100010800ff/status=386

sml2mqtt/080c2aec2d4c7239/0100020800ff/value=2649
sml2mqtt/080c2aec2d4c7239/0100020800ff/status=None

Maybe even having an option "-x" (Extended) where all the data from the SML frames is dumped to MQTT?

With the extended information my script that reads the sml2mqtt values from MQTT and pushes them to the tree for my wallbox could do the necessary transformations.

Case-sensitive OBIS ID and device assignment

Part 1:
Case-sensitive:

I noticed that the OBIS assignment must be case-sensitive. However, this is not described.
Example:
I first used the OBIS ID 0100100700FF and didn't get any of it transferred. Only when I changed the identifier to 0100100700ff did the data come. ONLY lower case has worked!

Part 2:
Background info:
I have two Landis Gyr electronic meters. These are each read out with a reading head (USB connection) and pluged into a Raspberry Pi.

As described in the readme, I looked for the server ID for the respective meter from the analysis and entered it in the config.yml.
Here I got a completely strange view in the MQTT.

mqtt

Only much later did I notice that the program only looks at the OBIS ID "0100000009ff". However, since I have a Landis Gyr where this ID can be found under "0100600100ff" I have to use the url -> /dev/ttyUSB0 or ​​/dev/ttyUSB1. Now I got a nice MQTT data stream.
mqtt-2

Until the next reboot of the Raspberry Pi. Here the read heads were initialized in a different order by the OS. So I received the meter reading from the other meter in the MQTT.

errors when running config

What did I do wrong

(venv) root@DietPi:/opt/sml2mqtt/venv# sml2mqtt --config /opt/sml2mqtt
Traceback (most recent call last):
File "/opt/sml2mqtt/venv/bin/sml2mqtt", line 6, in
from sml2mqtt.main import main
File "/opt/sml2mqtt/venv/lib/python3.7/site-packages/sml2mqtt/main.py", line 1 3, in
from sml2mqtt.sml_device import Device
File "/opt/sml2mqtt/venv/lib/python3.7/site-packages/sml2mqtt/sml_device.py", line 7, in
from smllib import CrcError, SmlStreamReader
File "/opt/sml2mqtt/venv/lib/python3.7/site-packages/smllib/init.py", line 3, in
from smllib.sml_frame import SmlFrame # noqa: F401
File "/opt/sml2mqtt/venv/lib/python3.7/site-packages/smllib/sml_frame.py", lin e 107
while (start := self.bytes.find(b'\x77\x07\x01', start + 1)) != -1:
^
SyntaxError: invalid syntax

Moving average

My understanding is the datagrams are sent by the device at a rate of 1 per second. Typically one wouldn't want to send an MQTT message once per second. For instance, I have configured my system such that it sends an MQTT message every 60s.

In such a configuration it would be very helpful if sml2mqtt could do a moving average over the "power" sensor. The moving average should be calculated based on the amount of samples that fit into one MQTT message interval. In my example where the device sends a datagram once every second and the MQTT message goes out every 30 seconds the moving average should be calculated over the last 30 samples periodically.

Could that be implemented? perhaps as a configurable option?

sml2mqtt does not reconnect to mqtt broker upon los of connection

As it seems, and by observation, if I shutdown my remote moquitto for maintenance, even if it is just an instant service mosquitto restart, sml2mqtt loses its connection and never opens it again. To be on the safe side I typically reboot the raspi that runs sml2mqtt in such a situation. It would be much more reliable, however, if sml2mqtt detects the connection loss and performs an automatic reconnect, permanently and periodically, and never gives up on retry. My tasmota based sensors, which also report via MQTT do exactly that, therefore no manual intervention is ever required if one component in the flowgraph goes down for a while and comes back later.

Input data from URL instead of serial device

Hi Spaceman,

I have a little feature request:

Since Tibber is is more and more common, blocks the IR port of your meter, but a hacked tibber bridge provides the SML data as a whole on a simple URL. It would be awesome, if the config would allow to provide an HTTP endpoint address as the data source for the SML data.

It would need the following configuration:

The procedure to hack your bridge is described in the openWB community forums or on Wyraz blog.

Regards,
Daniel

TLS support: not implemented yet?

Thanks for the package. I use it to couple my energy meters with home assistant.
Communication without TLS to my mqtt broker works perfectly fine.

I would like to use TLS for security reasons. But I can't find any information how to specify what ca_cert and client_cert shound be used.

Is ist correct that TLS is not implented yet? The underlying asyncio_mqtt library seems to support TLS. So, I would guess the implementation is not very hard. Are there any plans to implement this in the near future?

I'm definitely willing to do tests!

Crash after a few days of running

I'm running sml2mqtt on a Raspi 2. This night, it crashed:

[2021-10-12 22:09:47,985] [sml.device.ttyUSB0     ] ERROR    | Traceback (most recent call last):
[2021-10-12 22:09:47,988] [sml.device.ttyUSB0     ] ERROR    |   File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/sml2mqtt/sml_device.py", line 90, in read
[2021-10-12 22:09:47,990] [sml.device.ttyUSB0     ] ERROR    |     for sml_obj in frame.get_obis():
[2021-10-12 22:09:47,992] [sml.device.ttyUSB0     ] ERROR    |   File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/smllib/sml_frame.py", line 113, in get_obis
[2021-10-12 22:09:47,995] [sml.device.ttyUSB0     ] ERROR    |     ret.append(SmlListEntry.from_list(data))
[2021-10-12 22:09:47,997] [sml.device.ttyUSB0     ] ERROR    |   File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/smllib/sml_fields.py", line 146, in from_list
[2021-10-12 22:09:47,999] [sml.device.ttyUSB0     ] ERROR    |     raise ValueError('value is required!')
[2021-10-12 22:09:48,001] [sml.device.ttyUSB0     ] ERROR    | ValueError: value is required!
[2021-10-12 22:09:48,004] [sml.device.ttyUSB0     ] INFO     | ERROR
[2021-10-12 22:09:48,017] [sml.serial             ] INFO     | Port /dev/ttyUSB0 was closed
[2021-10-12 22:09:48,020] [sml.device.ttyUSB0     ] INFO     | PORT_CLOSED
[2021-10-12 22:09:48,217] [asyncio                ] ERROR    | Task was destroyed but it is pending!
task: <Task pending name='Task-170900' coro=<stop_loop() done, defined at /opt/sml2mqtt/venv/lib/python3.9/site-packages/sml2mqtt/_signals.py:10> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0xb5c3d838>()]>>

syslog doesn't contain anything interesting.

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.