Open martellucci opened 4 years ago
Hey! Probably an issue with the availability of resources. Is the MQTT broker installed on the same system? Check if you have the latest service file version, which has a dependency on the network target.
https://github.com/ThomDietrich/miflora-mqtt-daemon#continuous-daemonservice
The MQTT broker is on different server with different IP, but same LAN. The file is the last version.
Ciao
I see exactly the same after a (or any) reboot on my Rpi 3B:
han@mediamachine:~ $ sudo systemctl status miflora.service
● miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Loaded: loaded (/etc/systemd/system/miflora.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-10-16 19:52:32 UTC; 1h 21min ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Process: 712 ExecStart=/usr/bin/python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py (code=exited, status=1/FAILURE)
Main PID: 712 (code=exited, status=1/FAILURE)
Status: "Oct 16 19:52:32 - MQTT connection error. Please check your settings in the configuration file "config.ini"."
Oct 16 19:52:32 mediamachine systemd[1]: miflora.service: Unit entered failed state.
Oct 16 19:52:32 mediamachine systemd[1]: miflora.service: Failed with result 'exit-code'.
Oct 16 19:52:32 mediamachine systemd[1]: miflora.service: Service hold-off time over, scheduling restart.
Oct 16 19:52:32 mediamachine systemd[1]: Stopped Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.
Oct 16 19:52:32 mediamachine systemd[1]: miflora.service: Start request repeated too quickly.
Oct 16 19:52:32 mediamachine systemd[1]: Failed to start Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.
Oct 16 19:52:32 mediamachine systemd[1]: miflora.service: Unit entered failed state.
Oct 16 19:52:32 mediamachine systemd[1]: miflora.service: Failed with result 'exit-code'.
When the service is started again, everything is normal again.
han@mediamachine:~ $ sudo systemctl start miflora.service
han@mediamachine:~ $ sudo systemctl status miflora.service
● miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Loaded: loaded (/etc/systemd/system/miflora.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-10-16 21:15:47 UTC; 34s ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Main PID: 2843 (python3)
Status: "Oct 16 21:16:10 - Status messages published."
Tasks: 2 (limit: 4915)
CGroup: /system.slice/miflora.service
└─2843 /usr/bin/python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py
Oct 16 21:15:46 mediamachine systemd[1]: Starting Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon...
Oct 16 21:15:47 mediamachine systemd[1]: Started Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.
han@mediamachine:~ $
MQTT is running on another system.
tia Han
I added a wait in the service definition:
[Unit]
Description=Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Documentation=https://github.com/ThomDietrich/miflora-mqtt-daemon
After=network.target bluetooth.service mosquitto.service
[Service]
Type=notify
User=daemon
Group=daemon
WorkingDirectory=/opt/miflora-mqtt-daemon/
ExecStartPre=/bin/sleep 30. **<-------------------**
ExecStart=/usr/bin/python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py
StandardOutput=null
#StandardOutput=syslog
#SyslogIdentifier=miflora
StandardError=journal
Environment=PYTHONUNBUFFERED=true
Restart=always
[Install]
WantedBy=multi-user.target
It looks like this delay helps. I guess the MQTT problem is caused by a service that has not fully started when miflora tries to use it.
tia Han
IMHO the daemon should wait for the MQTT server to become available and gracefully shutdown if it doesn't reach it within a certain timeframe.
https://blog.miguelgrinberg.com/post/how-to-make-python-wait
Happy to help if I can squeeze it in my busy schedule ;-)
Hey, unfortunately I have the same problem. Suddenly it stopped working and I can't figure out why. The MQTT Broker (mosquito) is running on a different server inside my LAN and anther service is able to use ist. And even this great tool was able some days before.
The log says only to check the config.ini but this is purely minimalistic.
Is there any way to see what actually failed?
miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Loaded: loaded (/etc/systemd/system/miflora.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-03-09 11:44:29 CET; 2s ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Process: 7697 ExecStart=/usr/bin/python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py (code=exited, status=1/FAILURE)
Main PID: 7697 (code=exited, status=1/FAILURE)
Status: "Mar 09 11:44:29 - MQTT connection error. Please check your settings in the configuration file "config.ini"."
Can you help me? Thanks
Ben
Hi, I’m using miflora-mqtt-daemon on RPI 3B+ and I’m very happy with it ;)
Only I’ve got a problem after reboot of the RPI when the daemon doesn’t start. The error is:
I restart the daemon manually and it works well.
Can you help me?
Ciao
Stefano