fix: Home Assistant: mark legacy action sensors diagnostic (#32377)

This commit is contained in:
Maximilian Rink
2026-06-23 19:36:44 +02:00
committed by GitHub
parent 20ab0a2a4f
commit 72be1d746b
2 changed files with 9 additions and 4 deletions
+1
View File
@@ -1227,6 +1227,7 @@ export class HomeAssistant extends Extension {
discovery_payload: {
name: endpointName ? `${firstExpose.label} ${endpointName}` : firstExpose.label,
value_template: valueTemplate,
...(firstExpose.property === "action" ? {entity_category: "diagnostic"} : {}),
...ENUM_DISCOVERY_LOOKUP[firstExpose.name],
},
});
+8 -4
View File
@@ -3041,11 +3041,15 @@ describe("Extension: HomeAssistant", () => {
settings.set(["homeassistant", "legacy_action_sensor"], true);
await resetExtension();
// Should discovery action sensor
expect(mockMQTTPublishAsync).toHaveBeenCalledWith("homeassistant/sensor/0x0017880104e45520/action/config", expect.any(String), {
retain: true,
qos: 1,
// Should discover action sensor as a diagnostic helper instead of a primary entity.
const actionDiscovery = mockMQTTPublishAsync.mock.calls.find(([topic]) => topic === "homeassistant/sensor/0x0017880104e45520/action/config");
assert(actionDiscovery);
expect(JSON.parse(actionDiscovery[1])).toMatchObject({
entity_category: "diagnostic",
name: "Action",
object_id: "button_action",
});
expect(actionDiscovery[2]).toStrictEqual({retain: true, qos: 1});
// Should counter an action payload with an empty payload
mockMQTTPublishAsync.mockClear();