Showing posts with label tasker. Show all posts
Showing posts with label tasker. Show all posts

Monday, March 19, 2018

Spreadsheet Tasker Plugin

I collect various types of data on my phone such as sleep data using Tasker. Traditionally, I've saved the data to a local file on my phone (typically a csv) and then used an app to transfer that data file to Google Drive.

I recently found a Tasker plugin app called Spreadsheet Tasker Plugin that will communicate directly with a Google spreadsheet. This approach is much easier.

In the case of my sleep data, each time I complete a sleep instance, it adds a row to a Google sheet with the data.

I have my phone set up via Tasker to start a sleep instance when the phone is oriented face-down and end the sleep instance when it no longer orients face down. I have a timer built in so that it only records the data after 30 minutes to avoid accidental downward orientations or instances where I haven't fallen asleep yet.

The paid version offers off-line buffering which stores the data if you aren't connected until a connection is made.

Google Play Store: Spreadsheet Tasker Plugin

Saturday, December 28, 2013

Freezing Temp Alert

I created an alert on my phone to tell me when the temperature outside drops below freezing. Since I don't have my own network accessible thermometer, I am using the wunderground api to query the closest weather station, a couple of miles away. It should be close enough.

I used this blog post as a guide for accessing the wunderground api:  http://www.pocketables.com/2012/07/tasker-task-that-speaks-the-weather-forecast-download.html

I set up a wunderground developer account here: http://www.wunderground.com/weather/api/

In Tasker:

The profile runs every hour.

The task is as follows:

A1: HTTP Get [ Server:Port:api.wunderground.com Path:/api/[mykey]/conditions/q/[my state abbrev]/[the town or neigborhood with the station I wanted to query].xml Attributes: Cookies: Timeout:10 Mime Type:text/plain Output File: ]

A2: Variable Set [ Name:%wunderresults To:%HTTPD Do Maths:Off Append:Off ]

A3: Variable Search Replace [ Variable:%wunderresults Search:\<temp\_f\>\d\d.\d\<\/temp\_f\> Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%matchedtemp Replace Matches:Off Replace With:a ]

A4: Variable Search Replace [ Variable:%matchedtemp1 Search:\d\d.\d Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%matchedtemptwo Replace Matches:Off Replace With: ]

A5: Variable Set [ Name:%oakbrookTemp To:%matchedtemptwo1 Do Maths:Off Append:Off ]

A6: Flash [ Text:%myTemp Long:Off ]

A7: If [ %myTemp < 33 ]

A8: Notify [ Title:Temperature Warning Text:%myTemp Icon:hd_alerts_and_states_warning Number:0 Permanent:Off Priority:3 ]



I had to do some parsing gymnastics to get the temperature out of the xml returned from wunderground (actions 3 and 4).

I also have the temp display on a MimialistText widget so I can see the temp anytime, not just when it's freezing.

Saturday, December 7, 2013

Initial Sleep Analysis

This is my first post sharing my initial analysis of my sleep data. I've collected data for two months now using Tasker on my Android phone. It collects the start and end date/time of each sleep period as well as why I woke up.

I've just started using R and love it. Here is the first graph showing the total number of hours slept each night. Weekends are colored red because I wanted to know if I slept better on the weekends (it doesn't seem to matter).

Here is the graph:
(click to view)
I had a few days in November where my tasker action didn't save all the sleep intervals. On those days, I added estimate data. I may remove those dates altogether. There may be other dates that are incomplete. I have a could of days with less than four hours and I can't remember if that is correct or not. That probably has an impact on the dip in sleep duration in November.

Generally, I am getting more sleep that I expected, averaging around 6.5 to 7 hours per night.

Next I need to factor in the number of sleep segments to come up with a measurement of sleep quality (greater duration and fewer segments represents better sleep). I also need to consider why I woke up. If I was interrupted by an alarm, for example, and that cut my sleep shorter than it would have been naturally, it's not necessarily fair to treat that as a dependent variable when considering factors that affect sleep quality.

Here is the R Script I used (via RStudio):
library(methods) 
library(lubridate)

sleep <- read.csv("C:/Users/xxxxxxx/Documents/R/Sleep/sleepdata.csv", header=T)

sleep["EndDate"] <- NA

sleep$EndDate <- ifelse(sleep$EndTime > 12, format(mdy(as.character(sleep$Date)) + days(1), format="%m-%d-%Y"), format(mdy(as.character(sleep$Date)), format="%m-%d-%Y"))  #fill column with date of the morning of each sleep period

sleep["Weekday"] <- NA

sleep$Weekday <- weekdays(mdy(sleep$EndDate))  #fill column with weekday of the sleep period

sleep  #display data in case I want to review

dailytotals <-unique(within(sleep, {
  Duration <- ave(Duration, EndDate, FUN=sum)rm(Date,StartTime,EndTime,Status)
}))  #create frame, one record per day with total number of hours slept

dailytotals  #display in case I want to review

ggplot(dailytotals, aes(x=EndDate, y=Duration, group=1, colour=Weekday)) +
  geom_point() +  #plot points on graph
  stat_smooth(level=.99) + #regression/curve line with 99% certainty range
  theme(axis.text.x = element_text(angle = 90), axis.title.x = element_text(angle = 0), axis.title.y = element_text(angle = 0)) +  #labels, turn x axis vertically
  scale_color_manual(values=c(Saturday="red", Sunday="red", Monday="blue", Tuesday="blue", Wednesday="blue", Thursday="blue", Friday="blue"))  #color code weekend days

Friday, November 29, 2013

AutoRemote and Linux

I successfully paired Raspberry Pi with two android devices via AutoRemote.

I used the instructions here http://joaoapps.com/autoremote/linux/ but was getting an invalid key error. This is because I was trying to use the personal url rather than the personal key. The difference is explained here: http://joaoapps.com/autoremote/personal/ .

I set these connections up using the internal IP but will try to add registrations using a public IP so I can control from anywhere. I'll need to set up port fowarding in my router. I'll also need to come up with the best way to always know my home public IP.

I also successfully sent commands from my phone to the RPi.
  • sudo halt
  • aplay [filepath]

Sunday, November 24, 2013

EventGhost

Just installed EventGhost. I've been starting to investigate how to use EventGhost, AutoRemote, and Tasker to control the PC from an Android device.

More to come.



Resources:

Tuesday, November 19, 2013

AutoRemote, AutoLocation, AutoVoice

I have purchased and started playing with three plug in apps for Tasker created by João Dias.
  • AutoVoice
  • AutoRemote
  • AutoLocation
Info on these plugins can be found here.

Friday, November 1, 2013

Sleep Data - Getting Started

Occasionally, I have trouble sleeping. The most common issue is waking up in the middle of the night, typically around 2am, and having trouble getting back to sleep.

There are lots of variables that could impact my sleep and rather than just guessing, I wanted to start collecting my actual sleep times and other events that could impact sleep. Then I can look for potential causal relationships.

I've been using Tasker on my Android phone to collect sleep data. When I turn the phone face down, it sets that time to a variable. Then when the phone is picked up (and it's been more than 1/2 hour), a dialog asked why I woke up. Then it records the date, time, duration, and reason to a new line in a csv file on the phone. That file is synced once a day to my Google Drive so I can work further with it.

I also have a Tasker dialog that allows me to collect events that could affect sleep such as caffine, stress, nap, etc. That records the date, time, and reason to another csv file.

I've started to learn how to use R, a statistics programming language/environment, to analyze the data but still very early in that process. Specifically, I've been using R Studio.