I’ve been building my own Zigbee device that has two temperature probes.
Each temperature is reported by its own Temperature Measurement cluster (0x0402), and each cluster is in its own endpoint (10 and 11).
Both measurements appear in Home Assistant (added via ZHA) and updating according to the reporting configuration.
So far so good. But I intended on adding 10 of these sensors and I don’t want to have two Entities with the same “Temperature” name.
I want one to be called “Flow Temperature” and one to be called “Return Temperature” and I’d like the entity ids to match i.e. sensor.device_name_flow_temperature.
Is there any way to provide HomeAssistant with this information by default, so when the device is paired, the entities are named correctly?? I can’t find anything in the Zigbee specification about changing a cluster’s name, thought it feels obvious!
Another option seems to be creating a custom cluster and using zha-quirks to handle it, but that makes the device less portable.
Any advice would be very, very welcome!!!
Short answer, no. Most general clusters allow setting this through the description attribute (0x001C), but it’s not present on the Temperature cluster. Even if it was, ZHA doesn’t currently honor it. Add AnalogInput, MultistateInput, use description attribute for fallback_name by prairiesnpr · Pull Request #197 · zigpy/zha · GitHub
Thanks - I skimmed the PR comment history and it sounds like you know your stuff!!
Do you think that adding my own custom cluster and using zha-quirks is the way to go?
I wouldn’t or at least I didn’t bother to when I built out my quad ds18b20 sensor. Even if you could pass the description to HA, it’s not a guarantee that the sensor is where it says it is. I’d just rename the entity once joined.
The only downside to that is I haven’t 12 of them to add. I’m trying to think of ways to make this process easier for people.
If you have to add 12 sensors, renaming could be quite tedious. That’s all I was thinking.
I don’t disagree. If you did go the quirk route, I’d still leave it on the temperature clusters so that it would work per the standard. Then you could write a custom v2 quirk that would replace the temperature cluster with a custom cluster. Then expose the value using .sensor
.
That’s an excellent suggestion! If you want to leave as is, you can use it out of the box. If you want a better experience, add some quirk support! Thanks!
I gave this a go, but unfortunately, the sensor is still just called temperature.
I’ve tried the Quicks v2 QuirkBuilder and wrote this:
(
QuirkBuilder("coldbear", "FART Sensor")
.replaces(TemperatureMeasurement, endpoint_id=5)
.sensor(
TemperatureMeasurement.AttributeDefs.measured_value.name,
TemperatureMeasurement.cluster_id,
endpoint_id=5,
multiplier=0.01,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
unit=UnitOfTemperature.CELSIUS,
translation_key="flow_temperature",
fallback_name="Flow Temperature",
)
.replaces(TemperatureMeasurement, endpoint_id=7)
.sensor(
TemperatureMeasurement.AttributeDefs.measured_value.name,
TemperatureMeasurement.cluster_id,
endpoint_id=7,
multiplier=0.01,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
unit=UnitOfTemperature.CELSIUS,
translation_key="return_temperature",
fallback_name="Return Temperature",
)
.add_to_registry()
)
I’m finding it hard documentation for the Quicks v2, so this is just trial and error. The Quirk is being picked up and applied, but it’s not working.
Firstly, the existing clusters don’t get replaced, so I end up with four entities and secondly, they are all just called Temperature.
Any suggesions?
You need to provide a replacement cluster that’s not a temperature cluster. Pick a cluster id that’s in the manufacturer specific region per the zcl, it should inherit from CustomCluster
. I think I’d look at zha-device-handlers/zhaquirks/xiaomi/aqara/motion_agl1.py at 0156ab9f6e4e52f5f6f07f8be716b6c9f7c00789 · zigpy/zha-device-handlers · GitHub as an example of adding attributes and then setting them. Your .replaces
would then provide the cluster id to replace in addition to the replacement cluster. I think you also need to use a custom attribute name in your sensor or it will get translated instead of falling back, so your custom cluster would write the temperature attribute to a custom attribute then your sensor would listen to the same attribute.
There is a doc PR that you can look at for v2 quirks or look at the tests in zigpy.