Copyright (c) 2025 the_louie
An AppDaemon app for Home Assistant that automatically controls growth lights based on UV index readings and seasonal time schedules.
- Seasonal Time Control: Different operating hours for summer (June-August) and other months
- UV Index Monitoring: Automatically turns off lights when UV index is 5 or above
- Multiple Switch Support: Control multiple growth light switches simultaneously
- Robust Error Handling: Comprehensive logging and error recovery
- Configurable Parameters: All thresholds and sensors configurable via YAML
- Summer Months (June-August): 06:00 to 18:00
- Other Months: 09:00 to 15:00
- Lights are ON during active hours when UV index is below 5
- Lights are OFF during active hours when UV index is 5 or above
- Lights are OFF outside of active hours regardless of UV index
- If UV sensor is unavailable, lights remain ON during active hours
- Copy
i1_growlights.pyto your AppDaemonappsdirectory - Add the configuration to your
apps.yamlor include theconfig.yamlfile - Restart AppDaemon
grow_lights:
module: i1_growlights
class: GrowLights
# Time-based configuration
off_season_start: "09:00"
off_season_end: "15:00"
on_season_start: "06:00"
on_season_end: "18:00"
# UV index configuration
uv_index_sensor: "sensor.ecowitt_uv"
uv_index_threshold: 5
# Growth light switches to control
switches:
- switch.vaxtlampa
- switch.vaxtlampa_fonster_vast| Parameter | Type | Default | Description |
|---|---|---|---|
uv_index_sensor |
string | required | Home Assistant entity ID of UV index sensor |
uv_index_threshold |
number | 5 | UV index threshold for turning off lights |
switches |
list | required | List of switch entity IDs to control |
off_season_start |
time | "09:00" | Start time for non-summer months |
off_season_end |
time | "15:00" | End time for non-summer months |
on_season_start |
time | "06:00" | Start time for summer months |
on_season_end |
time | "18:00" | End time for summer months |
The app runs the following checks every 10 minutes:
- Determines current season (summer vs other months)
- Checks if current time is within active hours
- If outside active hours, ensures lights are OFF
- If inside active hours, reads UV index and controls lights accordingly
Performance Optimizations:
- Time strings are parsed once at startup for efficiency
- Single datetime call per check cycle
- Minimal state tracking to reduce memory usage
- Early returns prevent unnecessary processing
The app provides comprehensive logging at different levels:
- INFO: Light state changes and important events
- WARNING: UV sensor unavailability
- ERROR: Configuration or operational errors
- DEBUG: Detailed state information
- Graceful handling of sensor unavailability
- Configuration validation on startup
- Exception logging with line numbers
- Fallback behavior when sensors are unavailable
- Home Assistant with AppDaemon
- UV index sensor (e.g., Ecowitt weather station)
- Growth light switches or relays
This project is licensed under the BSD 2-Clause License - see the LICENSE file for details.