Python plugin: Xiaomi Mi Flower Mate

Python and python framework
BartS12
Posts: 2
Joined: Friday 13 April 2018 23:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by BartS12 » Friday 13 April 2018 23:47

I'm not sure if it adds a lot of information, but...
- I like the work on this plugin a lot! It opens up the possibility to access the plant data, even when not in range.
- Unfortunately, I do get the exact same error message: "Error: (MiFlower) 'onHeartbeat' failed 'BTLEException'. Also, the toggle switch gets stuck, and the only option is to reset my raspberry pi.

The weird part is that it usually *does* work a few times, and I do get valid data. But after the 3rd/4th time, it crashes.

Although my knowledge on domoticz and python (especially) is rather at the very beginner level, i'd be happy to contribute to some trouble shooting here. Any thoughts about stuff I can try?

madrian
Posts: 238
Joined: Saturday 27 August 2016 1:18
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by madrian » Sunday 15 April 2018 21:03

Instead of switch button why you don't use a push button to refresh?

blauwebuis
Posts: 310
Joined: Wednesday 21 December 2016 10:11
Target OS: Raspberry Pi
Domoticz version: current
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by blauwebuis » Monday 16 April 2018 10:07

The button already works as a push button really. It just switches back to 'off' after it has scanned all the devices.

I built the plugin, and I now also get the BTLE exception error a lot. If it crashes if it can't find the flower sensor, then we might be able to fix that. Thanks for the tip.

BartS12
Posts: 2
Joined: Friday 13 April 2018 23:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by BartS12 » Monday 16 April 2018 11:21

I think it's important to realize that (at least, for me), it *sometimes* works. This points towards certain possibilities (like, sensor is just inside/outside range), and away from other possibilities (like, privileges of the plug-in).

I can try to run the setup with my plant next to my raspberry pi. If the distance is < 1meter, I think we can safely confirm (or rule out) that that is the issue.

To be continued.

madrian
Posts: 238
Joined: Saturday 27 August 2016 1:18
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by madrian » Monday 16 April 2018 19:58

blauwebuis wrote:
Monday 16 April 2018 10:07
The button already works as a push button really. It just switches back to 'off' after it has scanned all the devices.
Thank you, I understand now.

"I built the plugin, and I now also get the BTLE exception error a lot. If it crashes if it can't find the flower sensor, then we might be able to fix that. Thanks for the tip."

This is my second question. One of my sensors is a little bit far away from my bluetooth receiver and sometimes it fails to read. In this case refresh button stays "on" and it's not possible to update anymore.

2018-04-16 19:51:04.991 User: Admin initiated a switch command (102/Xiaomi Flower Mate - Refresh/Off)
2018-04-16 19:51:04.991 MAIN SwitchLightInt : switchcmd=="On" || level < 0, new level:0

Please, add some more error handling and/or timeout function to the plugin.

madrian
Posts: 238
Joined: Saturday 27 August 2016 1:18
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by madrian » Wednesday 18 April 2018 21:01

Or is there any way to reset plugin without need to restart whole domoticz?

bramski
Posts: 30
Joined: Thursday 20 July 2017 16:26
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by bramski » Tuesday 24 April 2018 15:41

Thanks for developing this plugin.
Have the plugin enabled in my domoticz installation, but automatic scanning is failing. I see the following in domoticz logfile:

(Xiaomi Mi Flower) Scan failed

Any suggestions how to debug this further?

huey
Posts: 11
Joined: Tuesday 21 March 2017 21:45
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by huey » Tuesday 24 April 2018 22:53

bramski wrote:
Tuesday 24 April 2018 15:41
(Xiaomi Mi Flower) Scan failed
Can it be you run it as an unprivileged (non root) user? The scanner needs to run as root the script says.

I am not aware of a way to make the plugin run as another user and only the sub module run as root. I think it is not possible due to security constraints (or am I mistaken?)
Guess you can then only use the manual configured mac addresses you found with "hcitool lescan".

Regards.

Danielson
Posts: 2
Joined: Saturday 10 March 2018 10:47
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by Danielson » Friday 04 May 2018 10:04

Any updates on this script? My plants starting to die! :lol:

pumax
Posts: 1
Joined: Monday 14 May 2018 15:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by pumax » Monday 14 May 2018 15:20

Hello,

First of all thanks a lot for this cool plugin :)
I confirm the behavior explained by @bartS12, at around 5 meter of my raspberry, i can't get the data from the sensor but if i move it near to the raspberry (arround 50cm) it's working well.

Are you looking for an update ? :D
Thanks

Frucoboti
Posts: 2
Joined: Thursday 17 May 2018 1:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by Frucoboti » Thursday 17 May 2018 1:22

Hello,

I always get this error:

2018-05-17 01:15:59.613 User: Admin initiated a switch command (693/Huerto - Flip to update Mi Flowermates/Off)
2018-05-17 01:15:59.630 (Huerto) onCommand called for Unit 1: Parameter 'Off', Level: 0
2018-05-17 01:15:59.630 (Huerto) amount of Flower Mates to now ask for data: 1
2018-05-17 01:16:03.050 (Huerto) getting data from sensor: C4:7C:8D:66:14:E2
2018-05-17 01:16:03.058 Error: (Huerto) 'onHeartbeat' failed 'ImportError'.
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 247 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function onHeartbeat
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 99 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function onHeartbeat
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 154 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/plugin.py, function getPlantData
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 103 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/miflora_poller.py, function firmware_version
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 47 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/backends/__init__.py, function __enter__
2018-05-17 01:16:03.058 Error: (Huerto) ----> Line 48 in /home/pi/domoticz/plugins/Mi_Flower_mate_plugin-master/miflora/backends/bluepy.py, function connect

This is on a Rasp3. Bluetooth from raspbian discovers the Mi Flora device, so I supose that Domoticz should discover it too.
I have tested with manual or automatic, with no luck.
When button is pressed turns virtual switch off, and get then the error.

Someone?

Frucoboti
Posts: 2
Joined: Thursday 17 May 2018 1:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Xiaomi Mi Flower Mate

Post by Frucoboti » Thursday 17 May 2018 19:51

Nothing, no reads after 24 hours. I wonder if the Mi Flower must be added to raspbian devices, associated, or it is no needed.

I have read that it is required to "You'll also have to give Python to access Bluetooth trough additional libraries you will need to install.", as said at https://www.domoticz.com/wiki/Mi_Flora_Bluetooth_LE
Not sure what to do or if it not necessary with this method: https://www.domoticz.com/wiki/Plugins/Mi_flower_mate

Thanks

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests