Add inverted status option for Tuya covers#166020
Add inverted status option for Tuya covers#166020nishantapatil3 wants to merge 18 commits intohome-assistant:devfrom
Conversation
There was a problem hiding this comment.
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Hey there @tuya, @zlinoliver, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
Adds a per-cover, locally stored configuration switch for the Tuya integration that inverts cover status semantics, and wires that inversion into position/state interpretation and outgoing commands.
Changes:
- Introduces a config
switchentity per Tuya cover to toggle “Invert status”, with state restoration and dispatcher signaling. - Applies inversion logic in the Tuya cover entity for
is_closed, current position, open/close, and set-position behaviors. - Adds tests validating inverted state/position mapping and command dispatch when inversion is enabled.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/tuya/cover.py |
Applies the inversion flag to cover state/position and outgoing commands; subscribes to inversion change signals. |
homeassistant/components/tuya/switch.py |
Adds a local config switch entity per cover to toggle inversion, restores its state, and notifies covers via dispatcher. |
homeassistant/components/tuya/const.py |
Adds constants for storing inversion state in hass.data and for the dispatcher signal format. |
homeassistant/components/tuya/strings.json |
Adds the "invert_status" translation key for the new config switch name. |
tests/components/tuya/test_cover.py |
Adds coverage for inverted state/position mapping and inverted command dispatch. |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in, per-cover configuration switch for the Tuya integration to invert cover status semantics, allowing users to correct devices whose reported/open-close behavior is reversed.
Changes:
- Introduces a local “Invert status” config switch (with restore support) per discovered Tuya cover.
- Applies inversion to interpreted cover state/position and to outgoing open/close/set-position commands.
- Adds tests validating inverted state/position mapping and command dispatch for both percentage-based and enum-action covers.
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 |
|---|---|
homeassistant/components/tuya/const.py |
Adds constants for storing inversion state and signaling inversion updates. |
homeassistant/components/tuya/cover.py |
Applies inversion logic to cover state/position and outgoing commands; listens for inversion toggle signals. |
homeassistant/components/tuya/switch.py |
Adds a per-cover config switch (RestoreEntity) to toggle inversion and notify related cover entities. |
homeassistant/components/tuya/strings.json |
Adds translated names for the new inversion switch (indexed and non-indexed). |
tests/components/tuya/test_cover.py |
Adds test coverage for inverted behavior (state/position + command mapping). |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a per-cover, locally stored config switch to the Tuya integration to invert cover open/closed semantics for devices that report (and/or interpret) position/state opposite to Home Assistant’s expectations.
Changes:
- Add a new config
SwitchEntity(with restore support) to toggle “Invert status” per Tuya cover entity. - Apply inversion consistently in the cover entity for position/state interpretation and for outgoing open/close/set_position commands.
- Add tests validating inverted state/position mapping and command dispatch.
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 |
|---|---|
homeassistant/components/tuya/cover.py |
Applies the inversion flag to reported position/state and outgoing commands; listens for inversion-toggle signals to refresh state. |
homeassistant/components/tuya/switch.py |
Introduces a restore-capable config switch per cover to toggle inversion and dispatch update signals. |
homeassistant/components/tuya/const.py |
Adds constants for the inversion state store key and dispatcher signal format. |
homeassistant/components/tuya/strings.json |
Adds localized entity names for the new “Invert status” switch (indexed + non-indexed). |
tests/components/tuya/test_cover.py |
Adds tests for inverted state/position mapping and inverted outgoing command payloads. |
Proposed change
This PR adds a local per-cover config switch for the Tuya integration to invert cover status semantics for devices where Tuya and Home Assistant disagree on open/closed state.
When enabled, the inversion is applied consistently to:
open_cover/close_coverbehaviorset_cover_positionIt also adds tests covering inverted state, percentage mapping, and command dispatch.
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: