mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2026-04-22 06:10:40 +00:00
Enhance vacuum automation to handle error states and notify family members
This commit is contained in:
@@ -701,13 +701,23 @@ automation:
|
||||
- alias: 'Help Vacuum'
|
||||
id: 6548de52-a4a4-4df2-9d66-9c2c15577a7e
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: vacuum.l10s_vacuum
|
||||
to: 'error'
|
||||
id: vacuum_state_error
|
||||
- platform: state
|
||||
entity_id: sensor.l10s_vacuum_error
|
||||
id: vacuum_error_state
|
||||
- platform: event
|
||||
event_type: event_did_someone_help_vacuum_loop
|
||||
id: vacuum_error_loop
|
||||
condition:
|
||||
- condition: template
|
||||
value_template: "{{ states('sensor.l10s_vacuum_error') not in ['no_error', 'unavailable'] }}"
|
||||
value_template: >-
|
||||
{{
|
||||
is_state('vacuum.l10s_vacuum', 'error')
|
||||
or states('sensor.l10s_vacuum_error') not in ['no_error', 'unavailable']
|
||||
}}
|
||||
action:
|
||||
- service: script.send_to_logbook
|
||||
data:
|
||||
@@ -726,15 +736,33 @@ automation:
|
||||
Error: {{ states('sensor.l10s_vacuum_error') }}
|
||||
Room: {{ states('sensor.l10s_vacuum_current_room') }}
|
||||
|
||||
- service: script.notify_engine
|
||||
data:
|
||||
title: 'Help vacuum'
|
||||
value1: "{{ states('sensor.l10s_vacuum_error') }} - {{states('sensor.l10s_vacuum_current_room')}}"
|
||||
who: 'family'
|
||||
ios_category: 'camera'
|
||||
camera_entity: 'camera.l10s_vacuum_map'
|
||||
content_type: 'jpeg'
|
||||
group: 'information'
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: "{{ trigger.id in ['vacuum_state_error', 'vacuum_error_state'] }}"
|
||||
sequence:
|
||||
- wait_template: >-
|
||||
{{
|
||||
is_state('group.family', 'home')
|
||||
or is_state('input_boolean.guest_mode', 'on')
|
||||
or is_state('input_boolean.vacation_mode', 'on')
|
||||
}}
|
||||
- service: script.notify_engine
|
||||
data:
|
||||
title: 'Help vacuum'
|
||||
value1: "{{ states('sensor.l10s_vacuum_error') }} - {{ states('sensor.l10s_vacuum_current_room') }}"
|
||||
who: 'parents'
|
||||
ios_category: 'camera'
|
||||
camera_entity: 'camera.l10s_vacuum_map'
|
||||
content_type: 'jpeg'
|
||||
group: 'information'
|
||||
- service: vacuum.locate
|
||||
entity_id: vacuum.l10s_vacuum
|
||||
- service: script.speech_engine
|
||||
data:
|
||||
value1: >
|
||||
{{ "Vacuum error: " ~ states('sensor.l10s_vacuum_error') ~ ". Please help the robot." }}
|
||||
Currently in {{ states('sensor.l10s_vacuum_current_room') }}
|
||||
- wait_template: "{{ is_state('group.bed', 'off') }}"
|
||||
- wait_template: "{{ is_state('group.family', 'home') }}"
|
||||
- delay: 00:03:00
|
||||
|
||||
@@ -23,6 +23,51 @@ function Quote-BashArg {
|
||||
$containerNameQ = Quote-BashArg -Value $ContainerName
|
||||
$configPathQ = Quote-BashArg -Value $ConfigPath
|
||||
|
||||
$containerCheckScript = @'
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from homeassistant import bootstrap, core, loader
|
||||
from homeassistant.config_entries import ConfigEntries
|
||||
from homeassistant.helpers.check_config import async_check_ha_config_file
|
||||
|
||||
CONFIG_DIR = os.environ.get("CONFIG_DIR", "/config")
|
||||
|
||||
|
||||
async def main() -> int:
|
||||
hass = core.HomeAssistant(CONFIG_DIR)
|
||||
loader.async_setup(hass)
|
||||
hass.config_entries = ConfigEntries(hass, {})
|
||||
|
||||
ok = await bootstrap.async_load_base_functionality(hass)
|
||||
if not ok:
|
||||
print(f"Failed to initialize base functionality for {CONFIG_DIR}")
|
||||
await hass.async_stop(force=True)
|
||||
return 1
|
||||
|
||||
res = await async_check_ha_config_file(hass)
|
||||
await hass.async_stop(force=True)
|
||||
|
||||
print(f"Testing configuration at {CONFIG_DIR}")
|
||||
if res.errors:
|
||||
print("Failed config")
|
||||
for err in res.errors:
|
||||
print(f" {err.domain or 'error'}: {err.message}")
|
||||
return 1
|
||||
|
||||
print("Configuration valid")
|
||||
if res.warnings:
|
||||
print("Warnings:")
|
||||
for warn in res.warnings:
|
||||
print(f" {warn.domain or 'warning'}: {warn.message}")
|
||||
return 0
|
||||
|
||||
|
||||
raise SystemExit(asyncio.run(main()))
|
||||
'@
|
||||
|
||||
$containerCheckScript = ($containerCheckScript -replace "`r`n", "`n").Trim()
|
||||
|
||||
$containerCheck = @"
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo Docker CLI not found on host. >&2
|
||||
@@ -33,7 +78,7 @@ if ! docker ps --format '{{.Names}}' | grep -Fx $containerNameQ >/dev/null 2>&1;
|
||||
exit 1
|
||||
fi
|
||||
echo Running Home Assistant config check in container $containerNameQ...
|
||||
docker exec $containerNameQ python -m homeassistant --script check_config --config $configPathQ
|
||||
docker exec -i -e CONFIG_DIR=$configPathQ $containerNameQ python -
|
||||
"@
|
||||
|
||||
$supervisedCheck = @'
|
||||
@@ -76,5 +121,11 @@ $sshArgs = @(
|
||||
(Quote-BashArg -Value $remoteCommand)
|
||||
)
|
||||
|
||||
& $ssh.Source @sshArgs
|
||||
$stdinPayload = if ($Mode -eq 'container' -or $Mode -eq 'auto') { $containerCheckScript } else { '' }
|
||||
|
||||
if ([string]::IsNullOrEmpty($stdinPayload)) {
|
||||
& $ssh.Source @sshArgs
|
||||
} else {
|
||||
$stdinPayload | & $ssh.Source @sshArgs
|
||||
}
|
||||
exit $LASTEXITCODE
|
||||
|
||||
Reference in New Issue
Block a user