Monday, February 20, 2017

SMA Q2 extracting data.

SMA Q2 extracting data.


See my SMA-Q2 first impressions and do-not-disturb-automation blogs about SMA Q2.

SMA Care 

SMA Care app fetches Activity and Sleep data from SMA Q2 watch and store them in SQLITE3 database.

SMA Care:                                         Detailed HR data:                             Detailed Sleep data:     
Data are stored in a very light text based server less database: SQLITE3. 
Sqlite is very popular in android apps because data can be handled with standard SQL commands.
Fast and efficient way to store recurring data.

Place of databases:

You can find SMA Care application files (config files and data) on your Android device root directory: 

/data/data/com.szabh.sma_new/

The databases are here:     /data/data/com.szabh.sma_new/databases























Copy these database files to your SDCard and send to your PC.
I copy databases directory to SDcard with Tasker :



Then I send this directory to my NAS storage server with SCP.
See detailes here.
Copy databases to PC to further export and analysis.

Python for data analysis

Python is very popular language for data analysis.
You will soon understand why?

Database read with Python:

import sqlite3
import pandas as pd
from sqlalchemy import create_engine
db=sqlite3.connect('python/sma/mydb') # data/data/com.szabh.sma_new/databases
engine = create_engine('sqlite:///python/sma/mydb')


Read Table names from Database:

df = pd.read_sql_query('SELECT * FROM sqlite_master WHERE type="table" ', db)df.head(6)                                                                                                                            # List tables in database.


Export all tables to CSV:

tables=['Sport','Sleep','HeartRate','Alarm']
for table in tables:
    df = pd.read_sql_table(table, engine)
    df.to_csv(table+'.csv')

You will find 4 CSV file in your home directory

  • Sport.csv
  • Sleep.csv
  • HeartRate.csv
  • Alarm.csv
for example HR data seems like this:



Sleep data sample:



CSV




I also made data export in python.

df = pd.read_sql_query('SELECT * FROM Sleep WHERE date like "2017-02-18%" ', db)
df.head(5)



Python chart example:




Sunday, February 19, 2017

SMA Q2 - Do Not Disturb - Automation.

SMA Q2 and Do not Disturb Automation.


See my previous blog about SMA Q2.


You need Root access to your device to this!!

Do not Disturb (DnD) is a feature to enable or disable Notifications on watch. 
Watch is vibrate and display when any notification sent from phone to watch.

DnD settings is not available on the watch but can be set in the SMA Care app here:
The settings is unfortunately has no a Broadcast Intent. (you can't call directly) 

Why it is a problem?  Because when you forget to set DnD when go to sleep, then night messages or calls will be vibrate watch and will wake up you.

But DnD setting can be hacked with Tasker (An automation tool for Android) and Secure Settings (Secure Settings is also an android app which access system settings) 

The main principle is to deactivate Notification Listener service for SMA Q2.

What you need:
  1. Root on your device.
  2. Tasker 
  3. Secure Settings.   (as a Tasker plugin.)


  1. Make new Task 1   - name it ex.: SMA_notification_off.

2. Add Plugin - Secure Settings

  • All Action- 
  • System+ Actions
  • Notification Listener.
  • Choose SMA CARE in pull down list.
  • Disabled
  • Save.




3. Make another new (Task 2)   - name it ex.: SMA_notification_on.
    In this task set ENABLED the Notification listener.



4. Set a Tasker Profile.

Add a new Time based Profile in Tasker.
Ex: 21.30 -08:30
       Enter task is the TASK 1 (SMA_notification_off)
       Exit task will be TASK 2 (SMA_notification_on)


Try.

Enjoy.  :)

SMA Q2 - E-paper display watch


SMA Q2 is a Pebble Time like reflective display watch.

(SMA Time also used)


It means display is always on.


Color E-paper (E-ink) like display watch.  Basically it is a color LCD display with a good angle view.

It has lot of potential - depends on Support from SMA - the watch maker company.

Some feature highlights:

  • Always on - don't need back light to see display!
  • 40 days with one charge. (promised by company)
  • HR sensor for Heart Pulse measurement.
  • Accelerator sensor for Activity and Sleep measurements.
  • Vibration notification for any notification. ex: Calls, any notification from any app like messages, email, etc.
  • Back lights.

I can compare to Mi Band 2 because I earlier have that one, and can say it is comparable quality and much more useful because of "LCD" display.

If you have Pebble Time you fill this Q2 is ccomparison lone of that.

Strengths:
Could see the display any time (in any lighted environment)
40 days with one charge.
Cheap 48-55 USD. see Gearbest or Aliexpress.
Watch faces can be changed.
Hack-able in some basic aspect, like
Do not Disturb can be automated (see this DnD related blog) and planed to make blog for
HR and Activity data can be extracted (see sma-q2-extracting-data blog),

Weakness:
No custom watch faces yet! Most of the factory watch faces are ugly, un useful.
No support from company to development or community.
Relative big compared to Mi band 2.

See my comparison video of SMA Q2 to Miband 2

References:
XDA-developers forum
Italian review
Hungarian forum