An example of automating modes with AppDaemon to set suitable lights using the Lightwand AppDaemon app and automate other entities and appliances based on presence.
- Morning/Night Mode Triggers: Uses presence, time, and sensor triggers to automatically switch between
normal,morning, andnightmodes. - Vacation Mode: Prevents day to day mode changes when a user-defined
input_boolean.vacationis active. - Door Lock Integration: Supports MQTT-based door locks (e.g., Nimly) for auto-locking when no adults are home or during nighttime.
- Vacuum Cleaner Automation: Triggers vacuum cleaners when no adults are home and stops them if an adult returns.
- Alarm Notifications: Sends alerts via
notify_receiverwhen sensors are triggered (e.g., open windows, motion) and no one is home. - Customizable Schedules: All times and thresholds are configurable for flexibility.
- Morning routine: Defining
country_codeis now optional and app will not try to find location based on Appdaemon config. Lack of doing so will fire morning mode every day.
- Lightwand translations: App now uses Lightwand translations singleton. This requires at least one app with Lightwand version 2.0.0 or later running on your system. Check out https://github.com/Pythm/ad-Lightwand?tab=readme-ov-file#-translating-or-changing-modes on how to use your own mode names.
- MQTT Namespace Update: Default MQTT namespace changed to
'mqtt'to align with AppDaemon defaults.
- Spelling Correction: Changed
notify_recieverβnotify_receiver.
Install the required packages using requirements.txt
-
If you run Appdaemon as a Addon in HA you'll have to specify the python packages manually in configuration in the Addon and restart Appdaemon.
-
If your Appdaemon install method does not handle requirements automatically:
pip install -r requirements.txt-
Clone the repository into your AppDaemon
appsdirectory:git clone https://github.com/Pythm/ad-ModeManagement.git /path/to/appdaemon/apps/
-
Configure the app in your AppDaemon
.yamlor.tomlfile:manageModes: module: modeManagement class: ModeManagement country_code: 'NO' vacation: input_boolean.vacation notify_receiver: - mobile_app_my_phone
π‘ Tip: Default values are used if parameters are omitted in the configuration.
- Vacation Mode: Prevents day to day mode changes from app when
input_boolean.vacationis active. - Holiday Detection: Define
country_codeto fetch holidays. This will set normal automation instead of morning mode during hollidays and weekends. If not defined, app will call morning mode every day. - LightβMode Display β Use a Home Assistant input_text helper configured with (
HALightModeText) to show the current Light mode.
Note
If a light in Lightwand does not contain morning mode, the normal automation is automagically controlling your light.
| Role | Description | DoorβLock / Vacuum Behaviour |
|---|---|---|
| adult | Primary role. If no adults are home and a doorβlock is configured, the door will lock and relock; vacuums will start. | |
| kid | Keeps doors locked and starts vacuum if only kids are home. | |
| family | Extended family; behaves like an adult except does not start vacuum when leaving. | |
| housekeeper | Switches Light mode to wash and notifies you when the housekeeper arrives while no one else is home. |
|
| tenant | Not used at the moment; please make a request if you need behaviour for tenants. |
β οΈ Safety note β Mqtt door lock will be rewritten to better support id, and only unlock if enabled as a option.
You can automatically start and stop a vacuum cleaner when a person with the adult role leaves or returns home.
| Feature | Description |
|---|---|
| Battery monitoring | If the vacuum entity doesnβt expose a battery level, you can point to a separate battery sensor. |
| Custom start routine | Configure daily_routine with an entity that triggers the vacuum (e.g., a button or switch). |
vacuum:
- vacuum: vacuum.roborock_s8
battery: sensor.roborock_s8_battery # optional β only if the vacuum entity lacks a battery attribute
daily_routine: button.daily_clean # the entity that starts the cleaning job
prevent_vacuum:
- media_player.tv # the vacuum will not start if this entity reports "on"- The list under
prevent_vacuumcontains entities that act as gatekeepers. - If any of those entities reports a state of
on, the automation will skip starting the vacuum.
TIP β Use any entity that can report
on/off(switches, media players, sensors, etc.) to control the start condition.
- Configure
notify_receiverwith a list of devices (e.g.,mobile_app_your_phone). - You can use a custom notification app instead with
notify_appthat contains thesend_notificationfunction.
| Key | Type | Default | Description |
|---|---|---|---|
country_code |
country_code | (optional) | Country code for your location to find hollidays |
vacation |
input_boolean | input_boolean.vacation |
Input boolean to prevent mode changes during vacation. |
HALightModeText |
input_text | (optional) | Input text to display current light mode. |
notify_receiver |
list | (optional) | List of devices to send notifications to (e.g., mobile_app_your_phone). |
MQTT_namespace |
string | "mqtt" |
MQTT namespace (optional). |
HASS_namespace |
string | "default" |
Home Assistant namespace (optional). |
morning_start_listen_time |
string | "06:00:00" |
Time to start listening for morning sensors. |
execute_morning_at |
string | "10:00:00" |
Time to execute morning mode. |
morning_to_normal |
string | "09:00:00" |
Time to switch to normal mode after morning. |
night_start_listen_time |
string | "22:00:00" |
Time to start listening for night sensors. |
execute_night_at |
string | "02:00:00" |
Time to execute night mode. |
delay_before_setting_away |
int | 0 |
Optional delay in seconds before setting away mode when no one is home. |
keep_mode_when_outside |
input_boolean | input_boolean.keep_mode |
Prevents mode changes when away. |
prevent_vacuum |
list | (optional) | Sensors to prevent vacuum cleaners from running. |
turn_on_in_the_morning |
list | (optional) | Entities to turn on in the morning. |
turn_off_at_night |
list | (optional) | Entities to turn off at night. |
| Key | Type | Default | Description |
|---|---|---|---|
morning_sensors |
list | (optional) | Sensors to trigger morning mode. |
night_sensors |
list | (optional) | Sensors to trigger night mode. |
| Key | Type | Default | Description |
|---|---|---|---|
presence |
list | (optional) | List of persons with roles (adult, kid, housekeeper) |
person |
person/tracker | (optional) | Person or tracker to track. |
role |
string | adult |
Person role (adult, kid, family, housekeeper) |
outside |
input_boolean | (optional) | Manually set person away. |
lock_user |
int | (optional) | Lock user ID for MQTT door lock. |
| Key | Type | Default | Description |
|---|---|---|---|
vacuum |
dict | (optional) | List of vacuum cleaner entities. |
vacuum |
string | (optional) | Name of vacuum. |
battery |
string | (optional) | battery sensor. |
| Key | Type | Default | Description |
|---|---|---|---|
MQTT_door_lock |
list | (optional) | List of doorlocks to automatically unlock and disable relock when home. |
| Key | Type | Default | Description |
|---|---|---|---|
alarmsensors |
list | (optional) | Sensors to trigger notifications and media playback. |
alarm_media |
dict | (optional) | Playlist and media settings to play when alarmsensors are triggered. |
manageModes:
module: modeManagement
class: ModeManagement
country_code: 'NO'
vacation: input_boolean.vacation
HALightModeText: input_text.lightmode
# Notification setup
notify_receiver:
- mobile_app_my_phone
# Morning routine setup
morning_sensors:
- binary_sensor.motion_detection
- binary_sensor.presence_sensor
morning_start_listen_time: '06:00:00'
morning_to_normal: '09:00:00'
execute_morning_at: '10:00:00'
turn_on_in_the_morning:
- media_player.amp
# Night routine setup
night_sensors:
- binary_sensor.window_door_is_open
night_start_listen_time: '22:00:00'
execute_night_at: '02:00:00'
turn_off_at_night:
- media_player.amp
# Doorlock setup
MQTT_door_lock:
- zigbee2mqtt/NimlyDoor
# Presence detection setup
presence:
- person: person.me
outside: input_boolean.outside_me
role: adult
lock_user: 0
# Vacuum setup
vacuum:
- vacuum: vacuum.roomba
- vacuum: vacuum.roborock_s8
battery: sensor.roborock_s8_batteri
prevent_vacuum:
- media_player.tv
# Alarm configurations
alarmsensors:
- binary_sensor.entrance_motion_motion_detection
- cover.garage_door
- binary_sensor.door_window_door_is_open
alarm_media:
- amp: media_player.your_amp # Device to turn on
source: Roon # Source select on device
volume: 0.5 # Volume on device
normal_volume: 0.33 # Volume to return to after 2 minutes (optional)
player: media_player.yourplayer
playlist: 'Library/Artists/Alarm/Alarm'- Capture and send picture with notification on alarm.
- Found a bug? Open an issue or submit a PR!
- Want to add a feature? Discuss in the GitHub Discussions.