Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Launch timer on broadcast intent #61

Open
Zocker1999NET opened this issue Oct 24, 2023 · 5 comments
Open

[FR] Launch timer on broadcast intent #61

Zocker1999NET opened this issue Oct 24, 2023 · 5 comments
Labels
new feature New feature

Comments

@Zocker1999NET
Copy link

Zocker1999NET commented Oct 24, 2023

A mechanism allowing third-party apps to launch timers (similar to the schedule) would be really, really helpful (compare to Razeeman/Android-SimpleTimeTracker#11). This could then by triggered by other apps (Automate, Easer, Home-Assistant, …) allowing more advanced schedules.

Context

I want a timer to start when I wakeup (or more certain, a fixed time after that). This app’s scheduling feature is not enough as I wake up every day at a different time, depending on how long I was awake. Changing a schedule everyday is not feasible for me as I will forget that I need to adapt that app as well (sometimes even forget to adapt my alarm). However, my Home-Assistant already knows & detects it when I (want to) wake up (it reads the phone’s alarm, detects longer usage of phone and if I turn on the light). In this case, Home-Assistant could just trigger the timer of TimerMachine by sending an intent broadcast (e.g. my Home-Assistant already triggers time tracking on SimpleTimeTracker in some cases).

PS: I love the customization possibilities of this app ❤️ That’s why I want to integrate it in my daily life with the help of automations.

@DeweyReed
Copy link
Member

The app supports Tasker plugins and events, and they also work for Automate.

@Zocker1999NET
Copy link
Author

Oh, you probably mean the tasker API? I did not know something like that existed in the first place.

I mainly use Home-Assistant for triggering automations on Android, before I used Easer; both do not support that API directly. I won't use Automate & Tasker as those are not open source.

If I understand the API from the doc above correctly, it just uses broadcast intents so it should be possible to trigger it via e.g. Home-Assistant. Is there a docu for this API specific to this app?

@DeweyReed
Copy link
Member

Home-Assistant supports third-party add-ons, but it looks pretty challenging. I don't have a plan supporting this feature.

@DeweyReed DeweyReed closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
@Zocker1999NET
Copy link
Author

(Sorry for the late answer.)

I think we have a misunderstanding: I did not ask for specific support with Home-Assistant. I used Home-Assistant as an example as that is a software which I would like to integrate with this app.

What I mean is that this app could implement specific broadcast intents it listens to which could trigger actions similar to the existing Tasker API. However, instead of the Tasker API, which’s implementation seems closed sourced (or at least not good documented), such a general API would allow users to integrate this app with others (e.g. Easer, Home-Assitant, etc.).

For example, Simple Time Tracker implemented a such API by defining some app-specific broadcast intents it listens to. That API is documented here.

Home-Assistant, on the other hand, implements a general feature allowing users to send broadcast intents via their companion app, documented here.

This allows users to integrate those two apps/services together (e.g. letting Home-Assistant starting the "sleep" activity on the time tracker when I turn off my lights) without both of them providing explicit support for each other (a config example is attached below).
This also allows users to integrate Simple Time Tracker to Tasker or Automate, as those also allow users to send arbitrary broadcast intents. Through the special Tasker API (usage documented here) seems to provide a more user-friendlier way, as Tasker can so list all actions supported by a specific app.

As of now, this app seems to only support the special Tasker API. And as that specific API has no good public documentation (I haven’t found one so far), this does not allow integration with other automation apps. A more general broadcast intent API could provide support for that and (I assume, I might be wrong) should be fairly simple to implement. In case of Simple Time Tracker, it required changes to the manifest and adding a relatively simple broadcast listener; this was the first commit, which also adds a documentation of that API into the app.

I hope this makes my point clear. I accept it if you do not want to implement this yourself, it would be great if you would accept a PR implementing that.

Config Example for Integrating Home-Assistant to Simple Time Tracker

The Simple Time Tracker API looks like this quoted here:

Action - "com.razeeman.util.simpletimetracker.ACTION_START_ACTIVITY" or "com.razeeman.util.simpletimetracker.ACTION_STOP_ACTIVITY".
Extra - "extra_activity_name" with activity name that should be started or stopped.
Package - "com.razeeman.util.simpletimetracker".

Optional parameters for starting activity:
Extra - "extra_record_comment" with record comment.
Extra - "extra_record_tag" with the name of a record tag.

In Home-Assistant, a service call which calls this API may look like this:

# untested config, for demonstration purposes
- service: notify.mobile_app_<your_device_id_here>
  data:
    message: "command_broadcast_intent"
    data:
      # package name of the target app
      intent_package_name: "com.razeeman.util.simpletimetracker.ACTION_START_ACTIVITY"
      # action to trigger
      intent_action: "com.urbandroid.sleep.alarmclock.ALARM_STATE_CHANGE"
      # extra’s as defined by the API (format is a little bit obscure in Home-Assistant)
      intent_extras: "extra_activity_name:Sleeping,extra_record_comment:automatically triggered by Home-Assistant"

@DeweyReed
Copy link
Member

Thank you for the explanation! The app uses the open-sourced Tasker plugin library, although Tasker itself isn't, allowing integration from other automation apps, like Automate.

https://github.com/joaomgcd/TaskerPluginSample

Providing a general broadcast intent to start any timer should be easy, but the tricky part is ensuring the app can start in the background, which is getting harder and harder as Android evolves. I'll look into it and see what I can do.

@DeweyReed DeweyReed reopened this Mar 11, 2024
@DeweyReed DeweyReed added the new feature New feature label Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature
Projects
None yet
Development

No branches or pull requests

2 participants