!!!ABGELÖST!!! [74_XiaomiFlowerSens.pm] Xiaomi Flower Monitor

Begonnen von CoolTux, 17 November 2016, 13:25:06

Vorheriges Thema - Nächstes Thema

CoolTux

Zitat von: sash.sc am 16 März 2017, 17:01:21
Heißt wenn ich 3 Pflanzen anlege, dann für jeder Pflanze eigene Grenzwerte.

Gesendet von meinem E6653 mit Tapatalk

Ja genau. Macht ja auch Sinn. Unterschiedliche Pflanzenarten haben unterschiedliche Grenzwerte.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

ToM_ToM

ZitatNaja das kann auch nicht klappen. Aber Du könntest mal versuchen was passiert wenn Du in der Console mit gatttool den Abruf machen willst.

Habe ich gemacht. Hier das Ergebnis:


root@bananapi ~ # gatttool -b C4:7C:8D:61:D6:4B --char-write-req -a 0x33 -n A01F
Characteristic value was written successfully
root@bananapi ~ # gatttool -b C4:7C:8D:61:D6:4B --char-read -a 0x35
Characteristic value/descriptor: aa bb cc dd ee ff 99 88 77 66 00 00 00 00 00 00
root@bananapi ~ #


Mir ist noch was aufgefallen. Ich muss jedes Mal erst ein hcitool lescan ausführen, sonst bekomme ich hier auch die Fehlermeldung No route to host (113)
Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8

CoolTux

Dann wird das beim Modul genau so sein. Mach mal hcitool lescan und lass dann das Modul mal laufen. statusRequest
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

ToM_ToM

ZitatDann wird das beim Modul genau so sein. Mach mal hcitool lescan und lass dann das Modul mal laufen. statusRequest
Das hatte ich auch schon probiert, aber hilft leider auch nicht.

Zusätzlich habe ich das jetzt mal direkt aus FHEM gemacht:
{system('hciconfig hci0 reset')}
{system('timeout 5s hcitool lescan')}

Sensor bekommt immer noch den Status "unreachable", aber dafür sieht das Log schon etwas vielversprechender aus:

2017.03.16 17:57:43 4: Sub XiaomiFlowerSens_Run (Pflanze_01) - start blocking call
2017.03.16 17:57:43 4: Sub XiaomiFlowerSens_BlockingRun (Pflanze_01) - Running nonBlocking
2017.03.16 17:57:43 5: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - WFR: 1
2017.03.16 17:57:45 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 1
2017.03.16 17:57:45 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: Characteristic value was written successfully

2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - run gatttool
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 1
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 2
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 3
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 4
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 5
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 6
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 7
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 8
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 9
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 10
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - processing gatttool response. sensData[0]: connect
2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - processing gatttool response. sensData: Device or resource busy (16)

2017.03.16 17:57:46 4: Sub XiaomiFlowerSens_BlockingRun (Pflanze_01) - Processing response data: Device or resource busy (16)
Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8

CoolTux

Er kann gatttool genau einmal ausführen, immer genau nach einem hcitool lescan

Hast Du noch andere Bluetoothsachen über den Stick laufen? presence oder sowas?
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

CoolTux

Guten Morgen,

Ich habe da noch ein wenig nachgebessert. Es gibt nun auch zu jedem minWert einen maxWert den man angeben kann


attr Pflanze1 minMoisture 35


    • minFertility - min fertility value befor low warn event
    • minFertility - max fertility value befor high warn event
    • minMoisture - min moisture value befor low warn event
    • minMoisture - max moisture value befor high warn event
    • minTemp - min temperature value befor low warn event
    • maxTemp - max temperature value befor high warn event

Es gibt keine Readings. Nur Events für low,high und ok.
Beispiel:

2017-03-16 11:08:05 XiaomiFlowerSens Pflanze1 minMoisture low
2017-03-16 11:08:06 XiaomiFlowerSens Pflanze2 maxTemp high
2017-03-16 11:08:07 XiaomiFlowerSens Pflanze2 minFertility ok

Es macht natürlich nur Sinn ein Notify entsprechend dem minEvent auf low oder dem maxEvent auf high triggern zu lassen.


Ich teste diese Version die Tage und werde sie dann als Version 1.0.0 frei geben.
Wer möchte kann die Version aus dem Git testen. Zu finden im Devel Branch


Desweiteren habe ich nun ssh Funktion implementiert. Sobald das Attribut sshHost gesetzt ist, wird versucht gatttool auf dem entfernten Host aus zu führen. Da ich das nicht testen kann wäre ich an Informationen interessiert.
WICHTIG: ssh muss für Zertifikatsauthentication konfiguriert sein.




Grüße
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

ToM_ToM

ZitatEr kann gatttool genau einmal ausführen, immer genau nach einem hcitool lescan

Hast Du noch andere Bluetoothsachen über den Stick laufen? presence oder sowas?

Hallo CoolTux,

nein, ich habe sonst nichts weiter per Bluetooth laufen. Hatte den Bluetooth Dongle extra nur für den Pflanzensensor gekauft.
Interessant ist ja, dass wenn ich das ganze über FHEM vorher starte:
{system('hciconfig hci0 reset')}
{system('timeout 5s hcitool lescan')}

dass ich dann zumindest mal nicht mehr die Fehlermeldung ...no Route to Host... erhalte.

Nochmal zu meine System zum Abgleich:
Hardware: BananaPi (Cortex A7 Dual Core, 1024MB RAM)
Bluetooth-Dongle: Asus USB-BT400
OS: Debian 8 Jessie
FHEM: FHEM 5.8
Bluez: Bluez 5.43

Bluez habe ich selbst heruntergeladen, kompiliert und installiert:

cd /home
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.43.tar.xz
tar xvf bluez-5.43.tar.xz
cd bluez-5.43
./configure --enable-library --disable-systemd
make
make install


Evtl. habe ich irgendeinen wichtigen Punkt vergessen...?
Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8

MadMax-FHEM

Zitat von: CoolTux am 17 März 2017, 09:26:41
Desweiteren habe ich nun ssh Funktion implementiert. Sobald das Attribut sshHost gesetzt ist, wird versucht gatttool auf dem entfernten Host aus zu führen. Da ich das nicht testen kann wäre ich an Informationen interessiert.
WICHTIG: ssh muss für Zertifikatsauthentication konfiguriert sein.


Super! Danke!

Werde ich mal testen, komme aber wohl erst am So dazu...

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

ToM_ToM

Hey CoolTux,

ich habe mir jetzt mal die Mühe gemacht und nochmal einen zweiten Pi mit FHEM installiert (diesmal allerdings der Raspberry Pi Zero).
Und hier funktioniert alles wie erwartet. Somit kann der Sensor als Fehlerquelle ausgeschlossen werden.
Das Problem muss also irgendwo an meiner Bluetooth-Konfiguration liegen.
Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8

CoolTux

Zitat von: ToM_ToM am 17 März 2017, 20:08:26
Hey CoolTux,

ich habe mir jetzt mal die Mühe gemacht und nochmal einen zweiten Pi mit FHEM installiert (diesmal allerdings der Raspberry Pi Zero).
Und hier funktioniert alles wie erwartet. Somit kann der Sensor als Fehlerquelle ausgeschlossen werden.
Das Problem muss also irgendwo an meiner Bluetooth-Konfiguration liegen.

Dann schlage ich vor Du deinstallierst noch mal Dein bluez. Wenn ich Dich richtig verstanden habe hast Du es selbst compiliert. Hoffe Du hast das Verzeichnis noch. Dann einfach da rein gehen und make uninstall eingeben. ALS root.
Und dann am besten das Original deb Packet installieren.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

ToM_ToM

ZitatDann schlage ich vor Du deinstallierst noch mal Dein bluez. Wenn ich Dich richtig verstanden habe hast Du es selbst compiliert. Hoffe Du hast das Verzeichnis noch. Dann einfach da rein gehen und make uninstall eingeben. ALS root.
Und dann am besten das Original deb Packet installieren.

Habe ich gemacht, aber geht leider immer noch nicht. Fehler sind immer noch die Gleichen. Eieiei das kostet mich vielleicht Nerven....
Ich bin leider auch nicht der Linux Guru um zu wissen wie ich das jetzt noch lösen könnte.  :o
Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8

ToM_ToM

So,

habe jetzt nochmal ein Backup-Image vom Februar eingespielt wo ich noch nichts mit Bluetooth gemacht habe.
Dann bluez wieder per apt-get install bluez installiert, Pi neu gestartet und die Fehler sind dennoch die Gleichen
Beim set statusRequest kommt wieder folgender Fehler:

2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_Run (Pflanze_01) - start blocking call
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_BlockingRun (Pflanze_01) - Running nonBlocking
2017.03.17 21:35:58 5: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - WFR: 1
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 1
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 2
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 3
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 4
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 5
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 6
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 7
2017.03.17 21:35:58 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 8
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 9
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 10
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: connect: No route to host (113)

2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - run gatttool
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 1
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 2
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 3
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 4
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 5
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 6
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 7
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 8
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 9
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 10
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - processing gatttool response. sensData[0]: connect
2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - processing gatttool response. sensData: No route to host (113)

2017.03.17 21:35:59 4: Sub XiaomiFlowerSens_BlockingRun (Pflanze_01) - Processing response data: No route to host (113)



Führe ich vor dem set statusRequest folgenden Befehl aus
{system('timeout 5s hcitool lescan')}

bekomme ich wieder diese Meldung:
2017.03.17 21:36:41 4: Sub XiaomiFlowerSens_Run (Pflanze_01) - start blocking call
2017.03.17 21:36:41 4: Sub XiaomiFlowerSens_BlockingRun (Pflanze_01) - Running nonBlocking
2017.03.17 21:36:41 5: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - WFR: 1
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charWrite loop 1
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - charWrite wresp: Characteristic value was written successfully

2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - run gatttool

2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 1
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 2
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 3
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 4
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 5
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 6
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 7
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 8
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 9
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - call gatttool charRead loop 10
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - processing gatttool response. sensData[0]: connect
2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_callGatttool (Pflanze_01) - processing gatttool response. sensData: Device or resource busy (16)

2017.03.17 21:36:43 4: Sub XiaomiFlowerSens_BlockingRun (Pflanze_01) - Processing response data: Device or resource busy (16)


So langsam gehen mir die Ideen aus.  :-\
Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8

CoolTux

Sag mal kann es sein das der erwähnte Pi Zero der neue ist mit Bluetooth? So das Du Dein Stick nicht umstecken musstest?
Denn wenn ja denke ich es liegt am Stick.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

CoolTux

#508
Ich habe es endlich mal geschafft mein Sensor richtig ein zu richten.


Internals:
   BTMAC      C4:7C:8D:62:42:6F
   CFGFN
   DEF        C4:7C:8D:62:42:6F
   INTERVAL   14400
   NAME       Dracaena
   NR         527
   STATE      Feuchtegehalt: 33 %, Düngegehalt: 400 us/cm, Temperatur: 18.2 °C
   TYPE       XiaomiFlowerSens
   VERSION    0.9.11
   Helper:
     Dblog:
       Batterylevel:
         Logdb:
           TIME       1489801340.02213
           VALUE      92
       Temperature:
         Logdb:
           TIME       1489830240.07502
           VALUE      18.2
   Readings:
     2017-03-18 10:44:00   battery         ok
     2017-03-18 10:44:00   batteryLevel    92
     2017-03-18 10:44:00   fertility       400
     2017-03-18 10:44:00   firmware        2.9.2
     2017-03-17 09:03:48   lastGattError   Unknown Error, look at verbose 5 output
     2017-03-18 10:44:00   lux             226
     2017-03-18 10:44:00   moisture        33
     2017-03-18 10:44:00   state           active
     2017-03-18 10:44:00   temperature     18.2
   Helper:
Attributes:
   comment    moisture min 35
   disabledForIntervals 22:00-06:00
   event-on-change-reading .*
   group      Pflanzen
   interval   14400
   maxFertility 2000
   maxMoisture 60
   maxTemp    35
   minFertility 500
   minMoisture 25
   minTemp    12
   room       Wohnzimmer
   stateFormat Feuchtegehalt: moisture %, Düngegehalt: fertility us/cm, Temperatur: temperature °C
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

ToM_ToM

ZitatSag mal kann es sein das der erwähnte Pi Zero der neue ist mit Bluetooth? So das Du Dein Stick nicht umstecken musstest?
Nein, das ist noch der erste ohne WLAN und Bluetooth.

Ich installiere gerade nochmal einen komplett neuen BananaPi um herauszufinden ob es am Bananian liegt.
Hardware: BananaPi, Busmaster CUL, SanDisk 16GB Ultra SD, 16 GB USB-Stick | Software: Armbian, FHEM 5.8