Comments (21)
Hi, sorry. First comment on github.
from miflora-mqtt-daemon.
Hi all, not sure if solved but if you run Raspbian Stretch you need:
[Unit]
...
After=network.target
...
[Install]
WantedBy=multi-user.target
There is an change from "After=networking.target" (Debian / Raspbian 8) to "After=network.target" (in (Debian / Raspbian 9)
Gerhard
from miflora-mqtt-daemon.
after reboot Pi miflora service did'n start with openhab.
● miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Loaded: loaded (/etc/systemd/system/miflora.service; enabled)
Active: failed (Result: exit-code) since Wed 2017-09-06 22:12:51 MSK; 4min 46s ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Process: 440 ExecStart=/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py (code=exited, status=1/FAILURE)
Main PID: 440 (code=exited, status=1/FAILURE)
Status: "Sep 06 22:12:51 - MQTT connection error. Please check your settings in the configuration file "config.ini"."
Sep 06 22:12:50 openHABianPi systemd[1]: Starting Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon...
Sep 06 22:12:51 openHABianPi miflora-mqtt-daemon.py[440]: [2017-09-06 22:12:51] MQTT connection error. Please c...ni"
Sep 06 22:12:51 openHABianPi systemd[1]: miflora.service: main process exited, code=exited, status=1/FAILURE
Sep 06 22:12:51 openHABianPi systemd[1]: Failed to start Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.
Sep 06 22:12:51 openHABianPi systemd[1]: Unit miflora.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
How to make miflora service start with the system?(I new with *nix system, but wona now how it work) Because after command:
sudo systemctl start miflora.service
All start work fine!
Can you push me in right way?
from miflora-mqtt-daemon.
Hey there 👋
the error is quite clear: "MQTT connection error." - My guess is, that your MQTT broker is not ready or not reachable at this point of the boot up. Which broker are you using where? Please be aware, that the service in it's default configuration will wait for the mosquitto.service
to become available.
from miflora-mqtt-daemon.
Hi,
so, I finally came from work and bellow check status of service on raspberry:
[19:32:00] openhabian@openHABianPi:~$ sudo systemctl status miflora.service
[sudo] password for openhabian:
● miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Loaded: loaded (/etc/systemd/system/miflora.service; enabled)
Active: active (running) since Tue 2017-09-12 00:29:06 MSK; 19h ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Main PID: 1953 (python3)
Status: "Sep 12 19:28:25 - Status messages published."
CGroup: /system.slice/miflora.service
└─1953 python3 /opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py
Sep 12 00:29:06 openHABianPi systemd[1]: Started Xiaomi Mi Flora Plant Senso....
Hint: Some lines were ellipsized, use -l to show in full.
[19:33:42] openhabian@openHABianPi:~$ sudo systemctl status mosquitto.service
● mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled)
Active: active (running) since Tue 2017-09-12 00:22:55 MSK; 19h ago
Docs: man:mosquitto(8)
https://mosquitto.org/
Main PID: 437 (mosquitto)
CGroup: /system.slice/mosquitto.service
└─437 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Sep 12 00:22:55 openHABianPi systemd[1]: Started Mosquitto MQTT Broker.
`sudo reboot`
[19:43:53] openhabian@openHABianPi:~$ sudo systemctl status mosquitto.service
[sudo] password for openhabian:
● mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled)
Active: active (running) since Tue 2017-09-12 19:38:10 MSK; 5min ago
Docs: man:mosquitto(8)
https://mosquitto.org/
Main PID: 438 (mosquitto)
CGroup: /system.slice/mosquitto.service
└─438 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
Sep 12 19:38:10 openHABianPi systemd[1]: Started Mosquitto MQTT Broker
[19:44:04] openhabian@openHABianPi:~$ sudo systemctl status miflora.service
● miflora.service - Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Loaded: loaded (/etc/systemd/system/miflora.service; enabled)
Active: failed (Result: exit-code) since Tue 2017-09-12 19:38:11 MSK; 6min ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Process: 441 ExecStart=/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py (code=exited, status=1/FAILURE)
Main PID: 441 (code=exited, status=1/FAILURE)
Status: "Sep 12 19:38:11 - MQTT connection error. Please check your settings in the configuration file "config.ini"."
Sep 12 19:38:11 openHABianPi miflora-mqtt-daemon.py[441]: [2017-09-12 19:38:1...
Sep 12 19:38:11 openHABianPi systemd[1]: miflora.service: main process exite...E
Sep 12 19:38:11 openHABianPi systemd[1]: Failed to start Xiaomi Mi Flora Pla....
Sep 12 19:38:11 openHABianPi systemd[1]: Unit miflora.service entered failed....
Hint: Some lines were ellipsized, use -l to show in full.
sudo nano /opt/miflora-mqtt-daemon/config.ini
config.ini:
# Configuration file for Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
# Source: https://github.com/ThomDietrich/miflora-mqtt-daemon
#
# Uncomment and adapt all settings as needed.
[General]
# The operation mode of the program. Determines wether retrieved sensor data is published via MQTT or stdout/file.
# Currently supported:
# mqtt-json - Publish to an mqtt broker, json encoded (Default)
# mqtt-homie - Publish to an mqtt broker following the Homie MQTT convention (https://github.com/marvinroger/homie)
# json - Print to stdout as json encoded string
reporting_method = mqtt-json
# The bluetooth adapter that should be used to connect to Mi Flora devices (Default: hci0)
adapter = hci0
[Daemon]
# Enable or Disable an endless execution loop (Default: true)
enabled = true
# The period between two measurements in seconds (Default: 300)
period = 300
[MQTT]
# The hostname or IP address of the MQTT broker to connect to (Default: localhost)
hostname = 192.168.1.69
# The TCP port the MQTT broker is listening on. SSL/TLS currently not implemented (Default: 1883)
port = 1883
# Maximum period in seconds between ping messages to the broker. (Default: 60)
#keepalive = 60
# The MQTT base topic to publish all Mi Flora sensor data topics under.
# Default depends on the configured reporting_mode (mqtt-json: miflora, mqtt-homie: homie)
#base_topic = miflora/aspagarus
#base_topic = homie
# Homie specific: The device ID for this daemon instance (Default: miflora-mqtt-daemon)
#homie_device_id = miflora-mqtt-daemon
# The MQTT broker authentification credentials (Default: no authentication)
#username = user
#password = pwd123
[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:
#
aspagarus = C4:7C:8D:64:38:60
#JapaneseBonsai = C4:7C:8D:44:55:66
#Petunia@Balcony = C4:7C:8D:77:88:99
from miflora-mqtt-daemon.
Sorry, name of item on Russian, but it not influence on anything.
home.items file
// Mi Flora "Aspagarus" (C4:7C:8D:64:38:60)
Number Aspagarus_Battery "Заряд батарейки [%d %%]" (Battery) {mqtt="<[broker:miflora/aspagarus:state:JSONPATH($.battery)]"}
Number Aspagarus_Temperature "Темперетура воздуха[%.1f °C]" (Temperature) {mqtt="<[broker:miflora/aspagarus:state:JSONPATH($.temperature)]"}
Number Aspagarus_Moisture "Влажность в горшке [%d %%]" (Moisture) {mqtt="<[broker:miflora/aspagarus:state:JSONPATH($.moisture)]"}
Number Aspagarus_Conductivity "Плодородность почвы [%d µS/cm]" (Conductivity) {mqtt="<[broker:miflora/aspagarus:state:JSONPATH($.conductivity)]"}
Number Aspagarus_Light "Интенсивность освещения [%d lux]" (Light) {mqtt="<[broker:miflora/aspagarus:state:JSONPATH($.light)]"}
home.sitemap
Frame label="Аспагарус" {
Text item=Aspagarus_Battery
Text item=Aspagarus_Light
Text item=Aspagarus_Temperature
Text item=Aspagarus_Moisture
Text item=Aspagarus_Conductivity
May be problem in screen
from miflora-mqtt-daemon.
In Mqtt dashboard i see message from miflora after reboot:
miflora/aspagarus/$announce
{}
miflora/$announce
{}
And I try to add line Restart=always
in service, but still not want to start after reboot:
[Unit]
Description=Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon
Documentation=https://github.com/ThomDietrich/miflora-mqtt-daemon
After=bluetooth.service mosquitto.service
[Service]
Type=notify
Restart=always
User=daemon
Group=daemon
WorkingDirectory=/opt/miflora-mqtt-daemon/
ExecStart=/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py
StandardOutput=null
StandardError=journal
Environment=PYTHONUNBUFFERED=true
[Install]
WantedBy=multi-user.target
Bellow pic.
systemctl list-dependencies miflora.service
from miflora-mqtt-daemon.
Not sure what's going on. You'll need to test some more yourself. On my testing system it works just fine. Maybe play with the "After=" line a bit.
from miflora-mqtt-daemon.
so, I found the way - add delay in start. I think broker or bluetooth or something services did not time to start working.
sudo nano /etc/systemd/system/multi-user.target.wants/miflora.service
[Service]
StartLimitIntervalSec = 120
but after test this value can be increase about 180 sec
from miflora-mqtt-daemon.
Interesting, but why did you close the issue?
Let's leave the issue open for others and if it's a recurring theme this should be added to the code here.
from miflora-mqtt-daemon.
I see. No problem! ;)
from miflora-mqtt-daemon.
Hi, I have the same (?) issue with my RPi 0W on Raspbian Stretch Lite.
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 Wed 2017-09-13 18:59:42 CEST; 15min ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Process: 244 ExecStart=/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py (code=exited, status=1/FAILURE)
Main PID: 244 (code=exited, status=1/FAILURE)
Status: "Sep 13 18:59:42 - MQTT connection error. Please check your settings in the configuration file "config.ini"."
Sep 13 18:59:33 gardenpi systemd[1]: Starting Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon...
Sep 13 18:59:42 gardenpi miflora-mqtt-daemon.py[244]: [2017-09-13 18:59:42] MQTT connection error. Please check your settings in the configuration file "config.ini"
Sep 13 18:59:42 gardenpi systemd[1]: miflora.service: Main process exited, code=exited, status=1/FAILURE
Sep 13 18:59:42 gardenpi systemd[1]: Failed to start Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.
Sep 13 18:59:42 gardenpi systemd[1]: miflora.service: Unit entered failed state.
Sep 13 18:59:42 gardenpi systemd[1]: miflora.service: Failed with result 'exit-code'.
Adding the StartLimitIntervalSec = 120
throws another error Sep 13 19:22:28 gardenpi systemd[1]: [/etc/systemd/system/miflora.service:7] Unknown lvalue 'StartLimitIntervalSec
.
What am I doing wrong?
from miflora-mqtt-daemon.
@midijunk
https://stackoverflow.com/questions/38220995/systemd-unknown-lvalue-user-in-section-unit
Sounds like you've added the option to the wrong section
from miflora-mqtt-daemon.
ah, right, my fault. It is now in the "Unit" section and doesnt throw an error but doesnt help either (with 180). Same issue on boot. Seems that the it doesnt wait for 3 minutes? its not so important for me because I dont restart the pi too often.
from miflora-mqtt-daemon.
Nevertheless we should solve this issue for other users. I'm still unclear about the actual reason for it. The MQTT broker should be up in seconds....
from miflora-mqtt-daemon.
Do you know some python?
Could you please open up the miflora-mqtt-daemon.py file and change these lines
miflora-mqtt-daemon/miflora-mqtt-daemon.py
Lines 154 to 160 in c275a27
to
try:
mqtt_client.connect(config['MQTT'].get('hostname', 'localhost'),
port=config['MQTT'].getint('port', 1883),
keepalive=config['MQTT'].getint('keepalive', 60))
except Exception as e:
print_line('MQTT connection error. Please check your settings in the configuration file "config.ini"', error=True, sd_notify=True)
print_line(e, error=True, sd_notify=True)
sys.exit(1)
You should then see a more helpful error message in the log. Please post it here.
from miflora-mqtt-daemon.
sure
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 Thu 2017-09-14 13:38:23 CEST; 47s ago
Docs: https://github.com/ThomDietrich/miflora-mqtt-daemon
Process: 249 ExecStart=/opt/miflora-mqtt-daemon/miflora-mqtt-daemon.py (code=exited, status=1/FAILURE)
Main PID: 249 (code=exited, status=1/FAILURE)
Status: "Sep 14 13:38:23 - Configuration accepted."
Sep 14 13:38:23 gardenpi miflora-mqtt-daemon.py[249]: sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
Sep 14 13:38:23 gardenpi miflora-mqtt-daemon.py[249]: File "/usr/lib/python3.5/socket.py", line 712, in create_connection
Sep 14 13:38:23 gardenpi miflora-mqtt-daemon.py[249]: raise err
Sep 14 13:38:23 gardenpi miflora-mqtt-daemon.py[249]: File "/usr/lib/python3.5/socket.py", line 703, in create_connection
Sep 14 13:38:23 gardenpi miflora-mqtt-daemon.py[249]: sock.connect(sa)
Sep 14 13:38:23 gardenpi miflora-mqtt-daemon.py[249]: OSError: [Errno 101] Network is unreachable
Sep 14 13:38:23 gardenpi systemd[1]: miflora.service: Main process exited, code=exited, status=1/FAILURE
Sep 14 13:38:23 gardenpi systemd[1]: Failed to start Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon.
Sep 14 13:38:23 gardenpi systemd[1]: miflora.service: Unit entered failed state.
Sep 14 13:38:23 gardenpi systemd[1]: miflora.service: Failed with result 'exit-code'.
looks like the wifi is not up in time? my coverage is really bad on the balcony
from miflora-mqtt-daemon.
Help me here: Why is the issue related to wifi? At least @Nickolay40 had his broker on the same Pi...
from miflora-mqtt-daemon.
sorry, just wild guessing (read socket, connection and my wifi is bad there).
Im using mosquitto as a broker on another rpi with home assistant connected by ethernet to my fritzbox.
from miflora-mqtt-daemon.
Could you look into https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget ?
from miflora-mqtt-daemon.
edit:
Python is no problem but Im new to linux. My systemd-networkd doesnt work.
Sep 14 19:33:21 gardenpi systemd[1]: Network Service is not active.
Sep 14 19:33:21 gardenpi systemd[1]: Dependency failed for Wait for Network to be Configured.
-- Subject: Unit systemd-networkd-wait-online.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit systemd-networkd-wait-online.service has failed.
--
-- The result is dependency.
old
Doenst work. Im btw on Raspbian Stretch.
The first thing I did was to enableWait for network on boot
in raspi-config.
Then I enabledsystemctl enable systemd-networkd-wait-online.service
and then even addedAfter=network-online.target Wants=network-online.target
.
from miflora-mqtt-daemon.
Related Issues (20)
- Its possible to change MAC address in MyFlora sensor? HOT 2
- Bluepy error after apt update && upgrade HOT 1
- Daemon connects and collects data but does not publish to openhab HOT 3
- `$ sudo hcitool lescan` - Input/Output error HOT 2
- Anyone with problems? ->Miflora Firmware 3.3.5 HOT 4
- Failed to retrieve data from Mi Flora sensor but `bluetoothctl` detects all data HOT 2
- Light measurement disturbed by flashing LED HOT 1
- Installation fails HOT 8
- Add config option for "expire_after" HOT 2
- running as service in python3.10 HOT 3
- Api changes in miflora break miflora-mqtt-daemon HOT 4
- Brightness value wrong HOT 6
- MQTT Push - Topic not case sensitive HOT 2
- Last Message timestamp HOT 2
- Project dependencies may have API risk issues HOT 1
- Running on ESP32 HOT 1
- Change unit of light sensor from "lux" to "lx" HOT 1
- Support for Flower Care Max sensor?
- one sensor stopped answering, but works in the app HOT 2
- Error: The MAC address "..." seems to be in the wrong format. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from miflora-mqtt-daemon.