smartthings: retain state for appliances when powered off#169870
Open
CSdread wants to merge 6 commits intohome-assistant:devfrom
Open
smartthings: retain state for appliances when powered off#169870CSdread wants to merge 6 commits intohome-assistant:devfrom
CSdread wants to merge 6 commits intohome-assistant:devfrom
Conversation
Samsung appliances (washers, dryers, dishwashers, ovens, etc.) report HealthStatus.OFFLINE when powered off, not just when network-disconnected. Since 2025.6 the integration marks all entities unavailable on any OFFLINE event, breaking automations that monitor appliance state (e.g. "notify me when the wash is finished"). Fix _availability_handler to retain last-known state for appliances instead of marking them unavailable. Non-appliance devices (lights, switches, AC units) continue to go unavailable as before, since OFFLINE for them means genuinely unreachable. - Add APPLIANCE_CATEGORIES to const.py covering device categories that power off without losing meaningful state - Promote get_main_component_category to util.py so entity.py can use it without duplicating logic from binary_sensor.py - SmartThingsEntity._is_appliance() checks the device category - _availability_handler retains state for OFFLINE and UNHEALTHY events on appliance devices, avoids spurious async_write_ha_state calls - Constructor initialises appliances as available at boot since get_device_status is always called before get_device_health, so _internal_state holds valid last-known data even when offline Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Hey there @joostlek, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts SmartThings entity availability handling so Samsung appliance devices don’t become unavailable when SmartThings reports them OFFLINE/UNHEALTHY (common during physical power-off), retaining their last-known state to avoid breaking state-based automations.
Changes:
- Add an
APPLIANCE_CATEGORIESallowlist to identify device categories that should retain state when health is notONLINE. - Move
get_main_component_category()intoutil.pyfor shared use across platforms. - Update appliance availability logic in the SmartThings entity base class and adjust select-platform tests to expect retained state (including at boot).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/components/smartthings/test_select.py |
Updates dryer select availability expectations to retain last state and parametrizes non-ONLINE health statuses. |
homeassistant/components/smartthings/util.py |
Introduces shared get_main_component_category() helper for device categorization. |
homeassistant/components/smartthings/entity.py |
Changes base entity availability logic to keep appliance entities available when health is not ONLINE. |
homeassistant/components/smartthings/const.py |
Adds APPLIANCE_CATEGORIES used to decide whether to retain state on OFFLINE/UNHEALTHY. |
homeassistant/components/smartthings/binary_sensor.py |
Removes local get_main_component_category() and imports the shared utility version. |
…ance state retention Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
@home-assistant ready-for-review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Samsung appliances (washers, dryers, dishwashers, ovens, ranges, etc.) report
HealthStatus.OFFLINEwhen physically powered off — not just when network-disconnected. Since the SmartThings integration rewrite in 2025.6, everyOFFLINEevent unconditionally marks all entities asunavailable, breaking automations that depend on appliance state (e.g. "notify me when the wash is finished").This fix makes appliance entities retain their last-known state instead of going
unavailablewhen the device powers off. Non-appliance devices (lights, switches, AC units, TVs) continue to gounavailableonOFFLINEas before — for those,OFFLINEmeans genuinely unreachable and the state is unknown.The fix also corrects boot-time behaviour: appliances that are offline when HA starts now show their last-known state immediately, since
get_device_status()is always called beforeget_device_health()during setup, so_internal_stateis fully populated regardless of online status.Changes
const.py— AddsAPPLIANCE_CATEGORIEScovering device categories that emitOFFLINEduring normal power-off (WASHER,DRYER,DISHWASHER,OVEN,RANGE,COOKTOP,MICROWAVE,CLOTHING_CARE_MACHINE). Kept separate fromINVALID_SWITCH_CATEGORIESbecause the sets serve different purposes and have different members.util.py— Promotesget_main_component_category()frombinary_sensor.pyinto the shared utility module soentity.pycan use it without duplicating the logic.binary_sensor.py— Removes the now-duplicate local definition; imports fromutil.py.entity.py— Adds_is_appliance()method; rewrites_availability_handlerwith a flat two-guard pattern that retains state for appliance devices onOFFLINEandUNHEALTHYevents while avoiding spuriousasync_write_ha_state()calls; updates the constructor to initialise appliances as available at boot.test_select.py— Updates existing dryer availability tests to assert state is retained; parametrizes over bothHealthStatus.OFFLINEandHealthStatus.UNHEALTHYto cover all non-ONLINEstatuses.Type of change
Additional information
Checklist
ruff format homeassistant tests)