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 Tuya v2 quirk builder #3417

Merged
merged 40 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
851d54f
Clean up soil sensors.
prairiesnpr Oct 11, 2024
8555f3e
Refactor
prairiesnpr Oct 11, 2024
ded6e7a
Need to set in init.
prairiesnpr Oct 11, 2024
88068fc
Add power, temp, and soil functions
prairiesnpr Oct 11, 2024
4e7fb61
Cleanup, set defaults
prairiesnpr Oct 11, 2024
91a4012
Cleanup, set defaults
prairiesnpr Oct 11, 2024
6b32bff
all kwargs
prairiesnpr Oct 11, 2024
f1906b0
Remove default DPs, Simplify scaling
prairiesnpr Oct 11, 2024
c9cc9b2
Don't format tuya_dp function def
prairiesnpr Oct 11, 2024
b83c29f
Add EntityMetadata methods
prairiesnpr Oct 12, 2024
c6d5f30
Initial tests
prairiesnpr Oct 12, 2024
241a50f
Clean up soil sensors.
prairiesnpr Oct 11, 2024
ac35ab9
Refactor
prairiesnpr Oct 11, 2024
a698b9d
Need to set in init.
prairiesnpr Oct 11, 2024
63725d9
Add power, temp, and soil functions
prairiesnpr Oct 11, 2024
316d3f6
Cleanup, set defaults
prairiesnpr Oct 11, 2024
6458e02
Cleanup, set defaults
prairiesnpr Oct 11, 2024
9e8fade
all kwargs
prairiesnpr Oct 11, 2024
3c7e5fc
Remove default DPs, Simplify scaling
prairiesnpr Oct 11, 2024
bc790aa
Don't format tuya_dp function def
prairiesnpr Oct 11, 2024
2123900
Add EntityMetadata methods
prairiesnpr Oct 12, 2024
56266db
Initial tests
prairiesnpr Oct 12, 2024
ac9ccc7
Merge remote-tracking branch 'origin/clean-up-soil-sensors' into clea…
prairiesnpr Oct 13, 2024
24d3e4c
Move TuyaQuirkBuilder out of MCU, use AttrDefs
prairiesnpr Oct 13, 2024
a90674a
Remove unused logging
prairiesnpr Oct 13, 2024
6803bc0
Revert unrelated changes
prairiesnpr Oct 13, 2024
fac92fe
Add converter and dp_converter to tuya_sensor
prairiesnpr Oct 14, 2024
c3d1c93
Ensure mcu_version attr is present.
prairiesnpr Oct 14, 2024
7f27503
Add humidity method
prairiesnpr Oct 14, 2024
eff64ba
Require zigpy > 0.68
prairiesnpr Oct 14, 2024
868d0a8
Update tests for zigpy changes
prairiesnpr Oct 14, 2024
3ff810f
Additonal test fixes
prairiesnpr Oct 14, 2024
d47d2f4
Revert Test Updates
prairiesnpr Oct 16, 2024
c043b1f
Merge branch 'dev' of https://github.com/prairiesnpr/zha-device-handl…
prairiesnpr Oct 16, 2024
576b8e6
Update tests.
prairiesnpr Oct 16, 2024
8c28fef
Use AttributeDefs
prairiesnpr Oct 17, 2024
89cd451
Use zigpy 0.69
prairiesnpr Oct 17, 2024
87ba6f1
Code cleanup
prairiesnpr Oct 18, 2024
ea9d912
Formatting, add entity_type to binary_sensor
prairiesnpr Oct 18, 2024
f1323ac
commas and more commas
prairiesnpr Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ pytest-sugar
pytest-timeout
pytest-asyncio
pytest>=7.1.3
zigpy>=0.66.0
zigpy>=0.68.1
ruff==0.0.261
43 changes: 43 additions & 0 deletions tests/async_mock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Mock utilities that are async aware."""

from unittest.mock import * # noqa: F401, F403


class _IntSentinelObject(int):
TheJulianJES marked this conversation as resolved.
Show resolved Hide resolved
"""Sentinel-like object that is also an integer subclass.

Allows sentinels to be used
in loggers that perform int-specific string formatting.
"""

def __new__(cls, name):
instance = super().__new__(cls, 0)
instance.name = name
return instance

def __repr__(self):
return f"int_sentinel.{self.name}"

def __hash__(self):
return hash((int(self), self.name))

def __eq__(self, other):
return self is other

__str__ = __reduce__ = __repr__


class _IntSentinel:
def __init__(self):
self._sentinels = {}

def __getattr__(self, name):
if name == "__bases__":
raise AttributeError
return self._sentinels.setdefault(name, _IntSentinelObject(name))

def __reduce__(self):
return "int_sentinel"


int_sentinel = _IntSentinel()
4 changes: 2 additions & 2 deletions tests/test_smartwings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ async def test_smartwings_inverted_commands(zigpy_device_from_quirk, quirk):
# close cover and check if the command is inverted
await covering_cluster.command(close_command_id)
assert len(device.request.mock_calls) == 1
assert device.request.mock_calls[0][1][5] == b"\x01\x01\x00"
assert device.request.mock_calls[0].kwargs["data"] == b"\x01\x01\x00"

# open cover and check if the command is inverted
await covering_cluster.command(open_command_id)
assert len(device.request.mock_calls) == 2
assert device.request.mock_calls[1][1][5] == b"\x01\x02\x01"
assert device.request.mock_calls[1].kwargs["data"] == b"\x01\x02\x01"
Loading
Loading