-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from mdeweerd/dev
Add Tuya magic spell
- Loading branch information
Showing
7 changed files
with
137 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from custom_components.zha_toolkit import utils as u | ||
from custom_components.zha_toolkit.params import INTERNAL_PARAMS as p | ||
|
||
|
||
async def tuya_magic( | ||
app, listener, ieee, cmd, data, service, params, event_data | ||
): | ||
|
||
dev = app.get_device(ieee) | ||
"""Initialize device so that all endpoints become available.""" | ||
basic_cluster = dev.endpoints[1].in_clusters[0] | ||
|
||
# The magic spell is needed only once. | ||
# TODO: Improve by doing this only once (successfully). | ||
|
||
# Magic spell - part 1 | ||
attr_to_read = [4, 0, 1, 5, 7, 0xFFFE] | ||
res = await u.cluster_read_attributes( | ||
basic_cluster, attr_to_read, tries=params[p.TRIES] | ||
) | ||
|
||
event_data["result"] = res | ||
|
||
# Magic spell - part 2 (skipped - does not seem to be needed) | ||
# attr_to_write={0xffde:13} | ||
# basic_cluster.write_attributes(attr_to_write, tries=3) |
This file contains 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
This file contains 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