Fix HA entity names for derived weather sensors by removing device_class#31234
Merged
Koenkk merged 1 commit intoKoenkk:devfrom Mar 3, 2026
Merged
Fix HA entity names for derived weather sensors by removing device_class#31234Koenkk merged 1 commit intoKoenkk:devfrom
Koenkk merged 1 commit intoKoenkk:devfrom
Conversation
Z2M removes the `name` field from the MQTT discovery payload when `device_class` is present, letting HA auto-generate the entity name from the device class. For unique sensors (temperature, humidity) this works correctly. However, dew_point, wind_chill, humidex and apparent_temperature all shared device_class "temperature", causing HA to show "Temperature" for all four. Similarly, gust_speed shared device_class "wind_speed" with wind_speed, showing "Wind speed" for both. Removing device_class from these derived sensors preserves the name in the discovery payload so HA shows the correct labels. LTS is unaffected as statistics are driven by state_class and unit_of_measurement, neither of which changed.
Owner
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes
device_classfrom the followingNUMERIC_DISCOVERY_LOOKUPentries:dew_point(wastemperature)wind_chill(wastemperature)humidex(wastemperature)apparent_temperature(wastemperature)gust_speed(waswind_speed)Why
Z2M's HA discovery intentionally deletes the
namefield from the MQTT discovery payload whendevice_classis present, letting HA auto-generate the entity name from the device class. This works correctly for unique sensors — a singletemperaturesensor shows "Temperature", a singlehumiditysensor shows "Humidity", etc.However, devices that expose multiple sensors sharing the same
device_classare affected. For example, a weather station may exposedew_point,wind_chill,humidexandapparent_temperaturealongside a rawtemperaturesensor — all five previously haddevice_class: temperature, so HA showed "Temperature" for all of them. Likewise,gust_speedshareddevice_class: wind_speedwithwind_speed, causing both to show "Wind speed".Removing
device_classfrom these derived sensors preserves thenamein the discovery payload so HA displays the correct labels ("Dew point", "Wind chill", etc.). Long-term statistics are unaffected as they are driven bystate_classandunit_of_measurement, neither of which changed.