Automation

Integrate Dormi with Tasker, Automate, Home Assistant, and more

Introduction

Dormi's Automation feature allows seamless integration with third-party automation apps such as Tasker, Automate, and Home Assistant. This enables you to control Dormi's monitoring functionality externally and expose Dormi's state to other apps for advanced automation workflows.

Automation is managed through three options in the Dormi app settings:

  1. Control — allows other apps to control Dormi monitoring.
  2. Secret — required to enable control. This secret must be added to intents as an extra String key secret when controlling Dormi.
  3. Expose — exposes Dormi's monitoring state to other apps via broadcasts.

Automation relies on Android Intents and broadcasts. You can send intents to Dormi to control it (via the Control feature) or receive broadcasts from Dormi about its state (via the Expose feature).

Control

Use other apps to control Dormi by sending intents. The available actions are:

Sending intents (except MONITORING_START)

For actions like MONITORING_STOP, MONITORING_SNOOZE, MONITORING_RESUME, and EXPOSE_STATE:

  1. Create an Intent with action com.sleekbit.dormi.automation.action.[ACTION_NAME] (e.g., com.sleekbit.dormi.automation.action.MONITORING_STOP).
  2. Set the receiver package to com.sleekbit.dormi to make the intent explicit.
  3. Add the required extra string key secret with the value configured in Dormi settings.
  4. Optionally, add an extra string key tag for debugging (Dormi will show a toast and log it to logcat).
  5. Set the receiver class to com.sleekbit.dormi.automation.Control.
  6. Send or broadcast the intent.

If sent as an ordered broadcast, Dormi responds with a result code (Activity.RESULT_OK for success, Activity.RESULT_CANCELED for failure) and a short message.

Special handling for MONITORING_START

For privacy and Google Play policy compliance, starting monitoring requires user visibility. Send the intent to the main activity:

  1. Create the intent as above, with action com.sleekbit.dormi.automation.action.MONITORING_START.
  2. Send it to the main activity class com.sleekbit.dormi.ui.BmActivity.

This starts a countdown timer, notifies the user, and allows abortion of the action.

Example using ADB

adb shell am broadcast \
  -a com.sleekbit.dormi.automation.action.MONITORING_SNOOZE \
  -n com.sleekbit.dormi/.automation.Control \
  --es secret your_secret \
  --es tag test123
adb shell am broadcast \
  -a com.sleekbit.dormi.automation.action.EXPOSE_STATE \
  -n com.sleekbit.dormi/.automation.Control \
  --es secret your_secret \
  --es target_pkg any \
  --es tag test955

Expose

When enabled, Dormi broadcasts events for other apps to consume:

The "reconnecting" state is parent-mode specific, indicating a lost connection where the child device's state is unknown until reestablished.

Integration Examples

Tasker

Controlling Dormi from Tasker

  1. Create a new Task in Tasker.
  2. Add a "Send Intent" action.
  3. Set Action to com.sleekbit.dormi.automation.action.MONITORING_SNOOZE (replace with desired action).
  4. Set Package to com.sleekbit.dormi.
  5. Set Class to com.sleekbit.dormi.automation.Control (for non-START actions).
  6. Add Extra: secret:your_secret.
  7. Optionally add Extra: tag:debug_tag.
  8. For MONITORING_START, set Class to com.sleekbit.dormi.ui.BmActivity instead.
  9. Save and run the task.

For EXPOSE_STATE: add Extra target_pkg:net.dinglisch.android.taskerm to target Tasker specifically.

Receiving Expose broadcasts in Tasker

  1. Create a new Profile with Event → System → Intent Received.
  2. Set Action to com.sleekbit.dormi.automation.event.MONITORING_STATE_CHANGED.
  3. In the linked Task, use variables like %monitoring_state, %device_mode, %noise_detected (Tasker automatically maps extras to variables).
  4. For crash event, use Action com.sleekbit.dormi.automation.event.CRASH.

Automate

Controlling Dormi from Automate

  1. Create a new Flow in Automate.
  2. Add a "Send Broadcast" block.
  3. Set Action to com.sleekbit.dormi.automation.action.MONITORING_STOP (replace as needed).
  4. Set Package to com.sleekbit.dormi.
  5. Set Receiver to com.sleekbit.dormi.automation.Control.
  6. Add Extras: key secret with value your_secret, and optionally tag.
  7. For MONITORING_START, set Receiver to com.sleekbit.dormi.ui.BmActivity.
  8. Connect and run the flow.

For EXPOSE_STATE, add extra target_pkg:com.llamalab.automate.

Receiving Expose broadcasts in Automate

  1. Add a "Broadcast Receive" block to your flow.
  2. Set Action to com.sleekbit.dormi.automation.event.MONITORING_STATE_CHANGED.
  3. Use output variables to access extras like monitoring_state, device_mode, noise_detected.
  4. For crash, use the CRASH action.

Home Assistant

Integrate with Home Assistant Companion app on Android for remote control and state exposure.

Controlling Dormi from Home Assistant (remote control)

Use the notify.mobile_app_[your_device] service with message: command_broadcast_intent to send intents remotely.

  1. In Home Assistant, call the notify service.
  2. Set intent_package_name: com.sleekbit.dormi.
  3. Set intent_class_name: com.sleekbit.dormi.automation.Control (for non-START).
  4. Set intent_action: com.sleekbit.dormi.automation.action.MONITORING_SNOOZE (replace as needed).
  5. Set intent_extras: secret:your_secret,tag:ha_debug.
  6. For MONITORING_START, set intent_class_name: com.sleekbit.dormi.ui.BmActivity.

Example YAML for a button in Lovelace:

type: button
name: Snooze Dormi
tap_action:
  action: call-service
  service: notify.mobile_app_your_device
  data:
    message: command_broadcast_intent
    data:
      intent_package_name: com.sleekbit.dormi
      intent_class_name: com.sleekbit.dormi.automation.Control
      intent_action: com.sleekbit.dormi.automation.action.MONITORING_SNOOZE
      intent_extras: "secret:your_secret,tag:ha_snooze"

Receiving Expose broadcasts in Home Assistant Companion

Configure the Companion app to receive broadcasts and forward them to the server.

  1. Open Home Assistant Companion app on Android.
  2. Go to Settings → Companion app → Sensors.
  3. Enable the "Last Update trigger" sensor if not already.
  4. To receive intents, ensure the app is set up to handle android.intent_received events.
  5. On the server side, listen for the android.intent_received event.

Example YAML automation to parse the event and create sensors:

automation:
  - alias: Parse Dormi State
    trigger:
      - platform: event
        event_type: android.intent_received
        event_data:
          action: com.sleekbit.dormi.automation.event.MONITORING_STATE_CHANGED
    action:
      - service: input_text.set_value
        data:
          entity_id: input_text.dormi_monitoring_state
          value: "{{ trigger.event.data.extra_monitoring_state }}"

sensor:
  - platform: template
    sensors:
      dormi_state:
        friendly_name: "Dormi Monitoring State"
        value_template: "{{ states('input_text.dormi_monitoring_state') }}"

binary_sensor:
  - platform: template
    sensors:
      dormi_noise_detected:
        friendly_name: "Dormi Noise Detected"
        value_template: >
          {{ trigger.event.data.extra_noise_detected == 'true'
             if trigger else false }}