Xiaomi Aqara Human Motion Sensor - how to get graph working?

openhab2
xiaomi
Tags: #<Tag:0x00007fd310205478> #<Tag:0x00007fd3102051f8>

(Mr. Yoinkz) #1

Hi all,

I know there are some guides and posts regarding other subjects than Xiaomi’s and how to set up graphs.
… and yes - I did try to follow some of the guides, but I just can’t seem to get it working :disappointed_relieved: So I’m reaching out for some of the people that uses the Xiaomi Sensors and uses the graphs in the habpanel.

What I’m trying to achieve is of course to learn how to set up a graph based on values from a sensor.
Right now I wan’t a nice graph to show the values of the LUX measured for the last 3 days or so.

Have anyone had luck setting up something like that with the Xiaomi gear?

Thanks :slight_smile:


(Elias Hackradt) #2

I got like 10 Xiaomi devices, and I graph them with Grafana. I think there is also a tutorial how to add graphs from grafana to habpanel


(Mr. Yoinkz) #3

Was that the guide you followed - phew ?


(Elias Hackradt) #4

uhm… yes? It’s not that hard.

Also it’s a step by step guide. It’s really just read, copy, paste…


(Mr. Yoinkz) #5

Oh okay, will give it a try.

I’m using a Rpi3, so I should jump to those instructions.

How about the performance, does the graph software use a lot and will it be too much for the pie?


(Elias Hackradt) #6

I run it on a Pi3B, performance wise it’s all good.


(Mr. Yoinkz) #7

Hey BrutalBirdie,

So when I’m done doing this: InfluxDB+Grafana persistence and graphing what is the next step. It says I need to go back to the First Post, but is that “InfluxDB Installation and Setup”? Because if I go to that post is says I need to follow the instructions https://docs.influxdata.com/influxdb/v0.13/introduction/installation but in here I can’t find anything related to openHAB and I’m a bit insecure of what to chose.


(Mr. Yoinkz) #8

So I think it got up and running.

Grafana is showing up fine and I’m about to see how I can get some information from my Xiaomi Sensors. I played a bit around, but so far no luck.

I did add the gLux which I’ve added on my Aqara Sensor at the:

Items {
    gLux*   : strategy = everyChange, everyHour
}

But I’m uncertain of how to setup the diagram.
@BrutalBirdie, can you perhaps share your Grafana configuration on the Xiaomi Sensor?


(Elias Hackradt) #9

I am uncertain what you struggle with.
Is it the Setup of a Row in Grafana?
Is it the setup of the query for the Row ? Like that ?

Maybe you should check the InfluxDB yourself to see if Data is stored.


(Mr. Yoinkz) #10

How do I check that?

So far I didn’t have too much luck.
I do get the list with all my sensors that are a part of the gLux group, but it just don’t show any values:

… and here is the Xiaomi Aqara sensor I’m trying to get the Lux values from:


(Elias Hackradt) #11

Could you please post the content of your influxdb.persist ? (Is the file named like that? if not openHAB will not store anything)
Also you have the “default” Data Source set. Is InfluxDB your Default Data Source?
I selected InfluxDB explicit.

How to check if data is inside the InfluxDB.

// connect to the local database
influx --username 'root' --password 'myPreciousRing'
// show all databases
show databases;
// my case the name is openhab_db, select the database
use openhab_db;
// show what tables exists
show series;
// or
show measurements;
// show values from a specific table
select * from itemName; 

(Ward) #12

I use Grafana with MariaDB. Is there a reason to use influxdb instead of MariaDB/MySQL?
I tried influxdb once, but I found it hard to view the data in this database. Creating graphs is easier then with MySQL. Are there eg ways to manupalute data (edit incorrect values), backup/migrate etc…?


(Elias Hackradt) #13

I have one openHAB instance with over ca. 50 Devices that Monitor every 2 sec. the environment. And with that many data-points MySQL grew fast! I made a test for 1 month with both MySQL and InfluxDB.
MySQL grew about 1GB and Influx just around 450MB.
There is much more options why to choose just read this for example. https://db-engines.com/en/system/InfluxDB%3BMongoDB%3BMySQL


(Mr. Yoinkz) #14

Hi @BrutalBirdie,

My influxdb.persist file is located under: /etc/openhab2/persistence/influxdb.persist (and is named as written)
The file contains:

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
}

Items {
        gLux*           : strategy = everyChange, everyHour
        gTemp*          : strategy = everyChange, everyHour
}

My Data Source should be as far as I can see to the InfluxDB:

image

When I connect to the influxdb and runs the show series / measurements i get this:

> use openhab_db;
Using database openhab_db
> show series;
key
---
Garage_MotionSensorLux_Battery
Garage_MotionSensorLux_BatteryLow
Garage_MotionSensorLux_Illumination
Garage_MotionSensorLux_LastMotion
Garage_MotionSensorLux_MotionStatus
Garden_Driveway_MotionSensorLux_Battery
Garden_Driveway_MotionSensorLux_BatteryLow
Garden_Driveway_MotionSensorLux_Illumination
Garden_Driveway_MotionSensorLux_LastMotion
Garden_Driveway_MotionSensorLux_MotionStatus
Garden_Driveway_MotionSensorLux_MotionTimer
Garden_Front_MotionSensorLux_Battery
Garden_Front_MotionSensorLux_BatteryLow
Garden_Front_MotionSensorLux_Illumination
Garden_Front_MotionSensorLux_LastMotion
Garden_Front_MotionSensorLux_MotionStatus
Garden_Front_MotionSensorLux_MotionTimer
Garden_Front_Road_MotionSensorLux_Battery
Garden_Front_Road_MotionSensorLux_BatteryLow
Garden_Front_Road_MotionSensorLux_Illumination
Garden_Front_Road_MotionSensorLux_LastMotion
Garden_Front_Road_MotionSensorLux_MotionStatus
Garden_Front_Road_MotionSensorLux_MotionTimer
Hobbyroom_HT_Temperature
Hobbyroom_MotionSensorLux_Battery
Hobbyroom_MotionSensorLux_BatteryLow
Hobbyroom_MotionSensorLux_Illumination
Hobbyroom_MotionSensorLux_LastMotion
Hobbyroom_MotionSensorLux_MotionStatus
Hobbyroom_MotionSensorLux_MotionTimer

So I see the same units as I do when I click at the “From” field in the GUI of Grafana.

When I then run the: select * from Hobbyroom_MotionSensorLux_Illumination I get this (so it looks like it is getting some values):

name: Hobbyroom_MotionSensorLux_Illumination
time                value
----                -----
1520262000046000000 2
1520265167168000000 0
1520265600160000000 0
1520269200152000000 0
1520272800115000000 0
1520274960933000000 2
1520276400028000000 2
1520280000135000000 2
1520281563666000000 0
1520283600120000000 0
1520284865880000000 2
1520287200080000000 2
1520288165834000000 0
1520290800151000000 0
1520294400058000000 0
1520298000077000000 0
1520298067453000000 2
1520301600118000000 2
1520305200120000000 2
1520307970513000000 0
1520308800112000000 0
1520312400099000000 0
1520316000138000000 0
1520317874090000000 2
1520318424186000000 0
1520319600093000000 0
1520323200055000000 0
1520326800126000000 0
1520327761300000000 2
1520330400118000000 2
1520334000155000000 2
1520334363142000000 24

Did that help a bit?

I just don’t get anything on the “Graph” :(.


(Vincent Regaud) #15

In the graph set-up click the mean value and select distinct() instead

image


(Vincent Regaud) #16


(Mr. Yoinkz) #17

Hey @vzorglub,

Will give it a try. My Xiaomi Sensors it set to do pollingInterval=6000 , but I’m uncertain if this is in seconds or what it is. I can’t fint that in the documentation and haven’t changed it.


(Vincent Regaud) #18

Looking at the timestamps in your database, you have values coming in every hour
Extend the time of the graph as well and you should start to see something


(Mr. Yoinkz) #19

YIBEEE!!!

Now we are talking :). Now I just have to learn to tweak them so they look nice.
In your example? What settings did you use?


(Vincent Regaud) #20

I only changed the line thickness I think to 2.
Just play around, you can’t break it!
And if you mess up too much, start again a fresh graph.
There are lots of options, play!