FS-HA Home Assistant Automation Guide

Last updated:

📱 About FS-HA App
FS-HA is a fullscreen Home Assistant app for Android tablets with motion detection capabilities. This guide shows you how to create automations in Home Assistant based on motion detection and battery charging status from the app.

Table of Contents

1. Setup in FS-HA App

Before creating automations, you need to enable Home Assistant integration in the FS-HA app:

  1. 1 Open the FS-HA app on your Android tablet
  2. 2 Swipe from any corner of the screen toward the center to open Settings
  3. 3 Scroll down to "Home Assistant Automation" section
  4. 4 Enable "Enable Home Assistant Automation" switch
  5. 5 (Optional) Enter your Long-Lived Access Token if your Home Assistant requires authentication
    How to create a Long-Lived Access Token:
    1. Open Home Assistant in your browser
    2. Click on your profile (bottom left)
    3. Scroll down to "Long-Lived Access Tokens"
    4. Click "Create Token"
    5. Give it a name (e.g., "FS-HA App")
    6. Copy the token and paste it in the app
    Note: If your Home Assistant is on a local network without authentication, you can leave this field empty.
  6. 6 Click "Save"
✅ Success! The app will now send motion detection events to Home Assistant. A sensor entity called sensor.fs_ha_motion will be automatically created in Home Assistant.

2. Motion Detection Automations

The FS-HA app creates a sensor sensor.fs_ha_motion that changes state when motion is detected:

📌 Automation 1: Turn On Switch When Motion 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
💡 Tip: Replace switch.your_switch_entity_id with your actual switch entity ID. You can find entity IDs in Home Assistant under Settings → Devices & Services → Entities.
📌 Automation 2: Turn Off Switch When Motion Stops

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
📌 Automation 3: Turn On Light When Motion Detected (with delay off)

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

3. Battery Charging Automations

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.

⚠️ Important: This requires a smart plug/switch connected to your tablet's charger. The automation will turn the charger on/off based on battery level to protect battery health.
🔋 Automation 4: Turn Off Charger When Battery Reaches Limit

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
📝 Notes:
  • Replace sensor.tablet_battery_level with your tablet's battery sensor entity ID
  • Replace switch.tablet_charger with your smart plug/switch entity ID
  • Adjust the battery level range (above/below) to match your charging limit setting
  • You can use the Home Assistant Companion app on your tablet to expose battery level as a sensor
🔋 Automation 5: Turn On Charger When Battery Drops Below Threshold

This 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
🔋 Automation 6: Smart Charging Management (Complete Solution)

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

4. Time-Based Control (Sleep Mode)

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).

⚠️ Important: The FS-HA app will still detect motion, but Home Assistant automations can be configured to ignore these events during sleep hours. This prevents lights, sounds, or other devices from being activated at night.
🌙 Automation 7: Create Sleep Mode Helper

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".

📝 Steps to create helper:
  1. Go to Home Assistant Settings → Devices & Services
  2. Click "Helpers" tab
  3. Click "+ CREATE HELPER"
  4. Select "Toggle"
  5. Name it "Sleep Mode"
  6. Entity ID will be: input_boolean.sleep_mode
  7. Click "CREATE"
🌙 Automation 8: Auto-Enable Sleep Mode at Night

This 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
🌙 Automation 9: Auto-Disable Sleep Mode in Morning

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
🌙 Automation 10: Motion Light with Sleep Mode Check

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
💡 How it works: The automation triggers when motion is detected, but the condition checks if sleep mode is OFF. If sleep mode is ON (during night hours), the automation won't run, preventing lights from turning on.
🌙 Automation 11: Silent Notifications During Sleep

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
🌙 Automation 12: Complete Sleep Mode Solution

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
🌙 Automation 13: Weekend Sleep Mode Override

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
💡 Tips for Sleep Mode:

5. Advanced Examples

🎯 Advanced: Motion-Activated Room Automation

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
🎯 Advanced: Motion Detection with Time Conditions

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

6. AI Sensors & Logging

⚠️ IMPORTANT: Backup Before Using AI Features!

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:

📋 About the Sensors:
📊 AI Routine Insights (NEW!)

See what the AI learns about your routines and give feedback to improve its understanding.

📝 Steps:
  1. Go to your Home Assistant dashboard
  2. Click the three dots (⋮) menu → Edit Dashboard
  3. Click + ADD CARD
  4. Select Markdown
  5. Paste this 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 %} {% 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') }}
  1. Set Title to: 🤖 AI Routine Insights
  2. Click SAVE
💡 How to Give Feedback:
  1. When the AI asks if something is normal, check the feedback_entity in attributes
  2. Go to Developer Tools → States
  3. Find the feedback entity (e.g., input_boolean.ai_feedback_12345)
  4. Turn on/off to give feedback:
    • On = Yes, this is normal, learn it
    • Off = No, this is not normal, ignore it
✅ Done! The AI Routine Insights will now display on your dashboard, showing what the AI learns about your routines.
⚡ AI Latest Action

See the most recent action the AI performed.

📝 Steps:
  1. Go to your Home Assistant dashboard
  2. Click the three dots (⋮) menu → Edit Dashboard
  3. Click + ADD CARD
  4. Select Markdown
  5. Paste this content:
## 🤖 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') }}
  1. Set Title to: ⚡ AI Latest Action
  2. Click SAVE
✅ Done! The AI Latest Action will now display on your dashboard, showing the most recent AI action.
📝 How to View AI Activity Log in Dashboard

Add a Markdown card to your Home Assistant dashboard to display the AI Activity Log.

📝 Steps:
  1. Go to your Home Assistant dashboard
  2. Click the three dots (⋮) menu → Edit Dashboard
  3. Click + ADD CARD
  4. Select Markdown
  5. Paste this content:
{{ state_attr('sensor.ai_activity_log', 'content') }}
  1. Set Title to: 🤖 AI Activity Log
  2. Click SAVE
✅ Done! The AI Activity Log will now display on your dashboard, showing high-level AI activities without motion detection noise.
🔍 How to View AI Automation Debug Log in Dashboard

Add a Markdown card to display the full debug log (including motion detection) for troubleshooting.

📝 Steps:
  1. Go to your Home Assistant dashboard
  2. Click the three dots (⋮) menu → Edit Dashboard
  3. Click + ADD CARD
  4. Select Markdown
  5. Paste this content:
{{ state_attr('sensor.ai_automation_debug', 'content') }}
  1. Set Title to: 🔍 AI Automation Debug Log
  2. Click SAVE
⚠️ Note: The debug log includes motion detection entries and can be very detailed. Use this for troubleshooting or when you need to see all AI activity including motion detection.
✅ Done! The debug log will now display on your dashboard with all AI activity details, including motion detection.
📡 Bluetooth Presence & Device Sensors

The app creates Bluetooth sensors to track device presence and proximity for room detection and automation.

📋 Available Bluetooth Sensors:
  • 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
💡 Tips:
  • Replace john and mary with actual person names from your setup
  • Use these sensors in automations to trigger actions when people arrive/leave
  • Proximity sensors show distance in meters - useful for room detection
📋 Alternative: Manual Markdown Card Configuration

If 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

7. Troubleshooting

❌ Sensor not appearing in Home Assistant?
💡 Tips:
🌙 Sleep Mode Not Working?

© FS-HA App. For more information, visit fs-ha.troutfarmer.dk | Back to Home