Hi,
Is there any way to get average metrics from say a motion detector:
The picture above shows absolute motion ON or OFF but over periods of time a bit less granularity could be useful, more like a busier times and less busier times. The red line hand drawn over it is more or less that.
If this is not really major need, is there a way to get from Domoticz internal DB (or whatever it uses) read values say from last hour and then calculate the average in LUA for example?
I guess what I'm trying to find out is stats rather than time series data. Any suggestions?
Average option
Moderators: leecollings, remb0
- EdddieN
- Posts: 510
- Joined: Wednesday 16 November 2016 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Scotland
- Contact:
Average option
11101101 - www.machinon.com
- PeGe
- Posts: 25
- Joined: Tuesday 31 January 2017 14:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V3.6328
- Location: Sollentuna, Sweden
- Contact:
Re: Average option
Sure! - That database is easily accessible. But you will obviously need to have the "sqlite" package installed, to provide you with the needed commands.... is there a way to get from Domoticz internal DB (or whatever it uses) read values say from last hour ...
The query to retrieve the data can then be executed directly from the command line as follows:
Code: Select all
MyDeviceId=51 # THIS IS THE INDEX NUMBER OF THE DEVICE
MyStartTime=`date -d '1 hour ago' "+%Y-%m-%d %H:%M:%S"`
sqlite3 /home/pi/domoticz/domoticz.db "select nValue, Date from LightingLog where DeviceRowId = $MyDeviceId and Date > '$MyStartTime'"
In my case, as a result of recently having opened and closed a window two times, the output from my "Perimeter intact" switch was:
Code: Select all
0|2017-02-03 12:30:22
1|2017-02-03 12:30:26
0|2017-02-03 12:49:40
1|2017-02-03 12:49:54
I hope this will be of some help to you.
/P-G
- EdddieN
- Posts: 510
- Joined: Wednesday 16 November 2016 11:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Scotland
- Contact:
Re: Average option
Yes it does, also crosslinking from another post here, I think it is relevant too:
https://github.com/dannybloe/dzVents
https://github.com/dannybloe/dzVents
dzVents (|diː ziː vɛnts| short for Domoticz Easy Events) brings Lua scripting in Domoticz to a whole new level. Writing scripts for Domoticz has never been so easy. Not only can you define triggers more easily, and have full control over timer-based scripts with extensive scheduling support, dzVents presents you with an easy to use API to all necessary information in Domoticz. No longer do you have to combine all kinds of information given to you by Domoticzs in many different data tables. You don't have to construct complex commandArrays anymore. dzVents encapsulates all the Domoticz peculiarities regarding controlling and querying your devices. And on top of that, script performance has increased a lot if you have many scripts because Domoticz will fetch all device information only once for all your device scripts and timer scripts.
11101101 - www.machinon.com
Who is online
Users browsing this forum: No registered users and 1 guest