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

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

Moderator: leecollings

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 »

Stuntteam wrote:Yes..
When it's ready, that will be my prompt switch to RFLink ;)
User avatar
jadon
Posts: 7
Joined: Monday 07 November 2016 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Tiel, Netherlands
Contact:

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

Post by jadon »

I received my Xiaomi Mi Flora yesterday! I've only had a few minutes to play with it. Connecting with my phone was easy, as you'd expect with a bluetooth LE device. However, I downloaded the Xiaomi Home app and noticed the Flora dashboard is Chinese only :( So I couldn't tell what's what... Anyway, I'll have a look at reading data with that github script this weekend and see if it makes any sense :)
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 »

jadon wrote:I received my Xiaomi Mi Flora yesterday! I've only had a few minutes to play with it. Connecting with my phone was easy, as you'd expect with a bluetooth LE device. However, I downloaded the Xiaomi Home app and noticed the Flora dashboard is Chinese only :( So I couldn't tell what's what... Anyway, I'll have a look at reading data with that github script this weekend and see if it makes any sense :)
Could you please explore the device's range? For example, if you put the sensor into a corner will you phone's able to get the reading from another room, or another floor, etc?
Itschi
Posts: 18
Joined: Saturday 16 May 2015 14:58
Target OS: Windows
Domoticz version:
Contact:

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

Post by Itschi »

I got mine today. Transmission of the data over a free air distance of 10m worked fine. iOS App is in English and Chinese. Have to wait for the arrival of a HM-11 BLE module to continue with reading the sensors data by an own application...
User avatar
jadon
Posts: 7
Joined: Monday 07 November 2016 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Tiel, Netherlands
Contact:

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

Post by jadon »

The range is quite good! I live in an old house (so no concrete walls). I have my Mi Flora in the living room and my raspberry pi 3 in the hallway. I could even connect from my laptop on the 2nd floor.

Anyway, using "sudo hcitool lescan" it lists my device:

Code: Select all

pi@domoticz:~/miflora$ sudo hcitool lescan
LE Scan ...
C4:7C:8D:--:--:-- Flower care
Next, I cloned the repository from https://github.com/open-homeautomation/miflora

I changed the MAC address in demo.py and started the script. After 30 seconds or so, I got the following data:

Code: Select all

pi@domoticz:~/miflora$ python3 demo.py
Getting data from Mi Flora
FW: 2.6.6
Name: Flower care
Temperature: 19.4
Moisture: 9
Light: 201
Conductivity: 0
Battery: 100
So what's next? :)
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

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

Post by pvm »

You can store them in virtual sensors
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
User avatar
jadon
Posts: 7
Joined: Monday 07 November 2016 14:59
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Tiel, Netherlands
Contact:

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

Post by jadon »

okay, so I create a dummy hardware device and called it "Flower care"

Image

Then I added three virtual sensors: Temp, Lux and Moisture

Image

I copied the demo.py script to domoticz.py and added some code (Python is not my native programming language, so suggetions are welcome)

Code: Select all

import urllib.request
import base64
from miflora.miflora_poller import MiFloraPoller, \
    MI_CONDUCTIVITY, MI_MOISTURE, MI_LIGHT, MI_TEMPERATURE, MI_BATTERY

# Settings for the domoticz server
domoticzserver   = "localhost:8080"
domoticzusername = "admin"
domoticzpassword = "----"

# Sensor IDs
idx_temp  = "88"
idx_lux   = "89"
idx_moist = "90"

############

base64string = base64.encodestring(('%s:%s' % (domoticzusername, domoticzpassword)).encode()).decode().replace('\n', '')

def domoticzrequest (url):
  request = urllib.request.Request(url)
  request.add_header("Authorization", "Basic %s" % base64string)
  response = urllib.request.urlopen(request)
  return response.read()

poller = MiFloraPoller("C4:7C:8D:61:F7:2A")
#print("Getting data from Mi Flora")
#print("FW: {}".format(poller.firmware_version()))
#print("Name: {}".format(poller.name()))
#print("Temperature: {}".format(poller.parameter_value("temperature")))
#print("Moisture: {}".format(poller.parameter_value(MI_MOISTURE)))
#print("Light: {}".format(poller.parameter_value(MI_LIGHT)))
#print("Conductivity: {}".format(poller.parameter_value(MI_CONDUCTIVITY)))
#print("Battery: {}".format(poller.parameter_value(MI_BATTERY)))

val_bat  = "{}".format(poller.parameter_value(MI_BATTERY))

# Update temp
val_temp = "{}".format(poller.parameter_value("temperature"))
domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=udevice&idx=" + idx_temp + "&nvalue=0&svalue=" + val_temp + "&battery=" + val_bat)

# Update lux
val_lux = "{}".format(poller.parameter_value(MI_LIGHT))
domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=udevice&idx=" + idx_lux + "&svalue=" + val_lux + "&battery=" + val_bat)

# Update moisture
val_moist = "{}".format(poller.parameter_value(MI_MOISTURE))
domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=udevice&idx=" + idx_moist + "&nvalue=" + val_moist + "&battery=" + val_bat)
Using a cronjob I run this script every hour and my sensors get updated :)
I don't know how long the battery is going to last. It looks like it drains 1% every time I do a read out....

Note: I'm using python3

Image
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

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

Post by deennoo »

Great script, can do the job on my side waiting for a better BLE integration on RFLink.

Why don't you use a virtual leaf sensor ? Icon is more revelante.

As this is for a plant care, maybe run script twice a day (at mid day and before sunset) can be more usefull and battery friendly.
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

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

Post by pvm »

Thnx! Script working great
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

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

Post by deennoo »

Yeap thx for the script ! works as perfect !
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
trixwood

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

Post by trixwood »

i added with a custom sensor...

Code: Select all

idx_cond  = "141"

# Update conductivity
val_cond = "{}".format(poller.parameter_value(MI_CONDUCTIVITY))
domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=udevice&idx=" + idx_cond + "&svalue=" + val_cond + "&battery=" + val_bat)
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

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

Post by deennoo »

trixwood wrote:i added with a custom sensor...

Code: Select all

idx_cond  = "141"

# Update conductivity
val_cond = "{}".format(poller.parameter_value(MI_CONDUCTIVITY))
domoticzrequest("http://" + domoticzserver + "/json.htm?type=command&param=udevice&idx=" + idx_cond + "&svalue=" + val_cond + "&battery=" + val_bat)
Hey hey same here...
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

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

Post by pvm »

What type of device do you use?
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
deennoo
Posts: 784
Joined: Wednesday 10 December 2014 13:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

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

Post by deennoo »

Custom sensor
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / Tasmota / MQTT / BLE / Zigate
http://domo-attitude.fr
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

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

Post by pvm »

I understand :) I use custom sensor leaf wetness
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
Deluka
Posts: 19
Joined: Thursday 03 March 2016 18:38
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

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

Post by Deluka »

Would it be possible to use more then 1 Mi Flora
trixwood

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

Post by trixwood »

yes! as many as you like.

Does anybody has some info on how long the battery will last?
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 »

trixwood wrote:yes! as many as you like.

Does anybody has some info on how long the battery will last?
The users manual promises a year, but IMHO it really depends on your using habits: i.e. if you poll the data every minute, it will suck the battery really fast.
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

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

Post by pvm »

After a week of 1 daily request and first day 15 times it is still 100 full
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
lepetitnicolas
Posts: 12
Joined: Wednesday 02 November 2016 22:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.5877
Location: South West of France
Contact:

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

Post by lepetitnicolas »

Thanks for this script ! It's work perfect.

Now, i need to create a custom sensor (i don't see it.... V3.4834) and a cronjob
Raspberry Pi 3 - RFLink and Homewizard
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest