Skip to content

Commit 9c540c0

Browse files
committed
Finally got it ALL working!
Enhance configuration files for improved logging and vacuum automation - Updated logbook.yaml to exclude additional domains and sensor entities for better data management. - Modified logger.yaml to adjust log levels for template helpers and scripts, enhancing error tracking. - Added auto_purge and commit_interval settings in recorder.yaml to optimize database management. - Refined vacuum.yaml to improve queue handling and room identification logic, ensuring more efficient cleaning operations.
1 parent 36b5150 commit 9c540c0

5 files changed

Lines changed: 75 additions & 80 deletions

File tree

config/logbook.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#-------------------------------------------
88

99
exclude:
10+
domains:
11+
- persistent_notification
12+
- update
1013
entity_globs:
1114
- sensor.*_location
1215
- sensor.*_place
@@ -16,6 +19,16 @@ exclude:
1619
- input_text.l10s_vacuum_*
1720
- input_datetime.l10s_vacuum_*
1821
- input_boolean.l10s_vacuum_*
22+
- sensor.*_battery
23+
- sensor.*_battery_state
24+
- sensor.*_uptime*
25+
- sensor.*_last_update*
26+
- sensor.*_since
27+
- sensor.*_last_boot
28+
- sensor.sun_next_*
29+
- sensor.*_activity
30+
- sensor.*_bssid
31+
- sensor.*_wifi_signal_strength
1932
entities:
2033
- automation.cuckoo_clock
2134
- automation.detect_lights_and_adjust_the_brightness_when_turned_on_based_on_time
@@ -44,3 +57,4 @@ exclude:
4457
- sensor.small_garage_wifi_signal_strength
4558
- sensor.time
4659
- sensor.upstairs_ac_cooling_numeric
60+
- sensor.vcloudinfo_com

config/logger.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ logs:
3636
homeassistant.components.mqtt: error
3737
homeassistant.components.mqtt.discovery: critical
3838
homeassistant.components.persistent_notification: critical
39+
homeassistant.components.template: warn
3940
homeassistant.components.rest.sensor: critical
4041
homeassistant.components.recorder: error
4142
homeassistant.components.sensor.pi_hole: critical
@@ -47,7 +48,7 @@ logs:
4748
homeassistant.components.switch.unifi: error
4849
homeassistant.components.zwave: warn
4950
homeassistant.exceptions: info
50-
homeassistant.helpers.script: info
51+
homeassistant.helpers.script: warn
5152
homeassistant.helpers.entity: critical
5253
homeassistant.loader: warn
5354
homeassistant.components.websocket_api: error
@@ -58,4 +59,4 @@ logs:
5859
urllib3.connectionpool: error
5960
requests.packages.urllib3.connectionpool: critical
6061
root: warn
61-
62+

config/packages/logger.yaml

Lines changed: 0 additions & 38 deletions
This file was deleted.

config/packages/vacuum.yaml

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,26 @@ script:
5454
- variables:
5555
# Weekday runs are sweeping (vacuum only), weekend runs are mopping
5656
cleaning_mode: "{{ 'mopping' if now().weekday() in [5, 6] else 'sweeping' }}"
57-
catalog_raw: "{{ states('input_text.l10s_vacuum_room_catalog') | string | replace(' ', '') }}"
58-
queue_raw: "{{ states('input_text.l10s_vacuum_room_queue') | string | replace(' ', '') }}"
59-
last_reset: "{{ as_datetime(states('input_datetime.l10s_vacuum_last_weekday_cycle'), default=None) }}"
57+
catalog_raw: "{{ states('input_text.l10s_vacuum_room_catalog') | default('', true) | string | replace(' ', '') }}"
58+
queue_raw: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | string | replace(' ', '') }}"
59+
last_reset_raw: "{{ states('input_datetime.l10s_vacuum_last_weekday_cycle') }}"
60+
last_reset_date_str: >
61+
{% set dt = as_datetime(last_reset_raw, default=None) %}
62+
{{ dt.date().isoformat() if dt is not none else '' }}
63+
catalog_ints: "{{ catalog_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list }}"
64+
queue_ints: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list }}"
6065
# Seed if queue is empty AND last reset was not today
61-
can_seed_today: "{{ last_reset is none or last_reset.date() != now().date() }}"
62-
will_seed: "{{ queue_raw | length == 0 and can_seed_today and catalog_raw | length > 0 }}"
63-
seeded_queue_list: >
64-
{% set q = catalog_raw.split(',') if will_seed else queue_raw.split(',') %}
65-
{{ q | map('int') | list }}
66+
can_seed_today: "{{ last_reset_date_str == '' or last_reset_date_str != now().date().isoformat() }}"
67+
will_seed: >
68+
{% set empty_queue = queue_ints | length == 0 %}
69+
{% set on_demand = is_state('input_boolean.l10s_vacuum_on_demand', 'on') %}
70+
{{ (empty_queue or (on_demand and queue_ints | length <= 1)) and catalog_ints | length > 0 and (can_seed_today or on_demand) }}
71+
seeded_queue_list: "{{ catalog_ints if will_seed else queue_ints }}"
72+
valid_queue_list: "{{ seeded_queue_list }}"
6673
# Define bathroom IDs for mopping separation
6774
bath_ids: [1, 3, 4]
68-
nonbath_list: "{{ seeded_queue_list | reject('in', bath_ids) | list }}"
69-
bath_list: "{{ seeded_queue_list | select('in', bath_ids) | list }}"
75+
nonbath_list: "{{ valid_queue_list | reject('in', bath_ids) | list }}"
76+
bath_list: "{{ valid_queue_list | select('in', bath_ids) | list }}"
7077
# Prioritize non-bathrooms first, then bathrooms
7178
segments_to_clean: >
7279
{% if nonbath_list | length > 0 %}
@@ -216,64 +223,73 @@ automation:
216223
- platform: state
217224
entity_id: sensor.l10s_vacuum_current_room
218225
for: '00:03:00'
226+
- platform: state
227+
entity_id: vacuum.l10s_vacuum
228+
to: 'cleaning'
229+
for: '00:03:00'
219230
variables:
220231
room_map: {14:'kitchen',12:'dining-room',10:'living room',7:'master-bedroom',15:'foyer',9:'stacey-office',17:'formal-dining',13:'hallway',8:'justin-bedroom',6:'paige-bedroom',4:'master-bathroom',2:'office',1:'pool-bath',3:'kids-bathroom'}
232+
catalog_raw: "{{ states('input_text.l10s_vacuum_room_catalog') | default('', true) | string | replace(' ', '') }}"
233+
catalog_ints: "{{ catalog_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list }}"
221234
queue_raw: "{{ states('input_text.l10s_vacuum_room_queue') | default('', true) | string | replace(' ', '') }}"
222-
queue_ints: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | list | default([], true) }}"
235+
queue_ints: "{{ queue_raw | regex_findall('[0-9]+') | map('int') | select('gt', 0) | list | default([], true) }}"
236+
working_queue: "{{ queue_ints if queue_ints | length > 0 else catalog_ints }}"
223237
current_room_id: "{{ trigger.to_state.attributes.room_id | default(state_attr('sensor.l10s_vacuum_current_room', 'room_id'), true) | int(0) }}"
224-
matched_room_id: "{{ current_room_id if current_room_id > 0 and current_room_id in (queue_ints | default([], true)) else 0 }}"
225-
remaining_rooms: >
226-
{% if matched_room_id == 0 %}
227-
{{ queue_ints | join(',') }}
238+
matched_room_id: "{{ current_room_id if current_room_id > 0 and current_room_id in (working_queue | default([], true)) else 0 }}"
239+
remaining_rooms: "{{ working_queue | reject('equalto', matched_room_id) | list | join(',') }}"
240+
remaining_value: >
241+
{% set rem = remaining_rooms | string %}
242+
{% if rem | length == 0 and working_queue | length > 1 %}
243+
{{ working_queue | join(',') }}
228244
{% else %}
229-
{% set rem = [] %}
230-
{% set removed = namespace(done=false) %}
231-
{% for r in queue_ints %}
232-
{% if not removed.done and r == matched_room_id %}
233-
{% set removed.done = true %}
234-
{% else %}
235-
{% set rem = rem + [r] %}
236-
{% endif %}
237-
{% endfor %}
238-
{{ rem | join(',') }}
245+
{{ rem }}
246+
{% endif %}
247+
remaining_value_str: >
248+
{% set rv = remaining_value %}
249+
{% if rv is string %}
250+
{{ rv }}
251+
{% elif rv is iterable %}
252+
{{ rv | map('string') | join(',') }}
253+
{% else %}
254+
{{ rv | string }}
239255
{% endif %}
240256
241257
condition:
242258
# Only run if there's actually a queue and a room was successfully matched to the start of the queue
243259
- condition: template
244-
value_template: "{{ queue_ints | length > 0 }}"
260+
value_template: "{{ working_queue | length > 0 }}"
261+
- condition: template
262+
value_template: "{{ matched_room_id != 0 }}"
245263
- condition: template
246264
value_template: "{{ matched_room_id != 0 }}"
247-
- condition: state
248-
entity_id: vacuum.l10s_vacuum
249-
state: 'cleaning'
250265

251266
action:
252267
- service: input_text.set_value
253268
target:
254269
entity_id: input_text.l10s_vacuum_room_queue
255270
data:
256-
value: "{{ remaining_rooms }}"
271+
value: "{{ remaining_value_str }}"
257272
- variables:
258-
cleaned_raw: "{{ states('input_text.l10s_vacuum_rooms_cleaned_today') }}"
273+
cleaned_raw: "{{ states('input_text.l10s_vacuum_rooms_cleaned_today') | default('', true) | string }}"
274+
cleaned_parts: "{{ cleaned_raw | regex_findall('[^,]+') | map('trim') | reject('equalto','') | list }}"
259275
room_name: "{{ room_map.get(matched_room_id, states('sensor.l10s_vacuum_current_room')) }}"
260276
updated_cleaned: >
261-
{% set parts = cleaned_raw.split(',') if cleaned_raw | length > 0 else [] %}
277+
{% set parts = cleaned_parts %}
262278
{% if room_name not in parts %}
263279
{{ (parts + [room_name]) | join(', ') }}
264280
{% else %}
265-
{{ cleaned_raw }}
281+
{{ parts | join(', ') }}
266282
{% endif %}
267-
remaining_count: "{{ remaining_rooms.split(',') | length if remaining_rooms | length > 0 else 0 }}"
283+
remaining_count: "{{ remaining_value_str | regex_findall('[^,]+') | length if remaining_value_str | length > 0 else 0 }}"
268284
- service: input_text.set_value
269285
target:
270286
entity_id: input_text.l10s_vacuum_rooms_cleaned_today
271287
data:
272288
value: "{{ updated_cleaned }}"
273289
- service: script.notify_engine
274290
data:
275-
title: 'Vacuum room done'
276-
value1: "{{ room_name }} cleaned."
291+
title: 'Vacuum Room Cleaned'
292+
value1: "{{ room_name }} is clean."
277293
value2: "Remaining: {{ remaining_count }}."
278294
ios_category: 'camera'
279295
camera_entity: 'camera.l10s_vacuum_map'
@@ -324,9 +340,6 @@ automation:
324340
data:
325341
datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
326342

327-
- alias: 'Away Vacuum: Start Bathrooms When Pending'
328-
id: 6b8d7d0e-fc21-4a2f-bd9e-4c51f6b9c2c3
329-
330343
- alias: 'Vacuum Sensor Cleaning Silencer'
331344
id: 6548de52-a4a4-4df2-9d66-9c2c15577a7f
332345
trigger:
@@ -371,7 +384,7 @@ automation:
371384
data:
372385
value1: >
373386
{{ "Vacuum error: " ~ states('sensor.l10s_vacuum_error') ~ " [ask Residents to help]" }}
374-
Currently in {{states('sensor.l10s_vacuum_current_room')}}"
387+
Currently in {{states('sensor.l10s_vacuum_current_room')}}
375388
- delay: 00:01:00
376389
- service: vacuum.locate
377390
entity_id: vacuum.l10s_vacuum

config/recorder.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#-------------------------------------------
1212
#db_url: sqlite:///data/home-assistant_v2.db
1313
purge_keep_days: 30
14+
auto_purge: true
15+
commit_interval: 30
1416
exclude:
1517
domains:
1618
- camera
@@ -47,6 +49,7 @@ exclude:
4749
- sensor.*uptime*
4850
- sensor.sun_next_*
4951
- sensor.vpn_client_*
52+
- sensor.*_wifi_signal_strength
5053
- switch.*_do_not_disturb_*
5154
- switch.*_repeat_switch
5255
- input_text.l10s_vacuum_*
@@ -60,6 +63,8 @@ exclude:
6063
- number.alarm_panel_1_screen_brightness
6164
- script.amp_settings
6265
- script.speech_processing
66+
- button.l10s_vacuum_backup_map_1
67+
- binary_sensor.vcloudinfo_com
6368
- sensor.bear_stone
6469
- sensor.carlo_ap
6570
- sensor.carlo_fast

0 commit comments

Comments
 (0)