The Away Manager app (AwayManager.cs) handles home/away state detection and orchestrates all related automations when the house is occupied or vacant.
- Vincent's Presence: Primary person detection via device tracker
- Guest Detection: Secondary person (Timo) presence monitoring
- Vacation Mode: Override for extended away periods
- Smart State Management: Prevents rapid state changes
- Security Measures: Activates security-related automations
- Media Control: Turns off all media players and TVs
- Energy Saving: Optimizes energy consumption
- Notification System: Sends departure confirmation
- Lighting Scene: Activates appropriate lighting based on time of day
- Welcome Message: Personalized greeting announcement
- Pet Food Alert: Checks if pet food needs refilling
- System Restoration: Restores normal operational modes
- 15-Second Delay: Welcome message delayed to allow settling in
- State Stabilization: Prevents automation conflicts during transitions
- Context-Aware Messages: Different greetings based on house state
private void SetupPresenceDetection()
{
// Primary person (Vincent) presence detection
Entities.Person.VincentMaarschalkerweerd
.StateChanges()
.Where(x => x.Entity.State == "home" && !_backHome)
.Subscribe(_ => BackHome());
// Away detection (both Vincent and Timo away, or vacation mode)
var awayCondition = Entities.Person.VincentMaarschalkerweerd
.StateChanges()
.Where(x => Globals.AmIHomeCheck(Entities))
.Subscribe(_ => SetAwayMode());
}private void BackHome()
{
var houseState = Globals.GetHouseState(Entities);
// Send phone notification
NotifyVincentPhone(houseState);
// Set appropriate lighting scene
SetLightScene(houseState);
_backHome = false;
// Delayed welcome message (15 seconds)
Scheduler.Schedule(_config.Timing.WelcomeHomeDelay, () =>
{
var message = "Welkom thuis Vincent!";
if (Entities.Sensor.ZedarFoodStorageStatus.State != "full")
message += " Het eten van Pixel is bijna op!";
Notify.NotifyHouse("welcomeHome", message, true);
});
}private void SetAwayMode()
{
// Turn off all media players
TurnOffMediaPlayers();
// Send departure notification
Notify.NotifyPhoneVincent("Tot ziens", "Je laat je huis weer alleen :(", true);
// Set away state
Entities.InputBoolean.Away.TurnOn();
// Additional security and energy-saving measures
ActivateSecurityMode();
}- Person Trackers:
person.vincent_maarschalkerweerd,person.timo - Away State:
input_boolean.away - Vacation Mode:
input_boolean.onvacation - House Mode:
input_select.housemodeselect - Pet Food Status:
sensor.zedar_food_storage_status
The system relies on device presence detection:
- Phone GPS: Primary location tracking
- WiFi Connection: Secondary presence confirmation
- Network Devices: Router-based device detection
public class TimingConfiguration
{
public TimeSpan WelcomeHomeDelay { get; set; } = TimeSpan.FromSeconds(15);
}- Vincent Leaves β Device tracker shows "not_home"
- Away Check β System verifies both Vincent and Timo are away (or vacation mode)
- Away Mode Activated β All away automations trigger
- Media Shutdown β TVs and media players turn off
- Notification Sent β "Tot ziens" message to Vincent's phone
- Security Active β Away-related security measures activate
- Vincent Arrives β Device tracker shows "home"
- Welcome Sequence β Immediate phone notification sent
- Lighting Scene β Appropriate lights turn on based on time of day
- Delayed Message β 15-second delay before welcome announcement
- Pet Check β Food level checked, alert if low
- State Reset β Away mode deactivated, normal operations resume
- Timo Present β Secondary person detection
- Vincent Away β Primary person not home
- No Away Mode β House remains in "home" state
- Limited Automation β Some automations may behave differently
- Vacation Activated β Manual override for extended absence
- Extended Away β Different automation behavior for long periods
- Security Enhanced β Additional security measures during vacation
- Energy Optimization β Extended energy-saving modes
Welcome home lighting adapts to current house state:
- Morning: Bright, energizing lighting
- Day: Standard daytime lighting levels
- Evening: Warm, relaxing ambiance
- Night: Minimal lighting to avoid disruption
private void NotifyVincentPhone(HouseState houseState)
{
var greeting = houseState switch
{
HouseState.Morning => "Goedemorgen Vincent!",
HouseState.Day => "Welkom thuis!",
HouseState.Evening => "Goedenavond Vincent!",
HouseState.Night => "Welkom thuis (stil aan, het is laat!)",
_ => "Welkom thuis Vincent!"
};
Notify.NotifyPhoneVincent("Thuis", greeting, priority: true);
}- Food Level Check: Automatic check of pet food status
- Low Food Alert: Included in welcome message if food is low
- Pet Device Status: Monitors pet-related devices during away periods
private bool _backHome; // Prevents rapid state changes- State Coordination: Works with central house state system
- Time-Based Behavior: Different actions based on time of day
- Mode Awareness: Respects current house operational mode
- Away Security: Activates enhanced security monitoring
- Motion Alerts: Different motion detection behavior when away
- Door/Window Monitoring: Enhanced monitoring during away periods
- Automatic Shutdown: Turns off all entertainment devices
- Power Saving: Reduces standby power consumption
- Welcome Restoration: Can restore previous media states
- Arrival Prediction: Learn typical arrival patterns
- Preparation Automation: Pre-activate systems before arrival
- Energy Optimization: Smart pre-heating/cooling based on arrival times
- Long-term Away: Different behavior for multi-day absences
- Maintenance Mode: Reduced automation activity during extended away
- Security Enhancement: Escalated security measures for long absences
- Guest Detection: Different behavior when guests are present
- Privacy Mode: Reduced monitoring when guests are home
- Guest Notifications: Different welcome messages for different people