Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by tontze »

You could search information about your plants and set limits when to notify user?
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
physiker123
Posts: 37
Joined: Wednesday 25 November 2015 18:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany / France
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by physiker123 »

Hello,

now it works. I just had to wait.


Thank you for the great script!

physiker123 wrote:Just a quick idea: apparently I do not get any sensor values.
Is this a raspberry pi error or an error with Bluetooth?

Do I have to install the app to initiate the sensors? Above was written, that the sensors would work without the app..

Best regards



physiker123 wrote:Hello,

I have problems including my flower sensor into domoticz.

I followed the wiki article (with no result of this part, because it did not find the folder:
If all goes well, one last thing is to copy the Gatt tool to the directory where your linux version keeps its programs. It's location is different for different Linux flavours. Try:

sudo cp attrib/gatttool /usr/local/bin/ or sudo cp attrib/gatttool /usr/bin/
I found my flower sensor, and tried the demo.py, with the following result:

Code: Select all

Traceback (most recent call last):
  File "demo.py", line 6, in <module>
    print("Temperature: {}°C".format(poller.parameter_value("temperature")))
  File "/home/pi/domoticz/scripts/miflora/miflora/miflora_poller.py", line 256, in parameter_value
    self._mac)
OSError: [Errno Could not read data from Mi Flora sensor %s] C4:7C:8D:62:7C:CE
Does anybody have a clue?

Thank you in advance and thanks for the work!
Gargy
Posts: 4
Joined: Tuesday 17 March 2015 7:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by Gargy »

Hi!

So my MiFloras are working flawlesly on my RPi3. So today I wanted to move the sensor polling on my RPi2, where is also Domoticz. I instlled the BlueZ and I can find the sensor with BT LE scan, but when I tried to run the demo script, I got this:

Code: Select all

pi@raspberrypi ~/miflora $ sudo python3 demo.py
Traceback (most recent call last):
  File "demo.py", line 4, in <module>
    from miflora.miflora_poller import MiFloraPoller, \
  File "/home/pi/miflora/miflora/miflora_poller.py", line 12, in <module>
    from subprocess import PIPE, Popen, TimeoutExpired
ImportError: cannot import name TimeoutExpired
I tried everything, followed several tutorialsa and installed all mentioned dependencies etc.
Still can't figure out what is going on...

Any idea?
Africagrower
Posts: 1
Joined: Tuesday 14 March 2017 7:36
Target OS: Windows
Domoticz version:
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by Africagrower »

Dears,

We are working at an project in Africa, to use the Xiaomi Mi Flora sensors, to save water and to have the optimal production.
To keep at as Simple As Possible (KISS), we like to use an Android tablet or an small laptop.

Goal is to have the data on those, and to store the historical data.

Who like to help us?

By myself, based in the Netherlands, and visit every two months Zambia, and regular Tanzania/Ethiopia etc.

Regards
Ewout Schurink
Gargy
Posts: 4
Joined: Tuesday 17 March 2015 7:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by Gargy »

MiFlora has built-in logger and logs (I think) every 5 minutes. So when you check your plants with Android device and original Xiaomi software, the history is downloaded to the device.

The second option is of course Domoticz, where you can set the sensor polling time. I keep my polling rate at 15 minutes and didn't noticed any fall in battery level.

If you need only soil moisture, perhaps you could look on AliExpress - they got some dirty cheap soil sensors with WiFi or even cheaper if you go with wired device(s)...
User avatar
LouiS22
Posts: 433
Joined: Friday 27 February 2015 13:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by LouiS22 »

Gargy wrote:Hi!

So my MiFloras are working flawlesly on my RPi3. So today I wanted to move the sensor polling on my RPi2, where is also Domoticz. I instlled the BlueZ and I can find the sensor with BT LE scan, but when I tried to run the demo script, I got this:

Code: Select all

pi@raspberrypi ~/miflora $ sudo python3 demo.py
Traceback (most recent call last):
  File "demo.py", line 4, in <module>
    from miflora.miflora_poller import MiFloraPoller, \
  File "/home/pi/miflora/miflora/miflora_poller.py", line 12, in <module>
    from subprocess import PIPE, Popen, TimeoutExpired
ImportError: cannot import name TimeoutExpired
I tried everything, followed several tutorialsa and installed all mentioned dependencies etc.
Still can't figure out what is going on...

Any idea?
Have you compiled everything according to the wiki?
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by tontze »

LouiS22 wrote:
Gargy wrote:Hi!

So my MiFloras are working flawlesly on my RPi3. So today I wanted to move the sensor polling on my RPi2, where is also Domoticz. I instlled the BlueZ and I can find the sensor with BT LE scan, but when I tried to run the demo script, I got this:

Code: Select all

pi@raspberrypi ~/miflora $ sudo python3 demo.py
Traceback (most recent call last):
  File "demo.py", line 4, in <module>
    from miflora.miflora_poller import MiFloraPoller, \
  File "/home/pi/miflora/miflora/miflora_poller.py", line 12, in <module>
    from subprocess import PIPE, Popen, TimeoutExpired
ImportError: cannot import name TimeoutExpired
I tried everything, followed several tutorialsa and installed all mentioned dependencies etc.
Still can't figure out what is going on...

Any idea?
Have you compiled everything according to the wiki?
For me, it looks like you havent copied miflora folder to home/pi/domoticz/scripts ? I dont know does it make any difference, but in wiki it says to copy so .. :)


Also, im executing domoticz.py, dont know what that demo.py is for ?
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by tontze »

Africagrower wrote:Dears,

We are working at an project in Africa, to use the Xiaomi Mi Flora sensors, to save water and to have the optimal production.
To keep at as Simple As Possible (KISS), we like to use an Android tablet or an small laptop.

Goal is to have the data on those, and to store the historical data.

Who like to help us?

By myself, based in the Netherlands, and visit every two months Zambia, and regular Tanzania/Ethiopia etc.

Regards
Ewout Schurink
Attleast if you gonna use them with android app, latest update makes them unusable outside china ... They still will work with domoticz tho.
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
physiker123
Posts: 37
Joined: Wednesday 25 November 2015 18:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany / France
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by physiker123 »

Hello again :)

Does anybody know, why cron is not working in my case? I followed the wiki and also this troubleshooting ( http://garyhall.org.uk/troubleshooting- ... ry-pi.html ), cron is up and running, and my sudo crontab -e looks like this:

Code: Select all

# m h  dom mon dow   command
* * * * * /usr/bin/python3 /home/pi/domoticz/scripts/python/miflora/domoticz.py
I made it execute every minute to have a better look. Any ideas?

Thank you!

edit: I looked in the syslog, there it says

Code: Select all

(root) CMD (/usr/bin/python3 /home/pi/domoticz/scripts/python/miflora/domoticz.py)
Mar 14 21:51:01 raspberrypi CRON[9583]: (CRON) info (No MTA installed, discarding output)
So i added

Code: Select all

MAILTO=""
before the task, as suggested here:

http://askubuntu.com/questions/222512/c ... the-syslog

Now there are no more errors in syslog, but it still does not run the script... The syslog says:

Code: Select all

Mar 14 22:08:01 raspberrypi CRON[11346]: (root) CMD (/usr/bin/python3 /home/pi/domoticz/scripts/python/miflora/domoticz.py)
but the values are not updated in domoticz. If I run the script manually, it works..
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by tontze »

Try:

Code: Select all

*/1 * * * * /usr/bin/python3 /home/pi/domoticz/scripts/python/miflora/domoticz.py
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
physiker123
Posts: 37
Joined: Wednesday 25 November 2015 18:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany / France
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by physiker123 »

tontze wrote:Try:

Code: Select all

*/1 * * * * /usr/bin/python3 /home/pi/domoticz/scripts/python/miflora/domoticz.py
Thank you for your answer, but it still does not work.

I also tried the command under the cron environment

Code: Select all

env -i /bin/bash --noprofile --norc
, and there it works as sudo /usr/bin ....

I also edited the crontab as sudo crontab -e
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by krizzz »

Same type of problems here. Got everything installed and I see the Miflora when using the HCItool for scanning.

But when running the domesticz.py script, I have the following errors:

Code: Select all

1: Test
Mi Flora: C4:7C:8D:63:18:14
Firmware: 2.7.0
Name: Flower care
Traceback (most recent call last):
  File "domoticz.py", line 97, in <module>
    update("C4:7C:8D:63:18:14","3","1","2","4")
  File "domoticz.py", line 69, in update
    print("Temperature: {}\xb0C".format(poller.parameter_value("temperature")))
UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 17: ordinal not in range(128)
Somebody knows what this means?
physiker123
Posts: 37
Joined: Wednesday 25 November 2015 18:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany / France
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by physiker123 »

Yes. That means, that there is an Ascii incompatible character. I deleted the °C and so on from the print section in the script, and then at least the script runs. But still, crontab does not work for me.

krizzz wrote:Same type of problems here. Got everything installed and I see the Miflora when using the HCItool for scanning.

But when running the domesticz.py script, I have the following errors:

Code: Select all

1: Test
Mi Flora: C4:7C:8D:63:18:14
Firmware: 2.7.0
Name: Flower care
Traceback (most recent call last):
  File "domoticz.py", line 97, in <module>
    update("C4:7C:8D:63:18:14","3","1","2","4")
  File "domoticz.py", line 69, in update
    print("Temperature: {}\xb0C".format(poller.parameter_value("temperature")))
UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 17: ordinal not in range(128)
Somebody knows what this means?
krizzz
Posts: 200
Joined: Wednesday 20 November 2013 20:36
Target OS: Linux
Domoticz version:
Location: The Netherlands
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by krizzz »

physiker123 wrote:Yes. That means, that there is an Ascii incompatible character. I deleted the °C and so on from the print section in the script, and then at least the script runs. But still, crontab does not work for me.
Thanks! I will give that a try. And try figure out why the crontab wont work...Image
physiker123
Posts: 37
Joined: Wednesday 25 November 2015 18:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany / France
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by physiker123 »

I solved my problem. Your answer, @tontze , now works, but the path was wrong, there was a /python/ to much. So here is my crontab configuration working on my raspberry pi 3:

Code: Select all

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
MAILTO=""
*/1 * * * * /usr/bin/python3 /home/pi/domoticz/scripts/miflora/domoticz.py
This runs the script every minute, you may want to change that.

Great :)
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by tontze »

physiker123 wrote:I solved my problem. Your answer, @tontze , now works, but the path was wrong, there was a /python/ to much. So here is my crontab configuration working on my raspberry pi 3:

Code: Select all

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
MAILTO=""
*/1 * * * * /usr/bin/python3 /home/pi/domoticz/scripts/miflora/domoticz.py
This runs the script every minute, you may want to change that.

Great :)
Nice, it runs every minute, i thought u asked for it to run every minute :) just change */1 to */10 and it runs every 10minute :)
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
physiker123
Posts: 37
Joined: Wednesday 25 November 2015 18:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany / France
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by physiker123 »

Yes I asked to run it every minute, but your path to my script included a /python/, which was to much and prevended it from working :)

Now I changed it to run every 6 hours, that should be enough.

Thanks anyway :)
tontze wrote:
physiker123 wrote:I solved my problem. Your answer, @tontze , now works, but the path was wrong, there was a /python/ to much. So here is my crontab configuration working on my raspberry pi 3:

Code: Select all

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
MAILTO=""
*/1 * * * * /usr/bin/python3 /home/pi/domoticz/scripts/miflora/domoticz.py
This runs the script every minute, you may want to change that.

Great :)
Nice, it runs every minute, i thought u asked for it to run every minute :) just change */1 to */10 and it runs every 10minute :)
physiker123
Posts: 37
Joined: Wednesday 25 November 2015 18:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Germany / France
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by physiker123 »

physiker123 wrote:Yes I asked to run it every minute, but your path to my script included a /python/, which was to much and prevended it from working :)

Now I changed it to run every 6 hours, that should be enough.

so this is my new script:

Code: Select all

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
MAILTO=""
0 0,6,12,18 * * * /usr/bin/python3 /home/pi/domoticz/scripts/miflora/domoticz.py
Thanks anyway :)
tontze wrote:
physiker123 wrote:I solved my problem. Your answer, @tontze , now works, but the path was wrong, there was a /python/ to much. So here is my crontab configuration working on my raspberry pi 3:

Code: Select all

# Edit this file to introduce tasks to be run by cron.
# 
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# 
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').# 
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# 
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# 
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# 
# For more information see the manual pages of crontab(5) and cron(8)
# 
# m h  dom mon dow   command
MAILTO=""
*/1 * * * * /usr/bin/python3 /home/pi/domoticz/scripts/miflora/domoticz.py
This runs the script every minute, you may want to change that.

Great :)
Nice, it runs every minute, i thought u asked for it to run every minute :) just change */1 to */10 and it runs every 10minute :)
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by tontze »

Actually, wiki´s crontab part doesnt correspond to instructions earlier. I had same mistake as user before ..

Code: Select all

And then add this line:
0 0,12 * * * python3 /pi/domoticz/scripts/python/miflora/domoticz.py
an extra /python/ in the path, and missing /home from the path start :)

-T
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
tontze
Posts: 317
Joined: Thursday 12 January 2017 15:30
Target OS: Linux
Domoticz version: Beta Ch
Location: Finland
Contact:

Re: Xiaomi Mi Flora [Temp/Light/Moisture] BLE Sensor

Post by tontze »

since im not a scriptin/coding guru, im askinfg for help :) I would need to stop certain service(BT Beaconing) before updating mi flora, because BT Beacon service dies if anything else access HCI0 .. How can this be achieved ?

Maybe first check if mentioned service running before stopping it ..

Would be nice extra to this great script :)

-T
-----------------------------------------
Smartthings
zigbee2mqtt
RFLink 433mhz / Nrf 2.4Ghz
Mi Light
esp8266MiLight Hub
OpenHab/HomeAssistant/Domoticz
HP T610 & Debian 5.10.19-1 x86_64[/b]
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest