Xiaomi Mi Plants Monitor Flower

Well, it is paired with my phone. So I shut down the bluetooth on my phone, but I still have the “No default controller available” when I try to pair it (or use scan on) in bluetoothctl.

Anyone got this working on a Pi Zero W?

I’m using plantgateway on a Pi Zero W to publish the value of six Xiaomi Mi sensors on a MQTT topic without issue and I have configured the Plant Monitor component to monitor the plants.

The only issue I’m facing is the display of the status of the plant. I’m only manage to get “ok” or “problem” and have to click to see what the problem is (e.g. conductivity low).

2 Likes

I have setup 3 of them, only 1 get its details.

sensor:

  • platform: miflora
    mac: C4:7C:8D:60:95:5F
    name: Vinca Minor
    Median: 3
    adapter: hci0
    monitored_conditions:
    • temperature
    • light
    • conductivity
    • battery
    • moisture
  • platform: miflora
    mac: C4:7C:8D:65:BF:70
    name: Palm achtertuin rechts
    Median: 3
    adapter: hci0
    monitored_conditions:
    • temperature
    • light
    • conductivity
    • battery
    • moisture
  • platform: miflora
    mac: C4:7C:8D:65:BE:A5
    name: Palm achtertuin links
    Median: 3
    adapter: hci0
    monitored_conditions:
    • temperature
    • light
    • conductivity
    • battery
    • moisture

am im doing this right in yaml??

@pedrogense I have the following setup runnning for 3 months now without any problems:

  - platform: miflora
    name: "Mi Flora 1"
    mac: 'C4:7C:8D:64:46:77'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 2"
    mac: 'C4:7C:8D:64:42:27'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 3"
    mac: 'C4:7C:8D:64:45:C7'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 4"
    mac: 'C4:7C:8D:64:45:D3'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
  - platform: miflora
    name: "Mi Flora 5"
    mac: 'C4:7C:8D:64:45:9C'
    force_update: true
    monitored_conditions:
      - temperature
      - moisture
      - light
      - conductivity
      - battery
plant:
  Yucca:
    sensors:
      moisture: sensor.mi_flora_1_moisture
      battery: sensor.mi_flora_1_battery
      temperature: sensor.mi_flora_1_temperature
      conductivity: sensor.mi_flora_1_conductivity
      brightness: sensor.mi_flora_1_light_intensity
    min_moisture: 25
    max_moisture: 60
    min_battery: 15
    min_conductivity: 350
    min_temperature: 15
  Habanero Red:
    sensors:
      moisture: sensor.mi_flora_2_moisture
      battery: sensor.mi_flora_2_battery
      temperature: sensor.mi_flora_2_temperature
      conductivity: sensor.mi_flora_2_conductivity
      brightness: sensor.mi_flora_2_light_intensity
    min_moisture: 25
    max_moisture: 60
    min_battery: 15
    min_conductivity: 350
    min_temperature: 15
  Jalapeno Grande:
    sensors:
      moisture: sensor.mi_flora_3_moisture
      battery: sensor.mi_flora_3_battery
      temperature: sensor.mi_flora_3_temperature
      conductivity: sensor.mi_flora_3_conductivity
      brightness: sensor.mi_flora_3_light_intensity
    min_moisture: 25
    max_moisture: 60
    min_battery: 15
    min_conductivity: 350
    min_temperature: 15
  Habanero Chocolate:
    sensors:
      moisture: sensor.mi_flora_4_moisture
      battery: sensor.mi_flora_4_battery
      temperature: sensor.mi_flora_4_temperature
      conductivity: sensor.mi_flora_4_conductivity
      brightness: sensor.mi_flora_4_light_intensity
    min_moisture: 25
    max_moisture: 60
    min_battery: 15
    min_conductivity: 350
    min_temperature: 15
  Habanero Orange:
    sensors:
      moisture: sensor.mi_flora_5_moisture
      battery: sensor.mi_flora_5_battery
      temperature: sensor.mi_flora_5_temperature
      conductivity: sensor.mi_flora_5_conductivity
      brightness: sensor.mi_flora_5_light_intensity
    min_moisture: 25
    max_moisture: 60
    min_battery: 15
    min_conductivity: 350
    min_temperature: 15

Would be great if someone with a BLE Sniffer to also Reverse Eng this one: Aqualin Bluetooth Water Irrigation System
Could just create a really cheap automatic irrigation system…
Mi Flora reporting if water was needed and Aqualin watering automatically…

1 Like

I added a comment in that another thread, here are some instruction how you can sniff the traffic with an Android phone: http://www.fte.com/WebHelp/BPA600/Content/Documentation/WhitePapers/BPA600/Encryption/GettingAndroidLinkKey/RetrievingHCIlog.htm
edit: to add, you can simply open the btsnoop_hci.log file directly with Wireshark with no need for conversions etc.

That would be cool!

Today I use a solenoid valve that opens when gets power and closes when power is removed. For that I just use a normal Z-wave switch for the outlet. So when I get a low threshold value from the Miflora HA turns that switch on.

But the Aqualin is cheaper than the switch and valve was.

1 Like

I’m trying to set up the plantgw on my rpi z w but I keep getting this:

[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Helper exited
[Errno 104] Connection reset by peer
Exception IOError: (32, 'Broken pipe') in <bound method Peripheral.__del__ of <bluepy.btle.Peripheral instance at 0xb654b788>> ignored
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Helper exited
[Errno 104] Connection reset by peer
Exception IOError: (32, 'Broken pipe') in <bound method Peripheral.__del__ of <bluepy.btle.Peripheral instance at 0xb654bcd8>> ignored
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Helper exited

When I try to do a ble scan i get the following:

root@raspberrypi:~/bluepy/bluepy# python3 blescan.py
Scanning for devices...
Traceback (most recent call last):
  File "blescan.py", line 140, in <module>
    main()
  File "blescan.py", line 122, in main
    devices = scanner.scan(arg.timeout)
  File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 679, in scan
    self.start(passive=passive)
  File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 617, in start
    self._mgmtCmd("le on")
  File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 272, in _mgmtCmd
    rsp = self._waitResp('mgmt')
  File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 304, in _waitResp
    raise BTLEException(BTLEException.INTERNAL_ERROR, "Helper exited")
bluepy.btle.BTLEException: Helper exited

I can however do a lescan:

pi@raspberrypi:~ $ sudo hcitool lescan
LE Scan ...
C4:7C:8D:65:B8:FF (unknown)
38:01:95:D4:07:93 (unknown)
C4:7C:8D:65:B8:FF Flower care
04:52:C7:B0:EB:23 (unknown)

What gives?

EDIT:

Reinstalled raspbian again and hciconfig -a actually works now.

Now I just get this:

root@plantgateway:~# plantgateway
[Errno 104] Connection reset by peer
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
[Errno 104] Connection reset by peer
could not read data from C4:7C:8D:65:B8:FF (Rihanna) with reason: Error from Bluetooth stack (comerr)
Could not get data from 2sensor(s): Rihanna, otherplant.

Hi, what kind of credentials you use to connect to api.huahuacaocao.net?

Well, I downloaded the apk for the app and replaced all urls to api.huahua…net with a adress to a local reverse proxy that logged all the requests.

From there I found my login data, can’t remember exactly what it was.

But when I tried to add a probe I got a error stating it was only doable in China…

Sadly I haven’t had any more time to look at this.

Hey there,

im new to the Hassio community =)
My Mi Flora wont get any updates in the Hassio UI…, all values are 0 or unknow.

so first i added

  - platform: miflora
    mac: 'C4:7C:XX:XX:XX:XX'
    name: Pflanze1
    median: 3
    monitored_conditions:
      - moisture
      - light
      - temperature
      - conductivity
      - battery

to the configuration.yaml and restartet, so it showed up in the ui… no updates so far…
than i conneceted throu

gatttoool -b XX:XX:XX:XX:XX -I
connect
to the device:
so it retourned:

Connection successful

Notification handle = 0x0021 value: 00
Notification handle = 0x0021 value: 00
Notification handle = 0x0021 value: 00
[XX:XX:XX:XX:XX:XX][LE]>
(gatttool:6502): GLib-WARNING **: Invalid file descriptor.

it took about 4-5sek to spam the Notfication handle… and when i send the command Primary
i got

attr handle: 0x0001, end grp handle: 0x0009 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0x000f uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x0010, end grp handle: 0x0022 uuid: 0000fe95-0000-1000-8000-00805f9b34fb
attr handle: 0x0023, end grp handle: 0x0030 uuid: 0000fef5-0000-1000-8000-00805f9b34fb
attr handle: 0x0031, end grp handle: 0x0039 uuid: 00001204-0000-1000-8000-00805f9b34fb
attr handle: 0x003a, end grp handle: 0x0042 uuid: 00001206-0000-1000-8000-00805f9b34fb

i enabled the debugmode for the MiFlora sensor and it post this errors in the log:

2017-10-10 11:13:25 DEBUG (SyncWorker_0) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Moisture
2017-10-10 11:13:25 INFO (SyncWorker_0) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx:xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_9) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Conductivity
2017-10-10 11:13:25 INFO (SyncWorker_9) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx:xx:xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_11) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Light intensity
2017-10-10 11:13:25 INFO (SyncWorker_11) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_5) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Temperature
2017-10-10 11:13:25 INFO (SyncWorker_5) [homeassistant.components.sensor.miflora] Polling error [Errno Could not read data from Mi Flora sensor %s] xx:xx:xx:xx:xx
2017-10-10 11:13:25 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Polling data for Pflanze1 Battery
2017-10-10 11:13:35 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.pflanze1_battery is taking over 10 seconds
2017-10-10 11:13:35 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Pflanze1 Battery = 0
2017-10-10 11:13:35 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Data collected: [0, 0, 0, 0]
2017-10-10 11:13:35 DEBUG (SyncWorker_13) [homeassistant.components.sensor.miflora] Median is: 0

so any one an idea how i could fix that?
thanks budys =)

miflora

I have the same problem as friend
Any idea ?

For several releases my logs are filled with

Updating miflora sensor took longer than the scheduled update interval 0:00:30

Although everything works and values are reported correctly - is there any remedy for this?

I’ve been using MiFlora component with 5 sensors. They worked more or less ok before. After upgrading my RPi3 to Stretch and Python 3.5 since HASS 0.55.x, the component doesn’t update sensors which are not close enough to the RPi3 (literally 1-2 meeters). I use integrated bt module on RPi3.

I’ve noticed this too! Must be linked to BT drives though?

I think you need gatttool to work Mi Flora. My system was missing it, so I compiled it. Mi Flora plant sensor

the gatttool binary is part of the bluez package:
a simple

apt-get install bluez

should do the trick

edit: if it is already installed:

apt-get install --reinstall bluez

Yes, gatttool is a part of bluez, but my system was missing it. Reinstall does not add gatttool in my case.

Then the easiest way to get gatttool would be to download the package, unpack it (it’s just a gzipped archive containing two more archives) and copy gatttool from there to /usr/bin
plus I would file a bug report that gatttool is not being installed when installing the bluez package, because if the maintainer doesn’t know, he can’t fix it.

edit: the linked package is for ARM hard float (suitable for e.g. raspis)