GithubHelp home page GithubHelp logo

goldfndr / tasker-habitrpg Goto Github PK

View Code? Open in Web Editor NEW
33.0 7.0 11.0 39 KB

A base for interacting with Habitica via Tasker

License: GNU General Public License v3.0

JavaScript 100.00%
tasker habitrpg habitica javascript

tasker-habitrpg's Introduction

tasker-habitrpg

A base for interacting with Habitica's API via Tasker

Installation

  1. After downloading the files, edit HabitRPGfns.js to match your API values (note the API Token like a password warning!) and CDS. Note that you'll need to uncomment them (remove the // at the beginning of the three setGlobal lines).

  2. In your /sdcard/Tasker directory, create a JavaScript directory. (You'll probably find other directories here, like log and userguide.)

  3. Copy the edited HabitRPGfns.js file to your newly created /sdcard/Tasker/JavaScript directory. If you hadn't edited it yet, you could paste the values in from the mobile app (see Settings/Account Details). After you confirm it's operational, you can recomment or delete those lines. New versions of HabitRPGfns.js will have them commented out.

  4. Optionally import the example tasks. Copy them somewhere (e.g. /sdcard/Tasker/tasks) then, within Tasker, Import. The files need to end with ".tsk.xml" to be listed.

For the example task check done, you'll need to change the Variable Set %taskid action to use one of your own values. I suggest cloning this task (long-press name, menu, Clone) to avoid confusion, or you could import again.

score a task now supports Task ID and direction as parameters (%par1 and %par2), you can simply use it by adding to your personal task the "Perform Task" action: specify the "score a task" task and insert the Task ID into parameter 1 and (optionally) direction into parameter 2.

An easy method to find a Task's ID is to use the User Data Display's Task Overview with "toggle developer data". A cumbersome alternative method is the following.

  1. Login to HabitRPG from Chrome or Firefox.
  2. Open the Developer Tools (press F12 or Ctrl+Shift+I).
  3. Choose the Network tab.
  4. Sync.
  5. Select the "user?userV=number" request.
  6. In the Preview (Chrome) or Response (Firefox) subtab, expand data.
  7. For Chrome, find the text you seek, expand the task's entry. For Firefox, expand objects until you find the text you seek.
  8. The "id" has the value you'll use for the Variable Set %taskid action.

NOTE: All task IDs from V2 have changed in V3 so values will need to be corrected. Thanks to API V3 reporting success as true or false, you'll be alerted if you use an invalid ID.

HabitRPGfns.js is commented with each operation's inputs; use %result (string) or %results (array, e.g. %results2 and %results3) as appropriate for your actions' parameters.

Example 1

Create a profile that, within a Time context, runs once a day (From equals To), with a task of get streaks. No more wondering what the heck your streaks were after you accidentally didn't login for a couple of days!

Example 2

Create a profile that, within a Time context, runs periodically in the day (repeats), with a task of check due (e.g. every half hour from 11:33 after CDS to 0:33 after CDS). A permanent reminder (with count) of your remaining dailys! Note that there may be a very limited amount of space to display the list (wider in landscape); AutoNotification is one way to display more.

Example 3

Create a profile that, within a Time context, runs periodically in the day (repeats), with a cloned task of check done (with %taskid specifically set). A permanent reminder to do your daily! Optionally add a location context if your daily can't be completed everywhere.

Example 4

If there's a specific daily you often forget to perform or check off, you can easily create a widget with a tap shortcut of "Perform task" action with score a task, and a profile with time context that periodically does a cloned check done with actions to change the widget's image and/or label depending on task completed (rather than notify). This functionality is included with Tasker, but you can use Zooper Widget or Minimalistic Text or other plugins for further customization.

Example 5

Using tasker "Perform Task" action with InitChecklist (in conjunction with NextQuestion and score a task-checklist) and passing a tag name as the first parameter (%par1) , you can run a notification based checklist that prompts you with tasks (dailies, habits and to-dos) with that tag. This way you can tag all your morning / evening routine habits and be sure to be reminded when the time comes.

Useful tips

Variable Search Replace [ Variable:%result Search::[\w]+: *Multi-Line:*Off *One Match Only:*Off Store Matches In: *Replace Matches:*On Replace With: ]

  • Display the result but only in the Tasker UI (not elsewhere). Handy for testing.

Popup [ Text:%result ] If [ %caller1 ~ ui ]

  • Clear all Tasker-generated notifications. Handy for testing. (From the main screen's menu: More, Run An Action.)

Notify Cancel

  • For a periodic (time context with repeat) profile, make sure you can actually reach the HabitRPG server.

Test Net [ *Type:*Connection Type Store Result In:%contype ]
Stop [ Task: ] If [ %contype ~ none ]

Planned features

  • function: replace emoji short-names with Android emoji (Kit Kat/4.4 or newer preferred)
  • task: prune streaks-all to a limited count
  • scene: add a task; spinners
  • scene: augment above to store while offline, sync when getting online (possibly premium)

Credits

Apologies

The term "task" is used by both Tasker (one or more actions) and HabitRPG (habit or daily or to-do or reward). I hope the contexts above disambiguate adequately, but please create an issue (or pull request) if something needs fixing.

tasker-habitrpg's People

Contributors

goldfndr avatar sanzoghenzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

tasker-habitrpg's Issues

getting the tagID and the tasks by tag is broken.

When getting the tasks by a tag, tasker says that isn't a function "filter" for get_all_tags. So, getting the tagID and the tasks by tag is broken.

I tried to solve it but I don't know enough JS.

Score a task reporting failure even though ID is correct

Task scoring is coming up with a message about the scoring failing, even though I have repeatedly checked the ID and verified it to be correct. Further, Habitica itself is granting me the relevant changes (task value, gold, XP). So... as far as I can tell, the process is thinking the ID is wrong whether it is or not?

Change daily tasks get_due to use server's isDue property

Currently, the get_due function expects all daily tasks to be have frequency=weekly. That is, the days of the week (within repeat) are true/false depending on whether the task is due that particular weekday.

But, since 6/11/2015, Habitica has changed to also accept frequency=daily with an everyX value corresponding to an interval and a startDate (in ISO 8601 format) for when the every X started. Obviously, this requires new code to handle it, and converting ISO 8601 to something more usable (like seconds since epoch) is nontrivial.

The User Data Display Tool handles this by including:
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
and using Moment.js to check the date for due-ness.

It would be preferable to handle this by on-demand loading if possible, as only the get_due function would use this functionality and it would be slightly cumbersome to require moment.js (or moment.min.js) be specified in the JavaScript action as a Library (and that's assuming that loading it as a library would even work).

on challenge task looks not working

if i give the id of challenge task is creating a new task with the id as the task name instead of scoring the challenge task.
With no challenge task is working good.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.