Last updated:
Before creating automations, you need to enable Home Assistant integration in the FS-HA app:
sensor.fs_ha_motion will be automatically created in Home Assistant.
The FS-HA app creates a sensor sensor.fs_ha_motion that changes state when motion is detected:
This automation turns on a switch/relay when motion is detected by the FS-HA app.
alias: "Turn On Switch on Motion Detection"
description: "Turns on a switch when FS-HA app detects motion"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "on"
action:
- service: switch.turn_on
entity_id: switch.your_switch_entity_id
mode: single
switch.your_switch_entity_id with your actual switch entity ID.
You can find entity IDs in Home Assistant under Settings → Devices & Services → Entities.
This automation turns off a switch/relay when motion stops (10 seconds of no motion).
alias: "Turn Off Switch When Motion Stops"
description: "Turns off a switch when no motion is detected for 10 seconds"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "off"
for:
seconds: 10
action:
- service: switch.turn_off
entity_id: switch.your_switch_entity_id
mode: single
This automation turns on a light when motion is detected and turns it off after 5 minutes of no motion.
alias: "Motion Light with Auto-Off"
description: "Turns on light on motion, turns off after 5 minutes of no motion"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "on"
action:
- service: light.turn_on
entity_id: light.your_light_entity_id
- wait_for_trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "off"
for:
minutes: 5
- service: light.turn_off
entity_id: light.your_light_entity_id
mode: single
The FS-HA app monitors battery charging status. You can create automations to control a smart plug/switch that powers the tablet charger based on battery level.
This automation turns off the charger when the tablet battery reaches the charging limit (e.g., 85%).
alias: "Turn Off Charger at Battery Limit"
description: "Turns off charger when tablet battery reaches charging limit"
trigger:
- platform: numeric_state
entity_id: sensor.tablet_battery_level
above: 84
below: 86
condition:
- condition: state
entity_id: switch.tablet_charger
state: "on"
action:
- service: switch.turn_off
entity_id: switch.tablet_charger
- service: notify.mobile_app_your_phone
data:
title: "Tablet Charging Limit Reached"
message: "Battery reached 85%. Charger turned off to protect battery health."
mode: single
sensor.tablet_battery_level with your tablet's battery sensor entity IDswitch.tablet_charger with your smart plug/switch entity IDThis automation turns on the charger when battery drops below a certain level (e.g., 75%) to maintain battery health.
alias: "Turn On Charger When Battery Low"
description: "Turns on charger when battery drops below 75%"
trigger:
- platform: numeric_state
entity_id: sensor.tablet_battery_level
below: 75
condition:
- condition: state
entity_id: switch.tablet_charger
state: "off"
action:
- service: switch.turn_on
entity_id: switch.tablet_charger
- service: notify.mobile_app_your_phone
data:
title: "Tablet Charging Started"
message: "Battery dropped below 75%. Charger turned on."
mode: single
This comprehensive automation manages charging between 75% and 85% to maximize battery health for always-plugged tablets.
alias: "Smart Tablet Charging Management"
description: "Manages tablet charging between 75-85% for optimal battery health"
trigger:
- platform: numeric_state
entity_id: sensor.tablet_battery_level
# Trigger when battery is below 75% or above 85%
condition:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.tablet_battery_level
below: 75
- condition: numeric_state
entity_id: sensor.tablet_battery_level
above: 85
action:
- choose:
# Turn on charger if battery is below 75%
- conditions:
- condition: numeric_state
entity_id: sensor.tablet_battery_level
below: 75
sequence:
- service: switch.turn_on
entity_id: switch.tablet_charger
- service: notify.mobile_app_your_phone
data:
title: "Tablet Charging Started"
message: "Battery at {{ states('sensor.tablet_battery_level') }}%. Charger turned on."
# Turn off charger if battery is above 85%
- conditions:
- condition: numeric_state
entity_id: sensor.tablet_battery_level
above: 85
sequence:
- service: switch.turn_off
entity_id: switch.tablet_charger
- service: notify.mobile_app_your_phone
data:
title: "Tablet Charging Stopped"
message: "Battery at {{ states('sensor.tablet_battery_level') }}%. Charger turned off to protect battery."
mode: single
To prevent motion detection from triggering lights or sounds during sleep hours, you can create a "Sleep Mode" that disables motion-based automations at night. This prevents the FS-HA app from waking you up with lights or sounds when it detects motion (like someone turning in bed).
First, create a helper switch in Home Assistant to represent sleep mode. Go to Settings → Devices & Services → Helpers → Create Helper → Toggle, name it "Sleep Mode".
input_boolean.sleep_modeThis automation automatically enables sleep mode during night hours (e.g., 22:00 to 07:00).
alias: "Auto-Enable Sleep Mode at Night"
description: "Automatically enables sleep mode during night hours"
trigger:
- platform: time
at: "22:00:00"
action:
- service: input_boolean.turn_on
entity_id: input_boolean.sleep_mode
mode: single
This automation automatically disables sleep mode in the morning (e.g., 07:00).
alias: "Auto-Disable Sleep Mode in Morning"
description: "Automatically disables sleep mode in the morning"
trigger:
- platform: time
at: "07:00:00"
action:
- service: input_boolean.turn_off
entity_id: input_boolean.sleep_mode
mode: single
This automation turns on lights when motion is detected, but ONLY if sleep mode is OFF. This prevents lights from turning on during sleep hours.
alias: "Motion Light (Disabled During Sleep)"
description: "Turns on light on motion, but not during sleep hours"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "on"
condition:
- condition: state
entity_id: input_boolean.sleep_mode
state: "off"
action:
- service: light.turn_on
entity_id: light.room_main
brightness: 255
- wait_for_trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "off"
for:
minutes: 5
- service: light.turn_off
entity_id: light.room_main
mode: single
Instead of turning on lights or sounds during sleep hours, send a silent notification to your phone. This way you're aware of motion but not disturbed.
alias: "Motion Notification During Sleep"
description: "Sends silent notification during sleep hours instead of turning on lights"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "on"
condition:
- condition: state
entity_id: input_boolean.sleep_mode
state: "on"
action:
- service: notify.mobile_app_your_phone
data:
title: "Motion Detected (Sleep Mode)"
message: "Motion detected by FS-HA app (sleep mode active - no lights/sounds)"
data:
push:
sound: "none"
interruption-level: "passive"
mode: single
This comprehensive automation handles motion differently based on sleep mode status - lights during day, silent notifications at night.
alias: "Smart Motion Handling with Sleep Mode"
description: "Handles motion detection differently based on sleep mode"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "on"
action:
- choose:
# During sleep mode: send silent notification only
- conditions:
- condition: state
entity_id: input_boolean.sleep_mode
state: "on"
sequence:
- service: notify.mobile_app_your_phone
data:
title: "Motion Detected (Sleep Mode)"
message: "Motion detected - sleep mode active"
data:
push:
sound: "none"
interruption-level: "passive"
# During day: turn on lights normally
- conditions:
- condition: state
entity_id: input_boolean.sleep_mode
state: "off"
sequence:
- service: light.turn_on
entity_id: light.room_main
brightness: 255
- wait_for_trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "off"
for:
minutes: 5
- service: light.turn_off
entity_id: light.room_main
mode: single
This automation allows sleep mode to stay on longer on weekends (e.g., until 09:00 instead of 07:00).
alias: "Weekend Sleep Mode Override"
description: "Disables sleep mode later on weekends"
trigger:
- platform: time
at: "07:00:00"
condition:
- condition: time
weekday:
- saturday
- sunday
action:
- delay: "02:00:00" # Wait 2 hours (until 09:00)
- service: input_boolean.turn_off
entity_id: input_boolean.sleep_mode
mode: single
This automation turns on multiple devices when motion is detected and turns them off when motion stops.
alias: "Motion-Activated Room Automation"
description: "Turns on lights and other devices on motion, turns off after delay"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "on"
action:
- service: light.turn_on
entity_id:
- light.room_main
- light.room_accent
brightness: 255
- service: media_player.turn_on
entity_id: media_player.room_speaker
- wait_for_trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "off"
for:
minutes: 10
- service: light.turn_off
entity_id:
- light.room_main
- light.room_accent
- service: media_player.turn_off
entity_id: media_player.room_speaker
mode: single
This automation only activates during specific hours (e.g., evening hours).
alias: "Evening Motion Light"
description: "Turns on light on motion, only during evening hours"
trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "on"
condition:
- condition: time
after: "18:00:00"
before: "23:00:00"
action:
- service: light.turn_on
entity_id: light.room_main
brightness: 180
- wait_for_trigger:
- platform: state
entity_id: sensor.fs_ha_motion
to: "off"
for:
minutes: 5
- service: light.turn_off
entity_id: light.room_main
mode: single
Always create a full backup of your Home Assistant configuration before enabling AI automation features. The AI can make changes to your Home Assistant entities (lights, switches, etc.) and while it's designed to be safe, having a backup ensures you can restore your system if anything unexpected happens.
How to backup:
The FS-HA app includes an AI Automation Engine that monitors your Home Assistant entities and reacts contextually (turns on lights, detects presence, etc.). The app creates several sensors to track AI activity and routines:
sensor.ai_routine_insight - Shows what the AI learns about your routines and patterns (NEW!)sensor.ai_latest_action - Latest AI action that was executedsensor.ai_activity_log - High-level activity log (no motion detection details) - suitable for daily usesensor.ai_automation_debug - Full debug log with all details including motion detection - useful for troubleshootingsensor.bt_presence_[person] - Bluetooth presence for specific peoplesensor.bt_device_[mac] - Bluetooth devices (if open monitoring is enabled)sensor.bt_proximity_[person] - Bluetooth proximity distance for peopleSee what the AI learns about your routines and give feedback to improve its understanding.
## 🤖 AI Routine Insight
**Observation:** {{ state_attr('sensor.ai_routine_insight', 'observation') }}
**Status:** {{ state_attr('sensor.ai_routine_insight', 'normal_status') }}
{% if state_attr('sensor.ai_routine_insight', 'suggestion') %}
**Suggestion:** {{ state_attr('sensor.ai_routine_insight', 'suggestion') }}
{% endif %}
{% if state_attr('sensor.ai_routine_insight', 'feedback_entity') %}
**Feedback Entity:** {{ state_attr('sensor.ai_routine_insight', 'feedback_entity') }}
{% endif %}
**Time:** {{ state_attr('sensor.ai_routine_insight', 'timestamp') }}
🤖 AI Routine Insightsfeedback_entity in attributesinput_boolean.ai_feedback_12345)See the most recent action the AI performed.
## 🤖 AI Latest Action
**Action:** {{ state_attr('sensor.ai_latest_action', 'action') }}
**Status:** {{ state_attr('sensor.ai_latest_action', 'status') }}
**Details:** {{ state_attr('sensor.ai_latest_action', 'details') }}
**Time:** {{ state_attr('sensor.ai_latest_action', 'timestamp') }}
⚡ AI Latest ActionAdd a Markdown card to your Home Assistant dashboard to display the AI Activity Log.
{{ state_attr('sensor.ai_activity_log', 'content') }}
🤖 AI Activity LogAdd a Markdown card to display the full debug log (including motion detection) for troubleshooting.
{{ state_attr('sensor.ai_automation_debug', 'content') }}
🔍 AI Automation Debug LogThe app creates Bluetooth sensors to track device presence and proximity for room detection and automation.
sensor.bt_presence_[person] - Shows if a person's device is detected (e.g., sensor.bt_presence_john)sensor.bt_device_[mac] - Individual Bluetooth device tracking (e.g., sensor.bt_device_aa_bb_cc_dd_ee_ff)sensor.bt_proximity_[person] - Proximity distance in meters (e.g., sensor.bt_proximity_john)Example: Create an Entity Card for Bluetooth Presence
type: entities
title: 📡 Bluetooth Presence
entities:
- sensor.bt_presence_john
- sensor.bt_presence_mary
- sensor.bt_proximity_john
- sensor.bt_proximity_mary
john and mary with actual person names from your setupIf you prefer to configure the cards manually via YAML, you can use these configurations:
AI Routine Insights Card:
type: markdown
content: |
## 🤖 AI Routine Insight
**Observation:** {{ state_attr('sensor.ai_routine_insight', 'observation') }}
**Status:** {{ state_attr('sensor.ai_routine_insight', 'normal_status') }}
{% if state_attr('sensor.ai_routine_insight', 'suggestion') %}
**Suggestion:** {{ state_attr('sensor.ai_routine_insight', 'suggestion') }}
{% endif %}
**Time:** {{ state_attr('sensor.ai_routine_insight', 'timestamp') }}
title: 🤖 AI Routine Insights
AI Latest Action Card:
type: markdown
content: |
## ⚡ AI Latest Action
**Action:** {{ state_attr('sensor.ai_latest_action', 'action') }}
**Status:** {{ state_attr('sensor.ai_latest_action', 'status') }}
**Time:** {{ state_attr('sensor.ai_latest_action', 'timestamp') }}
title: ⚡ AI Latest Action
AI Activity Log Card:
type: markdown
content: |
{{ state_attr('sensor.ai_activity_log', 'content') }}
title: 🤖 AI Activity Log
AI Automation Debug Log Card:
type: markdown
content: |
{{ state_attr('sensor.ai_automation_debug', 'content') }}
title: 🔍 AI Automation Debug Log
sensor.fs_ha_motion in Home Assistant Developer Tools → Statesinput_boolean.sleep_mode helper exists and is properly configuredinput_boolean.sleep_mode exists in Home Assistant© FS-HA App. For more information, visit fs-ha.troutfarmer.dk | Back to Home