-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Feature request]: Improve Home Assistant integration by reusing other entity behavior #22098
Comments
Can't we solve this by stripping the |
Yes and No. That could work when the suffix comes from the endpoint but this is not always the case. The PJ-12304 is using Tuya datapoints so there is no endpoint. The proposed feature is more flexible especially if Similarly, a new method
For example
It could become either
or
Both would result in |
I haven't tried, but I think it should give no problems when using the |
Do not see the behavior as something specific to HA. This is more a kind of hint about the real nature of the attribute. Relying on the attribute name is really not nice since that requires that all possible names should be hard-coded in Consider for instance the recent TIC device: https://github.com/Koenkk/zigbee-herdsman-converters/blob/cd1638889237d50de2f62e1fed490d22294e4d15/src/devices/gmmts.ts#L219 . |
Definitely not! But how would you see this? There is a specific set of |
Is your feature request related to a problem? Please describe
I have multiple plugs with energy monitoring and also a PJ-1203A (Bidirectional energy meter with 80A current clamp). The former are working fine in Home Assistant but for the later, I noticed that I cannot display statistic graphs for the
power_a
,power_b
andpower_ab
entities. I eventually figured out that this is because those entities are missing in the Home Assistant integration.zigbee2mqtt/lib/extension/homeassistant.ts
Line 803 in ffc2ff1
Adding the missing entities in the lookup table works fine (until I update zigbee2mqtt) but there are other devices that use different names for similar values (e.g.
power_l1
,power_phase_a
,load
, ... ) so a generic solution could be welcome. The annoying thing is that there is no way to control the HA integration from the converter itself.I understand that Home Assistant features should not be exposed in
zigbee-herdsman-converters
but I believe that there is an easy solution.Describe the solution you'd like
The integration in
homeassistant.ts
is making extensive use of lookup tables using the entity name as key. This is not a good approach because a lot of converters (including external ones) are using names that are not listed there.My proposal is to introduce a new field
behavior
and an associated member in all Expose objects:In
homeassistant.ts
, a few occurrences oflookup[firstExpose.name ]
must be transformed intolookup[firstExpose.behavior || firstExpose.name ]
.The idea is that the keys in
homeassistant.ts
are now treated as behaviors and the default behavior is the name of the entity. The changes are very small and should not break any existing converter.Any entity or predefined expose helper can then declared to follow a known behavior
foobar
using.withBehavior('foobar')
It could be worth spending a few minutes or hours to clean up the lookup tables since some entries are now redundant (e.g. add
.withBehavior('voltage')
involtageWithPhase()
and then removevoltage_phase_b
andvoltage_phase_c
fromhomeassistant.ts
). As a second thought, obsolete behaviors should probably be kept to avoid breaking external converters that may still be using them (emit a warning?).Describe alternatives you've considered
The HA integration could be tuned using the unit (as for
Wh
andkWh
) but this is not very flexible.Additional context
none
The text was updated successfully, but these errors were encountered: