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

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

Was that the guide you followed - phew ?

uhm… yes? It’s not that hard.

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

1 Like

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?

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

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.

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?

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.

1 Like

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:

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; 

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

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

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” :(.

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

image

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.

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

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?

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!

Will do thanks @vzorglub

Do you know the command to check how large the database is?

… and also, do you export the data to your openhab (basicUI or habPanel)?

When I try to share my graph, I get a link that looks like this:
http://ip:3000/render/d-solo/sOu_M3Zgk/xiaomi-lux-sensors?refresh=1h&orgId=1&panelId=4&from=now-48&to=now&width=1000&height=350&tz=UTC%2B01%3A00

I’m not able to edit it so it works in basicUI - also when using the frame in the habPanel I get the whole graph + the posibility to edit the settings.