# Pet Fountain Automation

This document details the automation for the Dockstream Smart RFID Fountain device.

## Overview

The Dockstream Smart RFID Fountain is a smart pet fountain controlled through Home Assistant. A custom automation has been created to toggle the water dispensing mode between constant flow and intermittent flow every 15 minutes. This cycling helps keep the water fresh while reducing energy consumption.

## Fountain Configuration

The Dockstream Smart RFID Fountain has the following settings in Home Assistant:

| Setting | Entity ID | Value | Description |
|---------|-----------|-------|-------------|
| Water Dispensing Mode | `select.dockstream_smart_rfid_fountain_water_dispensing_mode` | Toggles between modes | Controls how water flows |
| Water Interval | `number.dockstream_smart_rfid_fountain_water_interval` | 10 minutes | Time between water dispensing in intermittent mode |
| Water Dispensing Duration | `number.dockstream_smart_rfid_fountain_water_dispensing_duration` | 15 minutes | How long water flows in intermittent mode |
| Cleaning Cycle | `number.dockstream_smart_rfid_fountain_cleaning_cycle` | 14 days | Reminder interval for cleaning |

## Available Modes

The fountain supports two water dispensing modes:

1. **Flowing Water (Constant)** - Water flows continuously
2. **Intermittent Water (Scheduled)** - Water flows according to the interval and duration settings

## Automation Details

The fountain cycling automation is defined in `/etc/nixos/fountain_automation.yaml`:

```yaml
alias: "Fountain Cycle Mode"
description: "Toggles fountain water mode every 15 minutes between constant and intermittent flow"
trigger:
  - platform: time_pattern
    minutes: "/15"  # Every 15 minutes
condition: []
action:
  - service: select.select_next
    target:
      entity_id: select.dockstream_smart_rfid_fountain_water_dispensing_mode
mode: single
id: fountain_cycle_mode
```

### How It Works

1. **Trigger**: The automation runs every 15 minutes based on the time pattern trigger
2. **Action**: It uses the `select.select_next` service to toggle to the next available option
3. **Mode**: Set to "single" to prevent multiple executions if triggers overlap

## Installation

The automation is included in Home Assistant via the `automation manual` directive in the Home Assistant configuration:

```yaml
"automation manual" = "!include_dir_merge_list /etc/hass";
```

The YAML file needs to be placed in the `/etc/hass` directory to be loaded.

## Testing

To manually test the automation:

1. In Home Assistant UI, go to Developer Tools > Services
2. Select `automation.trigger` as the service
3. Enter the following service data:
   ```yaml
   entity_id: automation.fountain_cycle_mode
   ```
4. Click "Call Service" to trigger the automation

## Customizing

To adjust the cycling interval:

1. Edit the YAML file at `/etc/nixos/fountain_automation.yaml`
2. Change the `minutes` value in the trigger section (e.g., from `"/15"` to `"/30"` for every 30 minutes)
3. Save the file
4. Restart Home Assistant or reload automations

To adjust fountain settings:

1. In Home Assistant UI, go to Settings > Devices & Services
2. Find the Dockstream Smart RFID Fountain device
3. Adjust the water interval or dispensing duration settings

## Troubleshooting

If the automation is not working as expected:

1. Check that the entity ID is correct and the fountain is online
2. Verify that Home Assistant is including the automation file correctly
3. Look for errors in the Home Assistant logs related to the automation or the fountain
4. Try manually controlling the fountain to ensure it responds to commands