-
Notifications
You must be signed in to change notification settings - Fork 730
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
[Device Support Request] Tuya ultrasonic level sensor (TS0601 by _TZE284_kyyu8rbj) #3356
Comments
@hickey - Any luck with this? Just got one and am trying to get it going and have made some progress but wouldn't mind some input |
{ This is what I have with state now |
{ with support from supplier I am almost there |
I bought the same Zigbee peripheral. I'm very interested in the developments. |
Can you share your quirk? @brooksaw |
its working, and fine for me currenlty. I had issues with UnitOfLength, but that should be fixed |
Building off of @syc0n, this might expose a bit more functionality, untested, don't have the device. from zigpy.quirks.v2 import EntityType
from zigpy.quirks.v2.homeassistant import PERCENTAGE, UnitOfLength
from zigpy.quirks.v2.homeassistant.sensor import SensorDeviceClass, SensorStateClass
import zigpy.types as t
from zhaquirks.tuya.builder import TuyaQuirkBuilder
class TuyaLiquidState(t.enum8):
"""Tuya Liquid State Enum."""
Normal = 0x00
Low = 0x01
High = 0x02
(
TuyaQuirkBuilder("_TZE284_kyyu8rbj", "TS0601")
.tuya_enum(
dp_id=1,
attribute_name="liquid_state",
enum_class=TuyaLiquidState,
translation_key="liquid_state",
fallback_name="Liquid state",
)
.tuya_sensor(
dp_id=2,
attribute_name="liquid_depth",
type=t.uint16_t,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
entity_type=EntityType.STANDARD,
converter=lambda x: x / 1000,
translation_key="liquid_depth",
fallback_name="Liquid depth",
)
.tuya_sensor(
dp_id=22,
attribute_name="liquid_level_percent",
type=t.uint16_t,
state_class=SensorStateClass.MEASUREMENT,
unit=PERCENTAGE,
entity_type=EntityType.STANDARD,
translation_key="liquid_level_percent",
fallback_name="Liquid level ratio",
)
.tuya_number(
dp_id=7,
attribute_name="max_set",
type=t.uint16_t,
unit=PERCENTAGE,
min_value=0,
max_value=100,
step=1,
translation_key="max_set",
fallback_name="Liquid max percentage",
)
.tuya_number(
dp_id=8,
attribute_name="mini_set",
type=t.uint16_t,
unit=PERCENTAGE,
min_value=0,
max_value=100,
step=1,
translation_key="mini_set",
fallback_name="Liquid minimal percentage",
)
.tuya_number(
dp_id=19,
attribute_name="installation_height",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.MILLIMETERS,
min_value=100,
max_value=4000,
step=1,
translation_key="installation_height",
fallback_name="Height from sensor to tank bottom",
)
.tuya_number(
dp_id=21,
attribute_name="liquid_depth_max",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.MILLIMETERS,
min_value=100,
max_value=2000,
step=1,
translation_key="liquid_depth_max",
fallback_name="Height from sensor to liquid level",
)
.skip_configuration()
.add_to_registry()
) |
Based on previous comments this is what I've got so far. Basically I moved the state to Diagnosis, removed PERCENTAGE units since values doesn't show if this is specified and corrected the distance units to match the actual values. from zigpy.quirks.v2 import EntityType
from zigpy.quirks.v2.homeassistant import PERCENTAGE, UnitOfLength
from zigpy.quirks.v2.homeassistant.sensor import SensorDeviceClass, SensorStateClass
import zigpy.types as t
from zhaquirks.tuya.builder import TuyaQuirkBuilder
class TuyaLiquidState(t.enum8):
"""Tuya Liquid State Enum."""
Normal = 0x00
Low = 0x01
High = 0x02
(
TuyaQuirkBuilder("_TZE284_kyyu8rbj", "TS0601")
.tuya_enum(
dp_id=1,
attribute_name="liquid_state",
enum_class=TuyaLiquidState,
entity_type=EntityType.DIAGNOSTIC,
translation_key="liquid_state",
fallback_name="Liquid state",
)
.tuya_sensor(
dp_id=2,
attribute_name="liquid_depth",
type=t.uint16_t,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
entity_type=EntityType.STANDARD,
converter=lambda x: x / 100,
translation_key="liquid_depth",
fallback_name="Liquid depth",
)
.tuya_sensor(
dp_id=22,
attribute_name="liquid_level_percent",
type=t.uint16_t,
state_class=SensorStateClass.MEASUREMENT,
entity_type=EntityType.STANDARD,
translation_key="liquid_level_percent",
fallback_name="Liquid level ratio",
)
.tuya_number(
dp_id=7,
attribute_name="max_set",
type=t.uint16_t,
min_value=0,
max_value=100,
step=1,
translation_key="max_set",
fallback_name="Liquid max percentage",
)
.tuya_number(
dp_id=8,
attribute_name="mini_set",
type=t.uint16_t,
min_value=0,
max_value=100,
step=1,
translation_key="mini_set",
fallback_name="Liquid minimal percentage",
)
.tuya_number(
dp_id=19,
attribute_name="installation_height",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.CENTIMETERS,
min_value=10,
max_value=400,
step=1,
translation_key="installation_height",
fallback_name="Height from sensor to tank bottom",
)
.tuya_number(
dp_id=21,
attribute_name="liquid_depth_max",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.CENTIMETERS,
min_value=10,
max_value=400,
step=1,
translation_key="liquid_depth_max",
fallback_name="Height from sensor to liquid level",
)
.skip_configuration()
.add_to_registry()
) |
Is this quirk working, if so will you be submitting a PR? |
It is working, altough, I'm making more tests to figure out why is the PERCENTAGE unit not working. Once I figure this out I can submit a PR. |
The percent issue is in ZHA, zigpy/zha#327 |
I'm having trouble with the The issue with the level percent could be a problem with my sensor, so if anyone can confirm it works on their device it would be awsome. |
If you could enable debug logging and grab the logs when |
Problem description
Recently bought the Tuya ultrasonic liquid level sensor (https://www.aliexpress.us/item/3256807266442468.html?spm=a2g0o.order_list.order_list_main.11.21ef1802lD5999&gatewayAdapt=glo2usa) and while it will pair with ZHA, it only reports LQI and RSSI.
I am very new (i.e. just started reading about ZHA quirks) and would like to assist/work on this quirk. Mostly I will probably need some guidance and basic information for building the Python script for the quirk. Part of the reason I would like to work on this quirk is to better understand the Zigbee protocols, add to the volunteers contributing quirks and write a quirk for the Tuya water quality sensor I also got (this has many more values to read and will be much more interesting project).
I am making the assumption from the diagnostic output below that the
reporting_status
is the attribute that contains the level value. So it seems that this should be a pretty straight forward quirk to implement.Solution description
I am envisioning a custom quirk that reports back a single value to ZHA which is the last level measured.
Screenshots/Video
Screenshots/Video
[Paste/upload your media here]
Device signature
Device signature
Diagnostic information
Diagnostic information
Logs
Logs
Custom quirk
Custom quirk
Additional information
No response
The text was updated successfully, but these errors were encountered: