validation error for Settings
hello-world-dot-c opened this issue · 4 comments
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.
You have to quote the entry under "skip":
skip:
- 010060320101
should be
skip:
- "010060320101"
Without quotes it's a number with a leading 0.
Found that it's not the device ID but the skip values that are the problem, when I do this:
skip:
- "010060320101"
it accepts it even though it goes against all examples that I could find. Other notes:
This
values:
0100010800FF:
is not matched against received values while this
values:
0100010800ff:
works. Making these strings all-uppercase or all-lowercase for comparison wouldn't be a bad idea IMHO.
Lastly, if you define a values section for a value that is not (yet) received, sml2mqtt crashes when using the -a option:
[2023-12-13 13:14:05,639] [sml.ttyUSB0 ] ERROR | Received Frame
[2023-12-13 13:14:05,640] [sml.ttyUSB0 ] ERROR | -> b'76050023357b6200620072630101760107ffffffffffff05000bbc7f0b0a01454d480000c7e63272620165000bbd556201637fa90076050023357c62006200726307017707ffffffffffff0b0a01454d480000c7e632070100620affff72620165000bbd557477070100603201010101010104454d480177070100600100ff010101010b0a01454d480000c7e6320177070100010800ff641c010472620165000bbd55621e52036900000000000000b40177070100020800ff0172620165000bbd55621e5203690000000000000000010101632ac60076050023357d6200620072630201710163a3f400'
[2023-12-13 13:14:05,643] [sml.ttyUSB0 ] ERROR | Traceback (most recent call last):
[2023-12-13 13:14:05,644] [sml.ttyUSB0 ] ERROR | File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/sml2mqtt/device/sml_device.py", line 200, in serial_data_read
[2023-12-13 13:14:05,644] [sml.ttyUSB0 ] ERROR | self.process_frame(frame)
[2023-12-13 13:14:05,645] [sml.ttyUSB0 ] ERROR | File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/sml2mqtt/device/sml_device.py", line 289, in process_frame
[2023-12-13 13:14:05,645] [sml.ttyUSB0 ] ERROR | for line in value.describe().splitlines():
[2023-12-13 13:14:05,646] [sml.ttyUSB0 ] ERROR | File "/opt/sml2mqtt/venv/lib/python3.9/site-packages/sml2mqtt/sml_value/sml_value.py", line 61, in describe
[2023-12-13 13:14:05,646] [sml.ttyUSB0 ] ERROR | f'{once}raw value: {self.sml_value.get_value()}\n' \
[2023-12-13 13:14:05,647] [sml.ttyUSB0 ] ERROR | AttributeError: 'NoneType' object has no attribute 'get_value'
[2023-12-13 13:14:05,648] [sml.ttyUSB0.status ] INFO | ERROR
[2023-12-13 13:14:05,648] [sml.mqtt.pub ] INFO | sml2mqtt/house/status: ERROR (QOS: 0, retain: False)
[2023-12-13 13:14:05,650] [sml.serial ] INFO | Port /dev/ttyUSB0 was closed
[2023-12-13 13:14:05,651] [sml.ttyUSB0.status ] INFO | PORT_CLOSED
Thanks, figured this out in the meantime. Note that the example on the configuration page doesn't have the quotes around the skip value:
https://sml2mqtt.readthedocs.io/en/latest/configuration.html
Fixed in the rewrite