embyt / enocean-mqtt

Receives messages from an enOcean serial interface (USB) and provides selected messages to an MQTT broker.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem with setup

ochstobi opened this issue · comments

Hello,

I have trouble setting up enocean-mqtt as docker container.
For now I have mapped the device and the config folder like this:
sudo docker run -itd --name="enocean2MQTT" --net=host --device=/dev/enocean --restart=always -v /volume1/docker/enocean2mqtt/config:/config flopon/enocean-mqtt:latest
But after startup I get this error:

Traceback (most recent call last):
  File "/usr/local/bin/enoceanmqtt", line 11, in <module>
    load_entry_point('enoceanmqtt', 'console_scripts', 'enoceanmqtt')()
  File "/enoceanmqtt/enoceanmqtt.py", line 107, in main
    com = Communicator(conf, sensors)
  File "/enoceanmqtt/communicator.py", line 33, in __init__
    raise Exception("Mandatory configuration not found: mqtt_host/enocean_port")
Exception: Mandatory configuration not found: mqtt_host/enocean_port

It seems that the config file is not found. Inside the enocean2mqtt/config folder on my machine there is the enoceanmqtt.conf file with this content:

[CONFIG]
enocean_port    = /dev/enocean
log_packets     = 1

mqtt_host       = poseidon
mqtt_port       = 1883
mqtt_client_id  = enocean   # ensure that this is unique if you use multiple client
mqtt_keepalive  = 60
mqtt_prefix     = enocean/

## all other sections define the sensors to monitor
#FT55EH eltako
[switch]
address = 0x01729E4C
rorg = 0xF6 # BS1
func = 0x02
type = 0x01

What am I doing wrong? Thanks for yor help.

commented

Yes, it seems that the config file is not found.
The application searches for the config file at the default location, which is /etc/enoceanmqtt.conf. Alternatively you can provide another path of the config file as a command line argument to enoceanmqtt.

I have adapted the path in the volume mount but the error still perists. -v /volume1/docker/enocean2mqtt/config:/etc
In portainer I see that the config folder is mapped to etc but nothing changed. How can I debug this further?

I have copied all files from the container with docker cp container-id:/ /debug
In the enoceanmqtt.log I have the following entries:

2021-03-10 10:30:29,439 INFO: Logging to file: /enoceanmqtt/../enoceanmqtt.log
2021-03-10 10:30:29,439 INFO: Logging debug to console
2021-03-10 10:30:29,440 WARNING: Config file /enoceanmqtt-default.conf /config/enoceanmqtt.conf does not exist, skipping

But at least the /enoceanmqtt-default.conf is there in the root of the container:

Tobias@Poseidon:~/debug$ ls
bin                 enoceanmqtt.conf.sample   home     README.md  sys
config              enoceanmqtt-default.conf  lib      root       tmp
dev                 enoceanmqtt.egg-info      LICENSE  run        usr
Dockerfile          enoceanmqtt.log           media    sbin       var
Dockerfile-arm32v6  enoceanmqtt.service       mnt      setup.py
enoceanmqtt         etc                       proc     srv

Inside the /config folder there is nothing, but in the etc/ there is the enoceanmqtt.conf file. Even if i mount the enoceanmqtt.conffile in /etc and /config the warning remains that the file does not exist.

EDIT: config problem solved after finding another image -> volschin/enocean-mqtt.
Now the program is starting but I can't see communication with my switch (Eltako FT55EH) ID: 01 72 9E 4C.
Is this configuration correct?

[switch]
address = 0x01729E4C
rorg = 0xF6 # BS1
func = 0x02
type = 0x01

Don't know what the parameters rorg, func and typedoes or come from. Copied them from this post issue: #1

commented

The parameters rorg,... define the used Enocean protocol used by the switch. You need to look up the device to see what it is using.
Keep looking at the log file to see whether RF packets are received.

Okay thanks, I'll dig a bit deeper in the configuration for that device. Currently no packages are recieved.
Can you give me information what are the possible values for these parameters?

commented

I don't think that this is the cause for your issues. Even if the sensor with its address is not contained in the config file at all, there should be a message in the log file telling that it received a message from an unknown sensor.

Are you sure the enocean_port is configured correctly and the device is accessible at the given path? Did you setup the udev rule? Instead you could also use the "real path" like /dev/ttyUSB0.

I am not very familiar with Docker, but do you need to route the device somehow in the Docker container?

What about installing the lib directly in the host system, without using Docker? Its dependencies are rather small.

I don't think that you can use symlinks for docker --device, and by the looks of it the udev configuration instructions creates a symlink to the real device. So you'll need to dereference the symlink in docker run:

$ sudo docker run -itd --name="enocean2MQTT" --net=host --device=$(readlink -f /dev/enocean) --restart=always -v /volume1/docker/enocean2mqtt/config:/config flopon/enocean-mqtt:latest

Also, note that the documented order of config file processing doesn't match the default order that is defined in Dockerfile:

ENTRYPOINT ["python", "/usr/local/bin/enoceanmqtt", "/enoceanmqtt-default.conf", "/config/enoceanmqtt.conf"]

You can try overriding the entrypoint parameters like this to enable debugging and to read just /config/enoceanmqtt.conf:

$ sudo docker run -itd --name="enocean2MQTT" --net=host --device=$(readlink -f /dev/enocean) --restart=always -v /volume1/docker/enocean2mqtt/config:/config flopon/enocean-mqtt:latest --debug /usr/local/bin/enoceanmqtt /config/enoceanmqtt.conf

You can remove --debug once you get it working.

Thanks for your help. I got the software running with the stick. Problem is the switch itself. I ordered it online as enocean switch. But I got an "Battery-free by EnOcean" switch which is sending the messages over 2,4GHz Zigbee-Protokoll....

@romor Software runs smooth in docker. Should mention in the Readme that the right docker image is volschin/enocean-mqtt and the volume mount have to point to -v /local/path/to/configfile:/config.
Example docker command: sudo docker run --name="enoceanmqtt" --device=/dev/enocean -v /volume1/docker/enocean2mqtt/config:/config volschin/enocean-mqtt:latest

@crowbarz Thanks for your hints. I have tested the symlink and I found out it is working now in docker. So you don't need to get the absolute device path.