As I also have a power meter with an SML protocol (Itron OpenWay 3.HZ), I wanted to describe my way to get to the values using a serial reader and sml2mqtt in Docker as an alternative.
Maybe this is helpful for others too:
sml2mqtt provides a good analyze functionality, so you don’t have to dive into details about your meter upfront.
First run a temporary copy of the container with the shell as entrypoint, as sml2mqtt will quit immediately without a valid conig.
That way we can rum sml2mqtt manually in the container to analyze the incoming data and create the config.
After that we can start another final copy of the container and remove the temporary one.
You need to map a directory from the host (or a docker volume) to the sml2mqtt folder inside the container, so the config can be persisted:
docker run -it --name sml2mqtt_analyze --volume /opt/sml2mqtt:/sml2mqtt --device=/dev/ttyUSB0 --entrypoint sh spacemanspiff2007/sml2mqtt:latest
Inside the shell run sml2mqtt with the analyze flag and a path where the config should be created:
sml2mqtt -c /sml2mqtt/config.yml --analyze
This will fail as the serial port inside the sample config it just created is most likely wrong.
So edit the config using vi /sml2mqtt/config.yml
and press i to enter edit mode.
Remove one of the two port entries from the sample config and adjust the other one to your needs:
ports:
- url: /dev/ttyUSB0 # Device path
timeout: 3 # Seconds after which a timeout will be detected (default=3)
Also edit the mqtt connection settings to your needs.
Then press Esc to leave edit mode and enter :wq to save and leave vi.
Now start sml2mqtt with the analyze flag again, so se can see the structure fo the incoming data:
(We don’t have to specify the config location again, as it now exists at the default location.)
sml2mqtt --analyze
Check the output for the value server_id.
Replace “DEVICE_ID_HEX” in the config with this value:
devices: # Device configuration by ID or url
0b013454760009893245:
mqtt: # Optional MQTT configuration for this meter.
...
In the device sample configuration, there’s also the possibility to filter out unwanted values by their OBIS code (skip section),
or to apply special settings to single OBIS values (values section).
If you don’t want to use this, simply remove the whole skip and values sections.
After that, run sml2mqtt without the –analyze flag, which will result in continous reading and also the reporting to your MQTT server.
If everything works, stop sml2mqtt by pressing CTRL+C and exit the temporary container by leaving the shell with exit .
Now setup the final container, which will autorun sml2mqtt instead of a shell when it starts:
docker run --detach --name sml2mqtt --volume /opt/sml2mqtt:/sml2mqtt --device=/dev/ttyUSB0 spacemanspiff2007/sml2mqtt:latest
After that you can delete the temporary container.