Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Tuya switch TS000x device type #2996

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft

Conversation

Migsi
Copy link
Contributor

@Migsi Migsi commented Feb 22, 2024

Proposed change

Change device type of Switch_4G_GPP to be an actual switch, as the device consists of potential-free relais. Also the type switch is substitutable with other types using HA helpers, but not (or not easily) vice versa.

It would probably make sense to change this for other similar switches as well, but as I don't own any others, I don't want to change stuff blindy, potentially introducing unnecessary errors/misbehaviour.

I found no related tests to this device, so I didn't do anything in this regard as well, as I've got not enough time to read through your testframework (yet) :/

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

Change device type of Switch_4G_GPP to be an actual switch, as the device consists of potential-free relais. Also the type switch is substitutable with other types using HA helpers, but not (or not easily) vice versa.

It would probably make sense to change this for other similar switches as well, but as I don't own any others, I don't want to change stuff blindy, potentially introducing unnecessary errors/misbehaviour.
Copy link

codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.85%. Comparing base (2a39c07) to head (b9057b5).
Report is 4 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2996   +/-   ##
=======================================
  Coverage   87.85%   87.85%           
=======================================
  Files         301      301           
  Lines        9212     9212           
=======================================
  Hits         8093     8093           
  Misses       1119     1119           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TheJulianJES TheJulianJES added the Tuya Request/PR regarding a Tuya device label Feb 26, 2024
@TheJulianJES TheJulianJES changed the title Update ts000x.py Change Tuya switch TS000x device type Feb 26, 2024
Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue with this is that it'll break existing installations. Everyone who currently set it up will have the old entity become stale and get a new one.
We've avoided changing the device type for new quirks because of this.

Please see this section on how to change the device type locally:
https://www.home-assistant.io/integrations/zha/#modifying-the-device-type

@TheJulianJES TheJulianJES marked this pull request as draft February 26, 2024 18:44
@Migsi
Copy link
Contributor Author

Migsi commented Feb 27, 2024

The issue with this is that it'll break existing installations. Everyone who currently set it up will have the old entity become stale and get a new one. We've avoided changing the device type for new quirks because of this.

Please see this section on how to change the device type locally: https://www.home-assistant.io/integrations/zha/#modifying-the-device-type

I see. So this PR becomes obsolete?

While it is possible to work around this, I still see it at least somewhat inconvenient for new users setting up this (and potentialy any other wrongly specified device). Wouldn't it be possible to ensure somehow the original device type continues working by automatically generating a proper helper, just as "change device type" in the UI does? The latter only seems to work when the "base" entity was a generic switch, but not when it is something specific like e.g. a lamp in this case.

@Migsi
Copy link
Contributor Author

Migsi commented Mar 3, 2024

@TheJulianJES sorry for the ping, I'd just close the PR if it really became irrelevant.

@TheJulianJES
Copy link
Collaborator

Wouldn't it be possible to ensure somehow the original device type continues working by automatically generating a proper helper, just as "change device type" in the UI does?

I know it's not ideal, but we can't really do this from quirks.

The latter only seems to work when the "base" entity was a generic switch, but not when it is something specific like e.g. a lamp in this case.

That's a limitation on HA Core side, as the integration responsible for that is called "Switch as X" and only allows you to "convert" switches.

So this PR becomes obsolete?

For now, probably yes. I'm aware the current situation isn't ideal (especially because you can't go from light to switch using HA UI and have to modify (ZHA) YAML configuration to fix this, but there's no "good" solution right now.)

@Migsi
Copy link
Contributor Author

Migsi commented Mar 25, 2024

Wouldn't it be possible to ensure somehow the original device type continues working by automatically generating a proper helper, just as "change device type" in the UI does?

I know it's not ideal, but we can't really do this from quirks.

...

So this PR becomes obsolete?

For now, probably yes. I'm aware the current situation isn't ideal (especially because you can't go from light to switch using HA UI and have to modify (ZHA) YAML configuration to fix this, but there's no "good" solution right now.)

Bummer :( Hope this gets sorted at some point.

The latter only seems to work when the "base" entity was a generic switch, but not when it is something specific like e.g. a lamp in this case.

That's a limitation on HA Core side, as the integration responsible for that is called "Switch as X" and only allows you to "convert" switches.

I might have a look at that at some point. Trying to lift this restriction could mitigate this inconvenience at least a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants