22tags :
33 - package
44 - automated
5+ version : 1.0.0
56---
67
78# Package: Dishwasher
89
9- ## Executive Summary
10- This package manages the integration and automation logic for the LG Dishwasher (via SmartThinQ). It normalizes raw sensor data into friendly states ("Active", "Clean"), calculates a human-readable "Time Remaining" value, and tracks maintenance requirements .
10+ ** Version: ** 1.0.0
11+ ** Description: ** Logic, sensors, flags, and automations for the LG Dishwasher. Handles normalization of LG ThinQ data and maintenance reminders .
1112
12- ** Key Features:**
13- - ** State Normalization** : Converts various machine states (e.g., ` running ` , ` rinsing ` , ` drying ` ) into a simple binary ` active ` sensor.
14- - ** Maintenance Tracking** : Uses an ` input_boolean ` to flag when a "Machine Clean" cycle is required, auto-resetting when the cycle is performed.
15- - ** Smart Notifications** :
16- - ** Start** : Notifies when a cycle begins, including the estimated finish time.
17- - ** End** : Notifies when finished with total run time. Triggers immediately on cycle end or if the door is opened while in 'end' state.
18-
19- ## Architecture
20-
21- ``` mermaid
22- sequenceDiagram
23- participant LG as LG ThinQ Integration
24- participant Pkg as Package Logic
25- participant HA as Home Assistant
26- participant User as User/Dashboard
27-
28- Note over LG, Pkg: State Normalization
29- LG->>Pkg: Update sensor.dishwasher_current_status
30- Pkg->>HA: Update binary_sensor.dishwasher_active (On/Off)
31- Pkg->>HA: Update sensor.dishwasher_status_clean (Friendly Name)
32-
33- Note over LG, Pkg: Time Calculation
34- LG->>Pkg: Update sensor.dishwasher_remaining_time
35- Pkg->>HA: Update sensor.dishwasher_remaining_time_human (HH:MM)
36-
37- Note over Pkg, HA: Automation Flow
38- rect rgb(20, 50, 20)
39- LG->>Pkg: Status: Running
40- Pkg->>HA: Notify "Dishwasher Started" (Wait for time calc)
41- end
42-
43- rect rgb(20, 20, 50)
44- LG->>Pkg: Status: End
45- Pkg->>HA: Notify "Dishes are Clean" (with Run Time)
46- end
47-
48- rect rgb(50, 20, 20)
49- LG->>Pkg: Machine Clean Reminder
50- Pkg->>HA: Turn On input_boolean.dishwasher_needs_cleaning
51- Pkg->>HA: Notify "Maintenance Needed"
52- User->>LG: Run "Machine Clean" Cycle
53- LG->>Pkg: Cycle: machine_clean
54- Pkg->>HA: Turn Off input_boolean.dishwasher_needs_cleaning
55- end
56- ```
57-
58- ## Backend Configuration
59-
60- The specific logic and sensors are defined in ` packages/dishwasher.yaml ` .
13+ ![ Package Diagram] ( ../../../assets/images/packages/dishwasher.png )
6114
15+ ## Configuration
6216``` yaml
17+ # ------------------------------------------------------------------------------
6318# Package: Dishwasher
64- # Description: Logic, Sensors, Flags, and Automations for the LG Dishwasher
65- #
19+ # Version: 1.0.0
20+ # Description: Logic, sensors, flags, and automations for the LG Dishwasher. Handles normalization of LG ThinQ data and maintenance reminders.
6621# Dependencies:
6722# - Integration: LG ThinQ (SmartThinQ LGE Sensors)
68- # - Script: script.notify_smart_master (Notification System Package)
69-
23+ # - Script: script.notify_smart_master
7024# ------------------------------------------------------------------------------
25+
26+ # ==============================================================================
7127# 1. HELPERS
72- # ------------------------------------------------------------------------------
28+ # ==============================================================================
7329input_boolean :
30+ # Flag: Tracks if the 'Machine Clean' cycle is due.
31+ # Logic:
32+ # - Turned ON by automation when 'binary_sensor.dishwasher_machine_clean_reminder' goes high.
33+ # - Turned OFF by automation when a 'machine_clean' cycle is actually started.
7434 dishwasher_needs_cleaning :
7535 name : " Dishwasher Needs Cleaning"
7636 icon : mdi:spray-bottle
7737
78- # ------------------------------------------------------------------------------
38+ # ==============================================================================
7939# 2. TEMPLATE SENSORS (Normalize the LG Data)
80- # ------------------------------------------------------------------------------
40+ # ==============================================================================
8141template :
8242 - binary_sensor :
8343 - name : " Dishwasher Active"
@@ -122,35 +82,39 @@ template:
12282 {% endif %}
12383 {% endif %}
12484
125- # ------------------------------------------------------------------------------
85+ # ==============================================================================
12686# 3. AUTOMATIONS
127- # ------------------------------------------------------------------------------
87+ # ==============================================================================
12888automation :
12989 # --- DISHWASHER STARTED ---
90+ # Notify when the dishwasher starts, with a wait for the time remaining sensor.
13091 - alias : " Notify: Dishwasher Started"
13192 id : notify_dishwasher_started_pkg
132- triggers :
93+ description : Notify when dishwasher starts a cycle, waiting for time remaining to be available.
94+ trigger :
13395 - entity_id : sensor.dishwasher_current_status
13496 from : initial
13597 to : running
136- trigger : state
98+ platform : state
13799 - entity_id : sensor.dishwasher_current_status
138100 from : power_off
139101 to : running
140- trigger : state
141- actions :
102+ platform : state
103+ action :
104+ # Wait up to 2 minutes for a valid time from the sensor.
142105 - wait_for_trigger :
143- - trigger : template
106+ - platform : template
144107 value_template : >
145108 {{ states('sensor.dishwasher_remaining_time_human') not in ['unknown', 'unavailable', '--:--'] }}
146109 timeout :
147110 minutes : 2
148111 continue_on_timeout : true
149112
150- - action : script.notify_smart_master
113+ - service : script.notify_smart_master
151114 data :
152115 category : info
153116 title : 💦 Dishwasher Started
117+ # Use a conditional message in case the wait timed out.
154118 message : >
155119 {% set remaining = states('sensor.dishwasher_remaining_time_human') %}
156120 {% if remaining not in ['unknown', 'unavailable', '--:--'] %}
@@ -164,19 +128,21 @@ automation:
164128 mode : single
165129
166130 # --- DISHWASHER DONE ---
131+ # Notify when dishwasher finishes. Triggers if door opens while status is 'end'.
167132 - alias : " Notify: Dishwasher Done"
168133 id : notify_dishwasher_done_pkg
169- triggers :
134+ description : Notify when dishwasher finishes, including run time.
135+ trigger :
170136 - entity_id : sensor.dishwasher_current_status
171137 to : end
172138 id : cycle_end
173- trigger : state
139+ platform : state
174140 - entity_id : binary_sensor.dishwasher_door
175141 from : " off"
176142 to : " on"
177143 id : door_open
178- trigger : state
179- conditions :
144+ platform : state
145+ condition :
180146 - condition : or
181147 conditions :
182148 - condition : trigger
@@ -188,7 +154,8 @@ automation:
188154 - condition : state
189155 entity_id : sensor.dishwasher_current_status
190156 state : end
191- actions :
157+ action :
158+ # Calculate run time, handling unknown values safely.
192159 - variables :
193160 run_time_raw : " {{ states('sensor.dishwasher_total_time') }}"
194161 run_time : |-
@@ -197,7 +164,7 @@ automation:
197164 {% else %}
198165 Unknown time
199166 {% endif %}
200- - action : script.notify_smart_master
167+ - service : script.notify_smart_master
201168 data :
202169 category : info
203170 title : ✨ Dishes are Clean
@@ -211,69 +178,47 @@ automation:
211178 mode : single
212179
213180 # --- DISHWASHER MAINTENANCE ---
181+ # Alerts when machine clean is needed and resets the flag when a clean cycle is started.
214182 - alias : " Notify: Dishwasher Maintenance"
215183 id : notify_dishwasher_maintenance_pkg
216- triggers :
184+ description : Alerts when machine clean is needed and resets when done.
185+ trigger :
217186 - entity_id : binary_sensor.dishwasher_machine_clean_reminder
218187 to : " on"
219188 id : needs_clean
220- trigger : state
189+ platform : state
221190 - entity_id : sensor.dishwasher_current_cycle
222191 to : machine_clean
223192 id : clean_cycle_started
224- trigger : state
225- actions :
193+ platform : state
194+ action :
226195 - choose :
196+ # Case 1: Reminder turns ON and we haven't acknowledged it yet.
227197 - conditions :
228198 - condition : trigger
229199 id : needs_clean
230200 - condition : state
231201 entity_id : input_boolean.dishwasher_needs_cleaning
232202 state : " off"
233203 sequence :
234- - action : input_boolean.turn_on
204+ - service : input_boolean.turn_on
235205 target :
236206 entity_id : input_boolean.dishwasher_needs_cleaning
237- - action : script.notify_smart_master
207+ - service : script.notify_smart_master
238208 data :
239209 category : info
240210 title : 🧼 Dishwasher Maintenance
241211 message : The dishwasher needs a Machine Clean cycle.
242212 tag : dishwasher_maintenance
243213 sticky : true
214+ # Case 2: A 'machine_clean' cycle is started, so we reset the flag.
244215 - conditions :
245216 - condition : trigger
246217 id : clean_cycle_started
247218 sequence :
248- - action : input_boolean.turn_off
219+ - service : input_boolean.turn_off
249220 target :
250221 entity_id : input_boolean.dishwasher_needs_cleaning
251222 mode : single
252- ` ` `
253-
254- ## Frontend Connection
255-
256- **Key Entities**:
257- - ` sensor.dishwasher_state`
258- - ` binary_sensor.kitchen_dishwasher_leak_sensor_water_leak` (Integration provided)
259-
260- **Dashboard Usage**:
261- The dishwasher is monitored in the Development dashboard (`dashboard_dev2`), primarily tracked within area cards (likely Kitchen).
262-
263- **Card Configuration (Snippet)**:
264- This snippet shows how the leak sensor and state are integrated into grid/area cards.
265223
266- ` ` ` json
267- // From lovelace.dashboard_dev2
268- {
269- "device_3": "sensor.dishwasher_state",
270- "device_3_icon": "mdi:dishwasher",
271- "device_3_state": "Running",
272- "device_3_color": "blue",
273- "device_4": "binary_sensor.kitchen_dishwasher_leak_sensor_water_leak",
274- "device_4_icon": "mdi:dishwasher-alert",
275- "device_4_state": "on",
276- "device_4_color": "red",
277- "device_4_animation": "blink"
278- }
279224```
0 commit comments