-
Notifications
You must be signed in to change notification settings - Fork 710
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
Please add support in ZHA for TZE200_ya4ft0w4 Tuya M100 Presence Sensor #3584
Comments
I also got this model, TZE200_ya4ft0w4, which seems to be a new version. There are no quirks available for it yet. Could you please add support for this device? With this model, in the Smart Life app, the human detection status is displayed as three states: cleared, moving, and exits. However, when connected to ZHA, no entities are detected at all. If I connect it through the Tuya integration via the Tuya Zigbee hub in Home Assistant, it only displays two states: cleared and occupancy. The issue is that when the status is moving in the Smart Life app, it is interpreted as cleared in Home Assistant, which makes it unusable. I would prefer ZHA to support this device rather than relying on the Tuya integration. Thank you! |
Hi, I have the same model. Does he have no quirk at all? |
I tried putting the model in various areas with no success. I think it involves more than that. |
This should get you started, the rest of the DPs can be found in the z2m source This is mapping the presence and move states to an occupied state. from zhaquirks.tuya.builder import TuyaQuirkBuilder
from zhaquirks.tuya import TuyaLocalCluster
from zigpy.zcl.clusters.measurement import OccupancySensing
class TuyaOccupancySensing(OccupancySensing, TuyaLocalCluster):
"""Tuya local OccupancySensing cluster."""
(
TuyaQuirkBuilder("_TZE200_ya4ft0w4", "TS0601")
.tuya_dp(
dp_id=1,
ep_attribute=TuyaOccupancySensing.ep_attribute,
attribute_name=OccupancySensing.AttributeDefs.occupancy.name,
converter=lambda x: True if x in (1, 2) else False,
)
.adds(TuyaOccupancySensing)
.skip_configuration()
.add_to_registry()
) |
Thank you. Not sure how I would implement this. Would I add it to the existing quirk? |
Assuming you have enabled custom quirks, if not the ZHA docs detail how to enable them, then just save it to a file in the custom quirk directory. It's the newer v2 format, see the following links for more details on extending it. https://github.com/zigpy/zha-device-handlers/blob/dev/tuya.md If you get a |
I will give it a try. |
Well I looked into things this morning and realized I am out of my depth. I don't know how I integrate this new code with my existing quirk which I have included below. I do have other presence sensors and don't want to mess them up. CODE: """BlitzWolf IS-3/Tuya motion rechargeable occupancy sensor.""" import math from zigpy.profiles import zgp, zha from zhaquirks import Bus, LocalDataCluster, MotionOnEvent ZONE_TYPE = 0x0001 class TuyaMmwRadarSelfTest(t.enum8):
class TuyaOccupancySensing(OccupancySensing, TuyaLocalCluster): class TuyaAnalogInput(AnalogInput, TuyaLocalCluster): class TuyaIlluminanceMeasurement(IlluminanceMeasurement, TuyaLocalCluster): class TuyaMmwRadarSensitivity(TuyaAttributesCluster, AnalogOutput):
class TuyaMmwRadarMinRange(TuyaAttributesCluster, AnalogOutput):
class TuyaMmwRadarMaxRange(TuyaAttributesCluster, AnalogOutput):
class TuyaMmwRadarDetectionDelay(TuyaAttributesCluster, AnalogOutput):
class TuyaMmwRadarFadingTime(TuyaAttributesCluster, AnalogOutput):
class TuyaTemperatureMeasurement(TemperatureMeasurement, TuyaLocalCluster): class TuyaRelativeHumidity(RelativeHumidity, TuyaLocalCluster): class NeoBatteryLevel(t.enum8):
class NeoMotionManufCluster(TuyaNewManufCluster):
class TuyaMmwRadarTargetDistance(TuyaAttributesCluster, AnalogInput):
class MmwRadarManufCluster(TuyaMCUCluster):
class MotionCluster(LocalDataCluster, MotionOnEvent):
class TuyaManufacturerClusterMotion(TuyaManufCluster):
class TuyaMotion(CustomDevice):
class NeoMotion(CustomDevice):
class MmwRadarMotion(CustomDevice):
class MmwRadarMotionGPP(CustomDevice):
|
Just place the following in a file named from zhaquirks.tuya.builder import TuyaQuirkBuilder
from zhaquirks.tuya import TuyaLocalCluster
from zigpy.zcl.clusters.measurement import OccupancySensing
class TuyaOccupancySensing(OccupancySensing, TuyaLocalCluster):
"""Tuya local OccupancySensing cluster."""
(
TuyaQuirkBuilder("_TZE200_ya4ft0w4", "TS0601")
.tuya_dp(
dp_id=1,
ep_attribute=TuyaOccupancySensing.ep_attribute,
attribute_name=OccupancySensing.AttributeDefs.occupancy.name,
converter=lambda x: True if x in (1, 2) else False,
)
.adds(TuyaOccupancySensing)
.skip_configuration()
.add_to_registry()
) |
Awesome. I will try that. |
Thanks for the additional instructions. I now have Occupancy showing up in HA for the sensor which is the most important. I guess I will wait until other controls and sensors are added. I am most appreciative! |
Is it working as expected? If so, the rest of them should be fairly easy to add, just a matter of working through them. |
Yes, it appears to be working as expected.
Unfortunately I do not have the skills to add the other items.
…On Thu, Dec 12, 2024 at 10:19 AM prairiesnpr ***@***.***> wrote:
Thanks for the additional instructions. I now have Occupancy showing up in
HA for the sensor which is the most important. I guess I will wait until
other controls and sensors are added. I am most appreciative!
Is it working as expected? If do, the rest of them should be fairly easy
to add, just a matter of working through them.
—
Reply to this email directly, view it on GitHub
<#3584 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXUES2YRSIZ3THUAYPQ4LK32FGSPRAVCNFSM6AAAAABTDMCGP2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMZZGI2TMMBVHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
It works for me too! |
Let me know if you have any success. |
from zigpy.quirks.v2 import EntityType
from zigpy.quirks.v2.homeassistant import UnitOfLength, UnitOfTime
from zigpy.quirks.v2.homeassistant.sensor import SensorDeviceClass, SensorStateClass
import zigpy.types as t
from zigpy.zcl.clusters.measurement import IlluminanceMeasurement, OccupancySensing
from zhaquirks.tuya import TuyaLocalCluster
from zhaquirks.tuya.builder import TuyaQuirkBuilder
class TuyaIlluminanceCluster(IlluminanceMeasurement, TuyaLocalCluster):
"""Tuya Illuminance cluster."""
class TuyaOccupancySensing(OccupancySensing, TuyaLocalCluster):
"""Tuya local OccupancySensing cluster."""
(
TuyaQuirkBuilder("_TZE200_ya4ft0w4", "TS0601")
.tuya_dp(
dp_id=1,
ep_attribute=TuyaOccupancySensing.ep_attribute,
attribute_name=OccupancySensing.AttributeDefs.occupancy.name,
converter=lambda x: True if x in (1, 2) else False,
)
.adds(TuyaOccupancySensing)
.tuya_number(
dp_id=2,
attribute_name="move_sensitivity",
type=t.uint16_t,
min_value=0,
max_value=10,
step=1,
translation_key="move_sensitivity",
fallback_name="Motion sensitivity",
)
.tuya_number(
dp_id=3,
attribute_name="detection_distance_min",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
min_value=0,
max_value=8.25,
step=0.75,
translation_key="detection_distance_min",
fallback_name="Minimum range",
)
.tuya_number(
dp_id=4,
attribute_name="detection_distance_max",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
min_value=0.75,
max_value=9.0,
step=0.75,
translation_key="detection_distance_max",
fallback_name="Maximum range",
)
.tuya_sensor(
dp_id=9,
attribute_name="distance",
type=t.uint16_t,
divisor=10,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
entity_type=EntityType.STANDARD,
translation_key="distance",
fallback_name="Target distance",
)
.tuya_switch(
dp_id=101,
attribute_name="find_switch",
entity_type=EntityType.STANDARD,
translation_key="find_switch",
fallback_name="Distance switch",
)
.tuya_number(
dp_id=102,
attribute_name="presence_sensitivity",
type=t.uint16_t,
min_value=0,
max_value=10,
step=1,
translation_key="presence_sensitivity",
fallback_name="Presence sensitivity",
)
.tuya_dp(
dp_id=103,
ep_attribute=TuyaIlluminanceCluster.ep_attribute,
attribute_name=TuyaIlluminanceCluster.AttributeDefs.measured_value.name,
)
.adds(TuyaIlluminanceCluster)
.tuya_number(
dp_id=105,
attribute_name="presence_timeout",
type=t.uint16_t,
device_class=SensorDeviceClass.DURATION,
unit=UnitOfTime.SECONDS,
min_value=1,
max_value=15000,
step=1,
translation_key="presence_timeout",
fallback_name="Fade time",
)
.skip_configuration()
.add_to_registry()
) |
Unfortunately it is not working. ZHA fails to load. This is an excerpt of some of the Log file if this helps. 2024-12-13 18:46:39.464 WARNING (SyncWorker_7) [zhaquirks] Loaded custom quirks. Please contribute them to https://github.com/zigpy/zha-device-handlers |
Hi, first of all, thanks for the help! Log 1: `Logger: homeassistant.config_entries Error setting up entry Zigbee-Hub for zha Log 2: `Error setting up entry Zigbee-Hub for zha Traceback (most recent call last): |
I missed |
Try the updated version above |
Hi, I found more log that may explain why I don't have all the controls `Logger: zha.application.gateway Failed to create platform entity: <class 'zha.application.platforms.number.NumberConfigurationEntity'> [args=('e4:98:bb:43:00:8d:58:22-1', [<zha.zigbee.cluster_handlers.manufacturerspecific.TuyaClusterHandler object at 0x7f31abd456d0>], <zha.zigbee.endpoint.Endpoint object at 0x7f31abd45490>, - quirk_applied: True - quirk_or_device_class: zigpy.quirks.v2.CustomDeviceV2 - quirk_id: None), kwargs={'entity_metadata': NumberMetadata(entity_platform=<EntityPlatform.NUMBER: 'number'>, entity_type=<EntityType.CONFIG: 'config'>, cluster_id=61184, endpoint_id=1, cluster_type=<ClusterType.Server: 0>, initially_disabled=False, attribute_initialized_from_cache=True, translation_key='detection_distance_min', fallback_name='Minimum range', attribute_name='detection_distance_min', reporting_config=None, min=0, max=8.25, step=0.75, unit=<UnitOfLength.METERS: 'm'>, mode=None, multiplier=None, device_class=<SensorDeviceClass.DISTANCE: 'distance'>)}] |
Glad you understand why. I sure don’t. Thanks to you both for helping out! |
Please make sure you are on the latest HA. I'm seeing python 3.12 in your logs and I would expect 3.13. |
Yup😅 you are correct I will update HA and check again |
Ok, I updated HA and now I have all the controls. but Illuminance is not working as expected it only shows 1 lx. |
Maybe try switching the stuff in the mfgr app |
Sorry, in what app? |
There are a few options here, if it's working for @Rabman416, then it's possible you have a defective device, does it work when paired to a Tuya hub? It's also possible that the devices have different firmware and don't use the same DPs. The quirk above is based on the z2m converter, and should work the same, I did see that there are widely reported issues with the illuminance measurement for this sensor though. You can enable debug logging in ZHA, note the start and end timestamps and the device ieee and nwk, run it through all of its paces, then attach the logs and we can see if there is anything logged. |
Sorry forget about my comment about app. I am also trying to get the wifi version working. I am using the Smart Life app for it and the TUYA integration. Maximum range works but looks like it needs to be divide by 100. Sliders do change and stay where I set them. |
Yes, it is working as I expected in the Tuya app with a Tuya hub, the illuminance, and all the controls. |
all the sliders?? |
Add |
My mistake on this. It was the Wifi version, not the Zigbee. |
All the sliders work. The illumination sensor shows only 1 or 2. Some other posts indicated the hole in the sensor needed to be enlarged. Never tried it though. My model is a Loginovo ZY-M100-24G |
Ok, then the illumination sensor acts the same as mine. but in the Tuya app, it works like normal so it is a ZHA problem. I don't get why then the Maximum range sliders don't work in mine. we have the same model |
I'm thinking that it's not scaled correctly, there isn't any scaling in z2m either, but looking at the other Tuya quirk, they use You might try the following and see if it looks better, otherwise you would need to reverse engineer the scaling. import math
from zigpy.quirks.v2 import EntityType
from zigpy.quirks.v2.homeassistant import UnitOfLength, UnitOfTime
from zigpy.quirks.v2.homeassistant.sensor import SensorDeviceClass, SensorStateClass
import zigpy.types as t
from zigpy.zcl.clusters.measurement import IlluminanceMeasurement, OccupancySensing
from zhaquirks.tuya import TuyaLocalCluster
from zhaquirks.tuya.builder import TuyaQuirkBuilder
class TuyaIlluminanceCluster(IlluminanceMeasurement, TuyaLocalCluster):
"""Tuya Illuminance cluster."""
class TuyaOccupancySensing(OccupancySensing, TuyaLocalCluster):
"""Tuya local OccupancySensing cluster."""
(
TuyaQuirkBuilder("_TZE200_ya4ft0w4", "TS0601")
.tuya_dp(
dp_id=1,
ep_attribute=TuyaOccupancySensing.ep_attribute,
attribute_name=OccupancySensing.AttributeDefs.occupancy.name,
converter=lambda x: True if x in (1, 2) else False,
)
.adds(TuyaOccupancySensing)
.tuya_number(
dp_id=2,
attribute_name="move_sensitivity",
type=t.uint16_t,
min_value=0,
max_value=10,
step=1,
translation_key="move_sensitivity",
fallback_name="Motion sensitivity",
)
.tuya_number(
dp_id=3,
attribute_name="detection_distance_min",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
min_value=0,
max_value=8.25,
step=0.75,
translation_key="detection_distance_min",
fallback_name="Minimum range",
)
.tuya_number(
dp_id=4,
attribute_name="detection_distance_max",
type=t.uint16_t,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
min_value=0.75,
max_value=9.0,
step=0.75,
translation_key="detection_distance_max",
fallback_name="Maximum range",
)
.tuya_sensor(
dp_id=9,
attribute_name="distance",
type=t.uint16_t,
divisor=10,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.DISTANCE,
unit=UnitOfLength.METERS,
entity_type=EntityType.STANDARD,
translation_key="distance",
fallback_name="Target distance",
)
.tuya_switch(
dp_id=101,
attribute_name="find_switch",
entity_type=EntityType.STANDARD,
translation_key="find_switch",
fallback_name="Distance switch",
)
.tuya_number(
dp_id=102,
attribute_name="presence_sensitivity",
type=t.uint16_t,
min_value=0,
max_value=10,
step=1,
translation_key="presence_sensitivity",
fallback_name="Presence sensitivity",
)
.tuya_dp(
dp_id=103,
ep_attribute=TuyaIlluminanceCluster.ep_attribute,
attribute_name=TuyaIlluminanceCluster.AttributeDefs.measured_value.name,
converter=lambda x: 10000 * math.log10(x) + 1 if x != 0 else 0,
)
.adds(TuyaIlluminanceCluster)
.tuya_number(
dp_id=105,
attribute_name="presence_timeout",
type=t.uint16_t,
device_class=SensorDeviceClass.DURATION,
unit=UnitOfTime.SECONDS,
min_value=1,
max_value=15000,
step=1,
translation_key="presence_timeout",
fallback_name="Fade time",
)
.skip_configuration()
.add_to_registry()
) |
OK, I’ll have to try it out this evening. Thanks for all your hard work. |
Well it is presenting a higher number now....no clue as to whether it is correct or not. Better than 1-2 lx though. |
Problem description
The Tuya Presence Sensor is not supported in the ts0601_motion.py Quirk.
Solution description
Would like the presence sensor device to show the controls and sensors.
Screenshots/Video
Screenshots/Video
Device signature
Device signature
Diagnostic information
Diagnostic information
Logs
Logs
Custom quirk
Custom quirk
Additional information
I tried entering the device name in the different various sections of the current Quirk with no success. It only shows two Diagnostic entities. Does not show the controls or sensor information.
This is the link to the device 24G Presence sensor on AliExpress. I did order from this vendor before and the device name on that order came as _TZE204_7gclukjs and it works.
https://www.aliexpress.com/item/1005005249827156.html?spm=a2g0o.order_list.order_list_main.5.54441802Kg4T6C
The text was updated successfully, but these errors were encountered: