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

Add support for Tuya single button scene switch variant TS0041A #2363

Merged
merged 5 commits into from
Jan 19, 2024

Conversation

ShogunMan
Copy link
Contributor

@ShogunMan ShogunMan commented Apr 28, 2023

Proposed change

Added support for variant TS0041A

Additional information

Sold as Cleverio in Sweden/Norway
https://www.kjell.com/no/produkter/smarte-hjem/smarte-hjem-losninger/cleverio-smarte-hjem/cleverio-multifunksjonsknapp-med-zigbee-3.0-p51830

Blueprint here:
https://community.home-assistant.io/t/zha-cleverio-tuya-1-button-scene-switch-ts0041a-tyzb01-4qw4rl1u/552120

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

@codecov
Copy link

codecov bot commented Apr 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2014378) 85.05% compared to head (696864c) 85.34%.
Report is 196 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2363      +/-   ##
==========================================
+ Coverage   85.05%   85.34%   +0.28%     
==========================================
  Files         266      271       +5     
  Lines        8425     8520      +95     
==========================================
+ Hits         7166     7271     +105     
+ Misses       1259     1249      -10     

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

@ShogunMan ShogunMan changed the title Added support for variant TS0041A Added support for Tuya single button scene switch variant TS0041A Apr 28, 2023
@MattWestb
Copy link
Contributor

Thats interesting its one A version that is normally only being made for LIDL and other that need have Zigbee / CSA-ITO certificated device and the normal CE (China Export not EU cert) is not getting certified like without letter or B in the end of the device type.

@ShogunMan
Copy link
Contributor Author

Thats interesting its one A version that is normally only being made for LIDL and other that need have Zigbee / CSA-ITO certificated device and the normal CE (China Export not EU cert) is not getting certified like without letter or B in the end of the device type.

Do you think it would be smart to add vendor specific data to the class ( _TYZB01_4qw4rl1u) to avoid mispairings?

@MattWestb
Copy link
Contributor

MattWestb commented Apr 28, 2023

I think it shall being in this quirk then its the same functionality as all other TS0041.
But i also think its good putting the A in the device class name and in the description so users is not trying adding the class to no A versions devices that is not working then it cant being matched.

We have not seen any TS004X that need model info matching and all is working well if the cluster / end points is matching OK with exception for the TS004F that is one different story and if its needed we is implanting it later for getting all working the same way.

@TheJulianJES TheJulianJES added new quirk Adds support for a new device Tuya Request/PR regarding a Tuya device labels Apr 28, 2023
@TheJulianJES TheJulianJES changed the title Added support for Tuya single button scene switch variant TS0041A Add support for Tuya single button scene switch variant TS0041A May 2, 2023
Comment on lines 224 to 227
TuyaSmartRemoteOnOffCluster,
],
OUTPUT_CLUSTERS: [
TuyaSmartRemoteOnOffCluster,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are both clusters used by that remote?
Or is replacing one OnOff cluster enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is only one button, but i really dont know why it has one input and one output OnOff cluster.
It does not throw any errors or warnings as it is now, but We could try with replacing only one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Its one tuya thing and deleting it in replacement is making ZHA not making on switch in the GUI that is not working (at least for TS004F devices).
Testing if it working without it and its still sending commands OK and not getting problems / delays with fast key pressings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TheJulianJES From testing and the device signature, it seems like both clusters has to be replaced. Works fine here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So when only one cluster is replaced, it doesn’t work?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Try leaving it out completely, so you have just one Tuya OnOff cluster.
(If one doesn’t work, try the other one.)

Copy link
Contributor Author

@ShogunMan ShogunMan Jul 11, 2023

Choose a reason for hiding this comment

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

I thought that the number of output clusters must match the number in the device signature, otherwise it will fail loading the quirk. This is my proposed replacement:

replacement = {
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.ON_OFF_SWITCH,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    PowerConfiguration.cluster_id,
                    TuyaSmartRemoteOnOffCluster,
                ],
                OUTPUT_CLUSTERS: [
                    OnOff.cluster_id,,
                    Time.cluster_id,
                    Ota.cluster_id,
                ],
            },
        },
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above code is the only one that is working reliably. PR has been updated with tuya cluster in only the input cluster.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ar you getting one switch in ZHA GUI then having it as input cluster after restarting HA ?
All TS004X is having problems with the dealt response shall being sent the wrong way or the device is making one pause between commands if making more fast. But it can being different with the A version you is having.

I have making one issue for sending it in the wrong detection but its not solved yet.

Copy link
Contributor Author

@ShogunMan ShogunMan Jul 12, 2023

Choose a reason for hiding this comment

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

This replacement/quirk does not provide the switch entity in the GUI as previous versions did.
If you have used a previous version, you will have to delete the switch entity manually as it is no longer provided by the integration, it will still be there after a restart if not deleted manually.

Copy link

github-actions bot commented Jan 8, 2024

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

@github-actions github-actions bot added the stale Issue is inactivate and might get closed soon label Jan 8, 2024
@ShogunMan
Copy link
Contributor Author

ShogunMan commented Jan 8, 2024

How about pulling this one? It works as it should.
Or should we just let it die :-)

I am currently using this custom quirk.

@github-actions github-actions bot removed the stale Issue is inactivate and might get closed soon label Jan 8, 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.

LGTM, thanks!

@TheJulianJES TheJulianJES self-assigned this Jan 19, 2024
@TheJulianJES TheJulianJES merged commit 729bffd into zigpy:dev Jan 19, 2024
2 checks passed
@ShogunMan ShogunMan deleted the add-TS0041A branch January 20, 2024 01:05
lgraf pushed a commit to lgraf/zha-device-handlers that referenced this pull request May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new quirk Adds support for a new device Tuya Request/PR regarding a Tuya device
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants