mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-23 19:19:52 +00:00
fix: Fix entity category of Home Assistant exposed enum sensors (#19474)
* Fix entity category of Home Assistant exposed enum sensors * Process review comment
This commit is contained in:
@@ -792,12 +792,6 @@ export default class HomeAssistant extends Extension {
|
||||
},
|
||||
};
|
||||
|
||||
// If it has an entity category of config, but exposed as sensor, then change
|
||||
// it to diagnostic. Sensors have no input, so can't be configured.
|
||||
if (discoveryEntry.discovery_payload.entity_category === 'config') {
|
||||
discoveryEntry.discovery_payload.entity_category = 'diagnostic';
|
||||
}
|
||||
|
||||
// When a device_class is set, unit_of_measurement must be set, otherwise warnings are generated.
|
||||
// https://github.com/Koenkk/zigbee2mqtt/issues/15958#issuecomment-1377483202
|
||||
if (discoveryEntry.discovery_payload.device_class &&
|
||||
@@ -855,8 +849,8 @@ export default class HomeAssistant extends Extension {
|
||||
} else if (firstExpose.type === 'enum') {
|
||||
const lookup: {[s: string]: KeyValue} = {
|
||||
action: {icon: 'mdi:gesture-double-tap'},
|
||||
alarm_humidity: {icon: 'mdi:water-percent-alert'},
|
||||
alarm_temperature: {icon: 'mdi:thermometer-alert'},
|
||||
alarm_humidity: {entity_category: 'config', icon: 'mdi:water-percent-alert'},
|
||||
alarm_temperature: {entity_category: 'config', icon: 'mdi:thermometer-alert'},
|
||||
backlight_auto_dim: {entity_category: 'config', icon: 'mdi:brightness-auto'},
|
||||
backlight_mode: {entity_category: 'config', icon: 'mdi:lightbulb'},
|
||||
color_power_on_behavior: {entity_category: 'config', icon: 'mdi:palette'},
|
||||
@@ -867,8 +861,8 @@ export default class HomeAssistant extends Extension {
|
||||
keep_time: {entity_category: 'config', icon: 'mdi:av-timer'},
|
||||
keypad_lockout: {entity_category: 'config', icon: 'mdi:lock'},
|
||||
load_detection_mode: {entity_category: 'config', icon: 'mdi:tune'},
|
||||
load_dimmable: {entity_category: 'diagnostic', icon: 'mdi:chart-bell-curve'},
|
||||
load_type: {entity_category: 'diagnostic', icon: 'mdi:led-on'},
|
||||
load_dimmable: {entity_category: 'config', icon: 'mdi:chart-bell-curve'},
|
||||
load_type: {entity_category: 'config', icon: 'mdi:led-on'},
|
||||
melody: {entity_category: 'config', icon: 'mdi:music-note'},
|
||||
mode_phase_control: {entity_category: 'config', icon: 'mdi:tune'},
|
||||
mode: {entity_category: 'config', icon: 'mdi:tune'},
|
||||
@@ -876,8 +870,8 @@ export default class HomeAssistant extends Extension {
|
||||
operation_mode: {entity_category: 'config', icon: 'mdi:tune'},
|
||||
power_on_behavior: {entity_category: 'config', icon: 'mdi:power-settings'},
|
||||
power_outage_memory: {entity_category: 'config', icon: 'mdi:power-settings'},
|
||||
power_supply_mode: {entity_category: 'diagnostic', icon: 'mdi:power-settings'},
|
||||
power_type: {entity_category: 'diagnostic', icon: 'mdi:lightning-bolt-circle'},
|
||||
power_supply_mode: {entity_category: 'config', icon: 'mdi:power-settings'},
|
||||
power_type: {entity_category: 'config', icon: 'mdi:lightning-bolt-circle'},
|
||||
sensitivity: {entity_category: 'config', icon: 'mdi:tune'},
|
||||
sensors_type: {entity_category: 'config', icon: 'mdi:tune'},
|
||||
sound_volume: {entity_category: 'config', icon: 'mdi:volume-high'},
|
||||
@@ -971,6 +965,15 @@ export default class HomeAssistant extends Extension {
|
||||
throw new Error(`Unsupported exposes type: '${firstExpose.type}'`);
|
||||
}
|
||||
|
||||
discoveryEntries.forEach((d) => {
|
||||
// If a sensor has entity category `config`, then change
|
||||
// it to `diagnostic`. Sensors have no input, so can't be configured.
|
||||
// https://github.com/Koenkk/zigbee2mqtt/pull/19474
|
||||
if (d.type === 'sensor' && d.discovery_payload.entity_category === 'config') {
|
||||
d.discovery_payload.entity_category = 'diagnostic';
|
||||
}
|
||||
});
|
||||
|
||||
return discoveryEntries;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user