4.0 KiB
Executable File
Home Assistant Automations
This document details the automations configured in the Home Assistant setup.
Automation Types
Automations in this configuration are managed in several ways:
- Module-Based Automations: Defined in Nix modules within the
modules/nixos/homeassistant/automations/directory - YAML Automations: Defined in YAML files and included via the
automation manualdirective - UI-Created Automations: Created through the Home Assistant UI and stored in
automations.yaml
Module-Based Automations
Light Switch Automations
Location: modules/nixos/homeassistant/automations/lightswitch/
These automations link physical light switches to smart lights:
- Bedroom Light Switch: Controls the bedroom lights
- Living Room Light Switch: Controls the living room lights
- Bedroom Closet Lights: Controls the closet lights
Motion-Activated Light Automations
Location: modules/nixos/homeassistant/automations/motion-light/
These automations turn lights on when motion is detected and off after a period of inactivity.
YAML Automations
Fountain Cycling Automation
Location: /etc/nixos/fountain_automation.yaml
This automation toggles the water dispensing mode on the Dockstream Smart RFID Fountain every 15 minutes:
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
This automation:
- Triggers every 15 minutes
- Uses the
select.select_nextservice to toggle between the two available options:- "Flowing Water (Constant)"
- "Intermittent Water (Scheduled)"
The fountain is also configured with:
- Water Interval: 10 minutes
- Water Dispensing Duration: 15 minutes
Creating New Automations
Method 1: Module-Based Automation
For reusable, complex automations that should be managed in code:
- Create a new directory in
modules/nixos/homeassistant/automations/ - Create a
default.nixfile with the automation logic
Example:
{ config, lib, ... }:
{
config = {
services.home-assistant.config."automation manual" = [
{
alias = "Example Automation";
description = "Example automation created via Nix module";
trigger = [
{
platform = "state";
entity_id = "binary_sensor.example_sensor";
to = "on";
}
];
action = [
{
service = "light.turn_on";
target.entity_id = "light.example_light";
}
];
mode = "single";
}
];
};
}
Method 2: YAML Automation
For simpler automations:
- Create a YAML file with the automation definition
- Place it in
/etc/hass/
Example:
alias: "Example Automation"
description: "Example automation in YAML"
trigger:
- platform: state
entity_id: binary_sensor.example_sensor
to: "on"
action:
- service: light.turn_on
target:
entity_id: light.example_light
mode: single
Method 3: UI Creation
For quick prototyping or simple automations:
- Go to Home Assistant UI > Settings > Automations & Scenes
- Click "+ Add Automation"
- Configure using the UI editor
Testing Automations
To test an automation:
- In the Home Assistant UI, go to Developer Tools > Services
- Select
automation.triggeras the service - Enter the entity_id of your automation in the service data field
- Click "Call Service" to trigger the automation manually
Troubleshooting
If an automation isn't working as expected:
- Check the Home Assistant logs for errors
- Verify entity names and service calls are correct
- Test individual triggers and actions separately
- Use the "Debug" section in the automation editor to trace execution