> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opencompany.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Android Automation

> Control Android devices via ADB or remote relay

# Android Automation

MachinaOs can control Android devices for automation tasks like launching apps, monitoring battery, controlling WiFi, and more.

## Connection Methods

| Method           | Use Case                                    |
| ---------------- | ------------------------------------------- |
| **Local ADB**    | Device connected via USB to your machine    |
| **Remote Relay** | Device connected via WebSocket relay server |

## Set Up Connection

Android device connection is configured in the **Credentials Modal** (Android panel), not via a workflow node. Open Credentials and pick one of the two methods below.

### Option A: Local ADB

1. Enable **Developer Options** on your Android device
2. Enable **USB Debugging**
3. Connect device via USB
4. Run `adb devices` to verify connection
5. In the Credentials Modal, open the **Android** panel and choose **Local ADB** (ADB port forwarding is set up for you)

### Option B: Remote Relay

1. Open the **Credentials Modal** and select the **Android** panel
2. Click **Connect** to start the relay connection
3. Scan the QR code with the companion Android app to pair your device

<Info>
  Remote relay allows controlling devices anywhere with internet access. The relay uses a two-state model: `connected` (relay WebSocket is up) versus `paired` (a device has scanned the QR and is ready to run actions). Android nodes require a **paired** device to execute.
</Info>

## Available Android Nodes

MachinaOs ships 16 Android service nodes across monitoring, apps, automation, sensors, and media. Each one can run as a standalone workflow node or be connected to an AI agent's tools handle.

### System Monitoring

| Node            | Description                                 |
| --------------- | ------------------------------------------- |
| Battery Monitor | Battery level, charging status, temperature |
| Network Monitor | WiFi/cellular status, internet connectivity |
| System Info     | Device model, Android version, memory       |
| Location        | GPS coordinates, accuracy, provider         |

### App Management

| Node         | Description                 |
| ------------ | --------------------------- |
| App Launcher | Launch apps by package name |
| App List     | Get installed applications  |

### Automation

| Node                 | Description                           |
| -------------------- | ------------------------------------- |
| WiFi Automation      | Enable/disable WiFi, scan networks    |
| Bluetooth Automation | Toggle Bluetooth, list paired devices |
| Audio Automation     | Volume control, mute/unmute           |
| Device State         | Airplane mode, brightness, screen     |
| Screen Control       | Wake screen, timeout settings         |
| Airplane Mode        | Airplane mode status and control      |

### Sensors

| Node                  | Description                               |
| --------------------- | ----------------------------------------- |
| Motion Detection      | Accelerometer, gyroscope, shake detection |
| Environmental Sensors | Temperature, humidity, pressure, light    |

### Media

| Node          | Description                  |
| ------------- | ---------------------------- |
| Camera        | Take photos, get camera info |
| Media Control | Playback control, volume     |

## Example: Battery Alert Workflow

Create a workflow that sends an alert when battery is low.

### Workflow Design

```
[Cron Scheduler] --> [Battery Monitor] --> [Python Executor] --> [WhatsApp Send]
                                               (check level)
```

### Step 1: Add Cron Trigger

```
Cron Expression: */10 * * * *  (every 10 minutes)
```

### Step 2: Add Battery Monitor

```
Action: Get Status
```

### Step 3: Add Python Executor

```python theme={null}
battery_level = input_data.get("level", 100)
is_charging = input_data.get("is_charging", False)

if battery_level < 20 and not is_charging:
    output = {
        "alert": True,
        "message": f"Battery low: {battery_level}%"
    }
else:
    output = {"alert": False}
```

### Step 4: Add WhatsApp Send (conditional)

```
Phone Number: +1234567890
Message: {{pythonExecutor.message}}
```

## Example: App Launcher Workflow

Launch an app when receiving a webhook.

```
[Webhook Trigger] --> [App Launcher]
```

**App Launcher Config:**

```
Package Name: {{webhookTrigger.body.app}}
```

**Test:**

```bash theme={null}
curl -X POST http://localhost:3010/webhook/launch \
  -H "Content-Type: application/json" \
  -d '{"app": "com.spotify.music"}'
```

## Example: WiFi Toggle

```
[Webhook Trigger] --> [WiFi Automation]
```

**WiFi Automation Config:**

```
Action: {{webhookTrigger.body.action}}
```

**Test:**

```bash theme={null}
# Enable WiFi
curl -X POST http://localhost:3010/webhook/wifi \
  -d '{"action": "enable"}'

# Disable WiFi
curl -X POST http://localhost:3010/webhook/wifi \
  -d '{"action": "disable"}'
```

## Battery Monitor Output

```json theme={null}
{
  "level": 85,
  "is_charging": true,
  "status": "charging",
  "plugged": "ac",
  "temperature": 28.5,
  "health": "good",
  "technology": "Li-ion"
}
```

## Network Monitor Output

```json theme={null}
{
  "is_connected": true,
  "type": "wifi",
  "wifi_ssid": "MyNetwork",
  "is_internet_available": true,
  "ip_address": "192.168.1.100"
}
```

## Troubleshooting

<Accordion title="Device not showing in dropdown">
  * Run `adb devices` to check connection
  * Ensure USB debugging is enabled
  * Try different USB cable/port
  * Restart ADB: `adb kill-server && adb start-server`
</Accordion>

<Accordion title="Remote relay won't connect">
  * Verify relay URL is correct
  * Check API key is valid
  * Ensure companion app is installed on device
  * Check firewall settings
</Accordion>

<Accordion title="Commands fail with permission error">
  * Some actions require root access
  * Use device automation apps for restricted features
  * Check Android version compatibility
</Accordion>

## Tips

<Tip>
  Start with Battery Monitor and System Info to verify your connection works before building complex workflows.
</Tip>

<Tip>
  Use meaningful node names (F2 to rename) when building workflows with multiple Android nodes.
</Tip>

## Next Steps

<CardGroup cols={2}>
  <Card title="Android Node Reference" icon="mobile" href="/nodes/android">
    Full documentation for all 16 Android nodes
  </Card>

  <Card title="Webhooks" icon="webhook" href="/nodes/webhooks">
    Trigger Android actions via HTTP
  </Card>
</CardGroup>
