various tidyups

This commit is contained in:
zorruno
2026-09-13 15:32:16 +12:00
parent 3ead85ef29
commit d1fea67cfe
34 changed files with 3303 additions and 2306 deletions
+80 -4
View File
@@ -1,8 +1,8 @@
#:########################################################################################:#
# Package: Pet Feeding and Jobs Timing
# File: pet_feeding_and_jobs.yaml
# Version: v1.4.0
# Date: 2026-07-26
# Version: v1.5.2
# Date: 2026-09-09
#
# Purpose:
# Provides legacy MQTT pet activity sensors and Jobs-derived timing sensors for
@@ -17,6 +17,11 @@
# instead of exposing a numeric sentinel value.
#
# Version History:
# - v1.5.2 (2026-09-12): Ignore stale restored dog-button event states so
# reconnects cannot create false timestamps or visual feedback.
# - v1.5.1 (2026-09-09): Extended dog-button feedback intervals to 500 ms.
# - v1.5.0 (2026-09-09): Added visual feedback flashes for physical dog
# completion buttons, using the Lounge outside light relay.
# - v1.4.0 (2026-07-26): Announce four physical job completions on the Sony
# lounge TV and both Pushover devices.
# - v1.3.0 (2026-07-26): Restore retained dog-fed and jobs-done activity
@@ -122,7 +127,12 @@ automation:
conditions:
- condition: template
value_template: >-
{{ trigger.to_state.state not in ['unknown', 'unavailable'] }}
{% set valid_state = trigger.to_state is not none
and trigger.to_state.state not in ['unknown', 'unavailable'] %}
{% set event_ts = as_timestamp(trigger.to_state.state, 0)
if valid_state else 0 %}
{% set event_age = as_timestamp(now()) - event_ts %}
{{ valid_state and event_ts > 0 and event_age >= 0 and event_age <= 30 }}
actions:
- action: input_datetime.set_datetime
target:
@@ -145,7 +155,12 @@ automation:
conditions:
- condition: template
value_template: >-
{{ trigger.to_state.state not in ['unknown', 'unavailable'] }}
{% set valid_state = trigger.to_state is not none
and trigger.to_state.state not in ['unknown', 'unavailable'] %}
{% set event_ts = as_timestamp(trigger.to_state.state, 0)
if valid_state else 0 %}
{% set event_age = as_timestamp(now()) - event_ts %}
{{ valid_state and event_ts > 0 and event_age >= 0 and event_age <= 30 }}
actions:
- action: input_datetime.set_datetime
target:
@@ -227,3 +242,64 @@ automation:
title: "Jobs Announcement"
short_announcement: "{{ completion_message }}"
long_announcement: "{{ completion_message }}"
#:######################################################################################:#
# AUTOMATION: Physical Dog-Button Visual Feedback
#:######################################################################################:#
- id: dog_button_visual_feedback
alias: "Jobs - Dog Button Visual Feedback"
description: >-
Flashes the Lounge outside light relay for one physical single-press,
preserving its original state after dog feeding or depooping is recorded.
mode: queued
max: 10
triggers:
- trigger: state
entity_id:
- event.jobs_dog_fed_button_x14bt_action
- event.jobs_dog_depooped_button_x15bt_action
conditions:
- condition: template
value_template: >-
{% set valid_state = trigger.to_state is not none
and trigger.to_state.state not in ['unknown', 'unavailable'] %}
{% set event_ts = as_timestamp(trigger.to_state.state, 0)
if valid_state else 0 %}
{% set event_age = as_timestamp(now()) - event_ts %}
{{
valid_state
and event_ts > 0
and event_age >= 0
and event_age <= 30
and trigger.to_state.attributes.event_type == 'single'
}}
actions:
- variables:
initial_state: "{{ states('switch.esp_loungesouthleftswitch_relay_2_outside_light_1') }}"
flash_count: >-
{{ 2 if trigger.entity_id == 'event.jobs_dog_fed_button_x14bt_action' else 3 }}
- repeat:
count: "{{ flash_count | int }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ initial_state == 'off' }}"
sequence:
- action: switch.turn_on
target:
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
- delay: "00:00:00.500"
- action: switch.turn_off
target:
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
- delay: "00:00:00.500"
default:
- action: switch.turn_off
target:
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
- delay: "00:00:00.500"
- action: switch.turn_on
target:
entity_id: switch.esp_loungesouthleftswitch_relay_2_outside_light_1
- delay: "00:00:00.500"