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:
- Control — allows other apps to control Dormi monitoring.
- Secret — required to enable control. This secret must be added to intents as an extra String key
secretwhen controlling Dormi. - 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:
MONITORING_START— start monitoring.MONITORING_STOP— stop monitoring.MONITORING_SNOOZE— snooze monitoring for 10 minutes (resets the timer if already snoozed).MONITORING_RESUME— resume monitoring if snoozed.EXPOSE_STATE— request the current state of monitoring, even if Expose is disabled. Add an extra string keytarget_pkgto send the broadcast to a specific app (e.g.,com.llamalab.automatefor Automate,net.dinglisch.android.taskermfor Tasker,io.homeassistant.companion.androidfor Home Assistant Companion). Set it toanyto broadcast system-wide.
Sending intents (except MONITORING_START)
For actions like MONITORING_STOP, MONITORING_SNOOZE, MONITORING_RESUME, and EXPOSE_STATE:
- Create an Intent with action
com.sleekbit.dormi.automation.action.[ACTION_NAME](e.g.,com.sleekbit.dormi.automation.action.MONITORING_STOP). - Set the receiver package to
com.sleekbit.dormito make the intent explicit. - Add the required extra string key
secretwith the value configured in Dormi settings. - Optionally, add an extra string key
tagfor debugging (Dormi will show a toast and log it to logcat). - Set the receiver class to
com.sleekbit.dormi.automation.Control. - 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:
- Create the intent as above, with action
com.sleekbit.dormi.automation.action.MONITORING_START. - 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:
com.sleekbit.dormi.automation.event.MONITORING_STATE_CHANGED— sent on changes in monitoring state, noise detection, or device mode. Extras:monitoring_state(one of "stopped", "starting", "monitoring", "snoozed", "reconnecting"),device_mode("child" or "parent"),noise_detected(true/false).com.sleekbit.dormi.automation.event.CRASH— sent on app crash, no extras.
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
- Create a new Task in Tasker.
- Add a "Send Intent" action.
- Set Action to
com.sleekbit.dormi.automation.action.MONITORING_SNOOZE(replace with desired action). - Set Package to
com.sleekbit.dormi. - Set Class to
com.sleekbit.dormi.automation.Control(for non-START actions). - Add Extra:
secret:your_secret. - Optionally add Extra:
tag:debug_tag. - For MONITORING_START, set Class to
com.sleekbit.dormi.ui.BmActivityinstead. - 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
- Create a new Profile with Event → System → Intent Received.
- Set Action to
com.sleekbit.dormi.automation.event.MONITORING_STATE_CHANGED. - In the linked Task, use variables like
%monitoring_state,%device_mode,%noise_detected(Tasker automatically maps extras to variables). - For crash event, use Action
com.sleekbit.dormi.automation.event.CRASH.
Automate
Controlling Dormi from Automate
- Create a new Flow in Automate.
- Add a "Send Broadcast" block.
- Set Action to
com.sleekbit.dormi.automation.action.MONITORING_STOP(replace as needed). - Set Package to
com.sleekbit.dormi. - Set Receiver to
com.sleekbit.dormi.automation.Control. - Add Extras: key
secretwith valueyour_secret, and optionallytag. - For MONITORING_START, set Receiver to
com.sleekbit.dormi.ui.BmActivity. - Connect and run the flow.
For EXPOSE_STATE, add extra target_pkg:com.llamalab.automate.
Receiving Expose broadcasts in Automate
- Add a "Broadcast Receive" block to your flow.
- Set Action to
com.sleekbit.dormi.automation.event.MONITORING_STATE_CHANGED. - Use output variables to access extras like
monitoring_state,device_mode,noise_detected. - 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.
- In Home Assistant, call the notify service.
- Set
intent_package_name: com.sleekbit.dormi. - Set
intent_class_name: com.sleekbit.dormi.automation.Control(for non-START). - Set
intent_action: com.sleekbit.dormi.automation.action.MONITORING_SNOOZE(replace as needed). - Set
intent_extras: secret:your_secret,tag:ha_debug. - 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.
- Open Home Assistant Companion app on Android.
- Go to Settings → Companion app → Sensors.
- Enable the "Last Update trigger" sensor if not already.
- To receive intents, ensure the app is set up to handle
android.intent_receivedevents. - On the server side, listen for the
android.intent_receivedevent.
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 }}