Update
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
# Home Assistant App Daemon
|
||||
|
||||
A .NET 10 solution that runs a collection of NetDaemon apps for Home Assistant.
|
||||
Each app is a self-contained monitor that observes entity state from Home
|
||||
Assistant, applies business logic, and drives switches / sensors / notifications
|
||||
back into HA via the NetDaemon `IHaContext` and MQTT entity manager.
|
||||
|
||||
## Requirements
|
||||
|
||||
- .NET 10 SDK (see `global.json`; rolls forward to latest major)
|
||||
- A running Home Assistant instance
|
||||
- [NetDaemon](https://netdaemon.xyz) runtime v5 (the `HomeAssistant.Server`
|
||||
project is the binary-deploy host)
|
||||
- A long-lived Home Assistant access token
|
||||
|
||||
## Solution layout
|
||||
|
||||
The solution file is `HomeAssistantSDK.sln`. Projects are grouped by concern:
|
||||
|
||||
### Host / infrastructure
|
||||
|
||||
| Project | Role |
|
||||
|---------|------|
|
||||
| `HomeAssistant.Server` | NetDaemon host. Binary-deploy target that loads all apps. |
|
||||
| `HomeAssistant.Entities` | Generated HA entity metadata + `IEntityManager` abstraction. |
|
||||
| `HomeAssistant.Models` | Shared HA DTOs (`EntityCreateModel`, etc.). |
|
||||
| `HomeAssistant.Infrastructure` | Cross-cutting infrastructure shared by apps. |
|
||||
| `HomeAssistant.McpServer` | MCP server exposing HA tools (entities, history, logbook, services, system). |
|
||||
| `Mappings` | Shared mapping helpers. |
|
||||
|
||||
### Monitor apps
|
||||
|
||||
Every monitor follows the same three-project pattern:
|
||||
|
||||
- `*.Models` — constants, enums, options classes, DTOs
|
||||
- `*.Manager` — business logic, services, and the `[NetDaemonApp]` entry
|
||||
point (`*Init.cs`)
|
||||
- `*.Manager.Tests` — unit tests for the manager
|
||||
|
||||
| Monitor | Entry point | What it does |
|
||||
|---------|-------------|--------------|
|
||||
| **NordPool** | `NordPool.Manager/NordPoolInit.cs` | Fetches Nord Pool spot prices every 15 min, computes cheapest heating intervals, exposes current/next-cheap price. |
|
||||
| **Boiler** | `BoilerMonitor.Manager/BoilerMonitorInit.cs` | Turns the boiler on/off based on cheap intervals, water-ready detection, daily runtime budget, and shower state. |
|
||||
| **Shower** | `ShowerMonitor.Manager/ShowerMonitorInit.cs` | Detects shower state from bathroom vs. home humidity rate and controls the exhaust fan. |
|
||||
| **Power** | `PowerMonitor.Manager/PowerMonitorInit.cs` | Polls the main meter + device sensors, calculates per-device and "other" power, accumulates costs against Nord Pool price, flags anomalies. |
|
||||
| **Light** | `LightMonitor.Manager/LightMonitorInit.cs` | Turns a light on at sunset or when a tracked person arrives home. |
|
||||
| **Battery** | `BatteryMonitor.Manager/BatteryMonitorInit.cs` | Daily scan for low-battery devices and push notification. |
|
||||
| **Leak** | `LeakMonitor.Manager/LeakMonitorInit.cs` | Subscribes to leak sensors and sends/clears alerts on water-detected transitions. |
|
||||
|
||||
### Tooling
|
||||
|
||||
| Project | Role |
|
||||
|---------|------|
|
||||
| `HomeAssistant.HistoryReplay` | Debugging console app that replays real HA history through the monitor business logic with no side effects. See its own [README](HomeAssistant.HistoryReplay/README.md). |
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
dotnet build HomeAssistantSDK.sln
|
||||
```
|
||||
|
||||
## Run tests
|
||||
|
||||
```bash
|
||||
dotnet test HomeAssistantSDK.sln
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
`HomeAssistant.Server` is the NetDaemon binary-deploy target. Build it as a
|
||||
self-contained binary and drop it into your NetDaemon deployment directory.
|
||||
See `HomeAssistant.Server/README.md` for the upstream template notes.
|
||||
|
||||
> **Scoped services:** NetDaemon registers `IHaContext` as scoped. Any app
|
||||
> service that injects `IHaContext` must be registered **scoped** or
|
||||
> **transient**, never singleton, or app load fails with
|
||||
> _"Cannot resolve scoped service … from root provider."_
|
||||
|
||||
## Configuration
|
||||
|
||||
Each monitor reads its options from the NetDaemon host configuration
|
||||
(`appsettings.json` / `appsettings.Development.json`) via
|
||||
`IOptions<*Options>`. Entity IDs, thresholds, and poll intervals are all
|
||||
configurable. See the `*Options` classes under each `*.Models` / `*.Manager`
|
||||
project for the full list of settings.
|
||||
|
||||
Never commit secrets. Use `appsettings.Development.json` (already ignored) or
|
||||
environment variables, using the `__` separator for nested keys.
|
||||
|
||||
## Documentation
|
||||
|
||||
- `docs/` — brainstorm notes, plans, and design docs
|
||||
- `HomeAssistant.HistoryReplay/README.md` — history replay tool
|
||||
- `HomeAssistant.Server/README.md` — NetDaemon host template notes
|
||||
- [NetDaemon docs](https://netdaemon.xyz/docs)
|
||||
|
||||
## License
|
||||
|
||||
Personal project; no license granted for redistribution. See repository
|
||||
history for authorship.
|
||||
Reference in New Issue
Block a user