Change Third Reality soil moisture sensor device class 3RSM0147Z#3780
Change Third Reality soil moisture sensor device class 3RSM0147Z#3780TheJulianJES merged 10 commits intozigpy:devfrom
3RSM0147Z#3780Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #3780 +/- ##
=======================================
Coverage 92.95% 92.95%
=======================================
Files 394 394
Lines 13173 13174 +1
=======================================
+ Hits 12245 12246 +1
Misses 928 928 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Not sure why the proposed change and additional information sections didn't populate. This is a quirk v2 for the 3RSM0147Z which replaces the humidity sensor for a soil moisture sensor, since the device is intended to be used to measure soil moisture and temperature. I am currently using this in my ZHA implementation for two devices. |
|
Thanks for sharing this. I've tried it and it works wonders. As a temporary workaround for others using home assistant and waiting for this to make it upstream: If you haven't already configured a directory for custom ZHA quirks, do so in your zha:
enable_quirks: true
custom_quirks_path: /config/custom_zha_quirksNext, add the |
|
@TheJulianJES any chance this can get a pair of eyes? As Josh wrote above, they're sold as "soil moisture sensors" but show up as humidity sensors. This change takes care of that. |
|
I think renaming the cluster ID is a little too hacky, in my opinion. Untested, but you should be able to just directly create the exact entity you want: from zigpy.quirks.v2 import QuirkBuilder, ReportingConfig
from zigpy.zcl.clusters.measurement import RelativeHumidity, SoilMoisture
from zhaquirks import CustomCluster
(
QuirkBuilder("Third Reality, Inc", "3RSM0147Z")
# Ignore the default relative humidity entity
.prevent_default_entity_creation(cluster_id=RelativeHumidity, endpoint_id=1)
# And instead create a new one
.sensor(
attribute_name=RelativeHumidity.AttributeDefs.measured_value.name,
cluster_id=RelativeHumidity.cluster_id,
state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.HUMIDITY,
reporting_config=ReportingConfig(
min_interval=30,
max_interval=900,
reportable_change=100,
),
translation_key="soil_moisture",
fallback_name="Soil moisture",
)
.add_to_registry()
) |
|
Yeah, that. But do note that we'd still break every instance where the relative humidity sensor is currently used, so everyone would have to switch then. |
|
Nice! I think we might not even need |
|
My entire motivating factor for this quirk was to change the device class to moisture so it would be available as a soil moisture sensor when configuring a new entity for the Plant Monitor (HACS version). So this instead of will accomplish that. (I don't think |
TheJulianJES
left a comment
There was a problem hiding this comment.
Sorry for the long wait on this. I believe we can do this in a much better way now with change_entity_metadata. We should be able to remove both the custom sensor and prevent_default_entity_creation. Then, add something like this:
.change_entity_metadata(
endpoint_id=1,
cluster_id=RelativeHumidity.cluster_id,
new_device_class: SensorDeviceClass.MOISTURE,
)Please let me know if this works as well!
|
This worked: Using When I got the error, the device loaded without the quirk and it still showed the entity as soil moisture instead of humidity. I won't have a chance for a few days to remove the device and re-pair it yet to see if the quirk is actually needed any longer. I am not sure if there was some other update to ZHA that may have supersedes this. And TR appears to be working on something for it, too, so I don't want these to conflict. |
Ah, this is a ZHA issue with how it processes |
|
I believe
I've pushed some changes to this PR that should work. |
3RSM0147Z
There was a problem hiding this comment.
Pull request overview
This PR updates the v2 quirk for Third Reality soil moisture sensors so the measurement currently exposed via the RelativeHumidity cluster is represented in Home Assistant as a moisture sensor (rather than a humidity sensor), aligning the entity with the device’s intended purpose.
Changes:
- Import
SensorDeviceClassandRelativeHumidityto support HA metadata updates. - Use
QuirkBuilder.change_entity_metadata()to set theRelativeHumidityentity’sdevice_classtoSensorDeviceClass.MOISTURE.
| ( | ||
| QuirkBuilder("Third Reality, Inc", "3RSM0147Z") | ||
| .applies_to("Third Reality, Inc", "3RSM0347Z") | ||
| .replaces(ThirdRealitySoilMoistureCluster) | ||
| .change_entity_metadata( | ||
| endpoint_id=1, | ||
| cluster_id=RelativeHumidity.cluster_id, | ||
| new_device_class=SensorDeviceClass.MOISTURE, | ||
| ) |
There was a problem hiding this comment.
The PR description says the RelativeHumidity cluster is being changed to a SoilMoisture cluster and that tests were added, but the code change here only adjusts Home Assistant entity metadata (device class) for the existing RelativeHumidity entity and there are no corresponding test changes. Either update the PR description/checklist to match what’s implemented, or extend the change (and tests) to fully achieve the stated behavior.
There was a problem hiding this comment.
Yeah, the PR description should probably be updated slightly.
TheJulianJES
left a comment
There was a problem hiding this comment.
I've regenerated ZHA diagnostics with this and the device class seems to have changed correctly. Thanks for the PR and helping getting this working!
|
@iamjoshk What is the purpose of this modification, to change the humidity to soil moisture? Display 2 soil entities? I used the latest 2026.4.1 version, but it didn't have much effect. There is still humidity |
|
In the future, we will remove excess humidity entities and only display temperature entities and soil moisture entities |


Proposed change
This quirk v2 changes the RelativeHumidity cluster for a SoilMoisture cluster to change the exposed entity from a humidity sensor to a soil moisture sensor, which is what this device is intended to measure.
Additional information
This Third Reality device measures temperature and soil moisture, but the soil moisture is exposed as Humidity in the default configuration.
I am currently using this quirk in my own ZHA integration.
Checklist
pre-commitchecks pass / the code has been formatted using Black