Xiaomi Mi Plants Monitor Flower

Im having the same issue, im think im going to change to Hassbian instead seems like you have more options to fiddle around in the os there…

I love the idea of hassio (docker and all) but its to locked down…

Edit: I’m using raspberry pi 3 not Zero W, so i guess you might not have the exact same problem that i have…

1 Like

I could be wrong, but I think BLE isn’t working on Pi Zero W with Hassio, yet. The documentation says that the BT add-on is for Pi 3. When I add BT device tracker to config it works perfect on Pi Zero. When I switch to BLE device tracker the Pi Zero won’t even load Hassio on reboot. Adding logger entries for Miflora to configuration.yaml shows that it’s just never connecting. I hooked it up to a phone and even small moisture adjustments sync super fast, so the device is working great but BLE on Pi Zero W just isn’t connecting with it.

But, yeah, SSH is locked down too much for most current users and I’m guessing someone will write a fully functional SSH plugin in a month or two for Hassio and full BLE support for Pi Zero W pretty soon, too. It’s crazy how many highly skilled people are donating so many hours to this great project :wink: It’s the best product out there and it’s free!!! [FWIW forum won’t let me put a dot in Hassio]

1 Like

Someone already got this working with macOS? Got an error that the polling got no data.

Thank you all for the great work you did in making this sensor work for Home assistant!

I came along a few weeks ago and installed the Miflora sensor, scanned and found the MAC addresses of the sensors and installed them all in HA. I even activated an automation that waters plants in my greenhouse based on the moisture sensor data.

I few day ago I also activated Homebridge to get HA values into my iOS and Siri routines. I even got data from these sensors into the Home app and Siri reports them. But it’s only temperature and lux values, not moisture nor conductivity.

Does anybody have an idea to why?

Maybe the home app doesn’t support those measurements? A workaround may be to put them in a template sensor.

Good evening! I just did a fresh installation of hassbian on my Pi3 and ran into some issues with pairing with my Flower sensor. In my previous installation things worked fine and I got data from the sensor. The difference with my fresh installation is that i installed Flic smart bluetooth buttons (with this installation process: Install Flic - #4 by Schmidij_ch). The buttons are working perfectly, so the Bluetooth is obviously working. However, then when I try to find and pair with the sensor I can’t find anything.

When I run “hcitool scan” in the terminal i get this:

Scanning …
Inquiry failed: Device or resource busy

I then tried:

bluetoothctl
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# scan on
No default controller available

I saved the mac-address from my precious installation, but it does not help to just add it with the regular config-lines

sensor: 
    - platform: miflora
      mac: 'XX:XX:XX:XX:XX:XX'
      name: Mr Avocado
      force_update: false
      median: 1
      monitored_conditions:
        - moisture
        - light
        - temperature
        - conductivity
        - battery

Any ideas?

Is the flower sensor paired with your phone while you try to access it from hass? If so, it won’t work to communicate with it.

Thanks for the response!

Of course, this is why. But how to add that functionality?
There is a list of supported types from HA that goes into Homebridge settings. The standard HA settings include: climate and sensor (which one would imagine would suffice).

I tried adding the value type of moisture into the Homebridge settings and restarted, but nothing changes. Automatically Homebridge includes temperature and light intensity from the Mi Flora.

I found a working wrapper for BLE in macOS, can scan my devices and found the Mi Flora. One problem, can program python, so don’t know how to begin and use it for the poller of the mi flora.

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??

@Peke 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.