ThomDietrich / miflora-mqtt-daemon

Linux service to collect and transfer Xiaomi Mi Flora plant sensor data via MQTT to your smart home system, with cluster support 🌱🌼πŸ₯€πŸ‘🌳
MIT License
610 stars 140 forks source link

[docker] No sensors found in configuration file "config.ini" #100

Closed Giel538 closed 4 years ago

Giel538 commented 4 years ago

Hi.

I'm trying to run the mqtt-daemon in docker.

Everything installed fine but when i run the docker i keep getting this error:

[2020-02-14 15:08:27] No sensors found in configuration file "config.ini"

In my docker compose file i have this line:

  - /data/miflora2mqtt/config.ini:/opt/miflora-mqtt-daemon/config.ini

So the config is stored in opt/miflora-mqtt-daemon/config.ini. When i copy this file back from the docker to my local hard drive i see the right config.ini In this file i have this:

[Sensors]

# Add your Mi Flora sensors here. Each sensor consists of a name and a Ethernet MAC address.
# Additional location information can be added to the name, delimited by an '@'.
# Scan for sensors from the command line with:
#    $ sudo hcitool lescan
#
# Examples:
#
Flower_1 = C4:7C:8D:6A:74:7F
Flower_2 = C4:7C:8D:6A:74:23
Flower_3 = C4:7C:8D:6B:1A:70

Do you have any idea what i can try?

CWempe commented 4 years ago

According to the Instruction (https://github.com/ThomDietrich/miflora-mqtt-daemon#usage-with-docker) your path is wrong.

The config.ini inside the container is located in /config.

So you line should look like this, I guess.

  - /data/miflora2mqtt/config.ini:/config/config.ini
ThomDietrich commented 4 years ago

Thanks @CWempe. @Giel538 hope it works now. Would you like to provide your docker-compose.yml and please feel free to suggest a change to the README to remove this issue for others.

Giel538 commented 4 years ago

This is my docker file now:

version: '3.6'
services:  
  portainer:
    image: ruimarinho/miflora-mqtt
    container_name: "miflora-mqtt"
    restart: "always"
    network_mode: host    
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /data/miflora2mqtt/config.ini:/config/config.ini
    environment:
      - TZ=Europe/Amsterdam

Still the same problem :(

Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Source: https://github.com/ThomDietrich/miflora-mqtt-daemon

[2020-02-18 20:12:34] No sensors found in configuration file "config.ini
CWempe commented 4 years ago

Did you try without the underscore?

Flower1 = C4:7C:8D:6A:74:7F
Flower2 = C4:7C:8D:6A:74:23
Flower3 = C4:7C:8D:6B:1A:70

Just a guess... πŸ€·β€β™‚

Giel538 commented 4 years ago

I tried now, but still not working.

I also changed my docker volume line to:

So it is pointing to the directory config insted of config.ini directly.

Is there anyway to find out of it is a problem in the missing file or a wrong configured config.ini?

CWempe commented 4 years ago

I would try to start the container witout the file or with a wrong path. So you know if you get another error like "config file not found" instead of "No sensors found".

And you could replace your file with the example to see if you get something like "cannot connect to sensor".

Just a little troubleshooting. πŸ€”

ThomDietrich commented 4 years ago

Agree with @CWempe doing a bit of troubleshooting should bring you a long way. Let us know when you can rule out things.

That said, I checked the source code and there is indeed no explicit check to make sure the file exists. That is definitely something to improve! PR welcome.

Besides that: Seems like way back I decided to fall back to the config.ini.dist file when the user one wasn't found. This doesn't seem utterly meaningful now and we should change this behavior with the PR.

Giel538 commented 4 years ago

If i deleted my local config folder it will be recreated. I place the config.ini file inside here. I also tried to delete everything except my 3 flower sensor. I tried with only flower. Nothing works.

I removed the volume line and added this to my docker file:

environment:
  - MIFLORA_MQTT_HOSTNAME=192.168.1.188
  - MIFLORA_SENSORS_0_Schefflera@Kitchen=C4:7C:8D:6B:1A:70

But still the same error.

ThomDietrich commented 4 years ago

Hey, were you able to identify the cause of this error? Let us know and I'll work on a mitigation or improvement of the documentation ;)