A .NET service for scheduling and automating time-based activities with Home Assistant integration.
Kronos.Service is a hosted service application built on .NET that provides reactive scheduling capabilities. It's designed to control and automate devices connected to Home Assistant based on time-based schedules.
- Reactive Scheduling: Built on System.Reactive (Rx.NET) for efficient event-driven scheduling
- Home Assistant Integration: Direct control of Home Assistant entities and automation
- Hosted Service Architecture: Runs as a console-hosted service with proper lifecycle management
- Configurable Schedules: Define time-based Boolean schedules for automation tasks
- Tick-based Processing: Regular interval-based checking and execution of scheduled items
The service consists of several key components:
- SchedulerHostedService: Core service that processes scheduled items on regular intervals
- IScheduleProvider: Provides collection of scheduled items to execute
- ITimeProvider: Reactive time provider for schedule evaluation
- IHomeAssistantControl: Interface for controlling Home Assistant devices
- ScheduledBoolean: Framework for defining time-based Boolean states
- .NET Core: Cross-platform service framework
- Reactive Extensions (Rx.NET): For reactive, event-driven scheduling
- Microsoft.Extensions.Hosting: Hosted service infrastructure
- Microsoft.Extensions.DependencyInjection: Dependency injection container
- Microsoft.Extensions.Logging: Structured logging
src/
├── Kronos.Service/ # Main hosted service application
├── Kronos.Framework.Schedule/ # Scheduling framework and abstractions
└── Kronos.Scratch/ # Development and testing playground
The service uses appsettings.json for configuration:
{
"Logging": {
"LogLevel": {
"Default": "Information"
}
}
}dotnet build Kronos.Service.slncd src/Kronos.Service
dotnet run- Service initializes with dependency injection container
- Schedule provider loads configured scheduled items
- Hosted service starts with 1-second tick interval
- On each tick, scheduled items are evaluated against current time
- When schedule conditions are met, Home Assistant control actions execute
- Service continues until stopped
- Automated heating/cooling schedules
- Light automation based on time of day
- Timed device control
- Smart home scheduling
- Energy management automation
- System.Reactive
- Microsoft.Extensions.Hosting
- Microsoft.Extensions.Logging
- Microsoft.Extensions.DependencyInjection
- Microsoft.Extensions.Configuration
This project follows clean architecture principles with clear separation between:
- Service hosting (Kronos.Service)
- Business logic (SchedulerHostedService)
- Domain framework (Kronos.Framework.Schedule)
- External integrations (IHomeAssistantControl)