matthijsvisser / kamstrup-402-mqtt

This project provides a Python library that enables communication with the Kamstrup Multical 402 heat meter. The configured parameters will be read from the meter at a certain interval and published in MQTT messages.
MIT License
45 stars 11 forks source link

Errors running deamon.py #6

Closed JeroenHaringman closed 2 years ago

JeroenHaringman commented 2 years ago

I'm stuck on this error when I run python3 daemon.py &:

[3] 2510 root@raspberrypi:/home/pi/kamstrup-402-mqtt# Traceback (most recent call last): File "daemon.py", line 92, in main() File "daemon.py", line 88, in main daemon = KamstrupDaemon() File "daemon.py", line 50, in init self.poll_interval = kamstrup_cfg["poll_interval"] KeyError: 'poll_interval'

matthijsvisser commented 2 years ago

Looks like you haven't specified a poll interval of the meter in the configuration file.

JeroenHaringman commented 2 years ago

All right, I added the poll interval, my config.yaml now looks like this:

mqtt: host: 192.168.178.84 port: 1883 client: kamstrup topic: kamstrup qos: 0 retain: False authentication: False poll_interval: 1 serial_device: com_port: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A5043WW6-if00-port0 kamstrup: parameters:

That COM port is the same one I use with the multical402-4-domoticz.py script.

When I run python3 daemon.py I get permission denied errors (can't quite remember if I had those last night as well, maybe I went straight for the sudo python3 daemon.py), so I run sudo python3 daemon.py, and then I get this:

pi@raspberrypi:~/kamstrup-402-mqtt $ sudo python3 daemon.py & [5] 18746 [4] Exit 1 python3 daemon.py pi@raspberrypi:~/kamstrup-402-mqtt $ Traceback (most recent call last): File "daemon.py", line 92, in main() File "daemon.py", line 88, in main daemon = KamstrupDaemon() File "daemon.py", line 50, in init self.poll_interval = kamstrup_cfg["poll_interval"] KeyError: 'poll_interval'

Looks like the same error. Also (obviously, but I checked anyway) nothing showed up on the kamstrup MQTT topic.

matthijsvisser commented 2 years ago

The poll interval attribute is part of the kamstrup object. You'll need to place it under the kamstrup parameters. Take a look at the example; config.yaml

JeroenHaringman commented 2 years ago

And that was, the solution, thank you very much! No errors when i run the script, log says it has transmitted sane values to the MQTT topic.

Now I have misconfigured the configuration.yaml of my Home Assistant and it won't start anymore 😋 but that's my problem.

matthijsvisser commented 2 years ago

Nice, have fun!