fix: Preserve duration in state (#32900)

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
This commit is contained in:
Luan Taraschi
2026-08-26 12:02:15 +02:00
committed by GitHub
co-authored by Koen Kanters
parent dccf0a98c6
commit 7fbbbc3b17
2 changed files with 22 additions and 1 deletions
-1
View File
@@ -22,7 +22,6 @@ const CACHE_IGNORE_PROPERTIES = [
"no_occupancy_since",
"step_mode",
"transition_time",
"duration",
"elapsed",
"from_side",
"to_side",
+22
View File
@@ -1100,6 +1100,28 @@ describe("Controller", () => {
expect(mockMQTTPublishAsync).toHaveBeenCalledWith("zigbee2mqtt/bulb", stringify({state: "ON", brightness: 200}), {qos: 0, retain: true});
});
it("Publish entity state caches a duration reported by the device", async () => {
await controller.start();
mockMQTTPublishAsync.mockClear();
const device = getZ2MDevice("bulb");
await controller.publishEntityState(device, {state: "ON", duration: 30});
await flushPromises();
expect(controller.state.get(device)).toStrictEqual({brightness: 50, color_temp: 370, linkquality: 99, state: "ON", duration: 30});
});
it("Publish entity state keeps an action_duration out of the cache", async () => {
await controller.start();
mockMQTTPublishAsync.mockClear();
const device = getZ2MDevice("bulb");
await controller.publishEntityState(device, {state: "ON", action_duration: 1500});
await flushPromises();
expect(controller.state.get(device)).toStrictEqual({brightness: 50, color_temp: 370, linkquality: 99, state: "ON"});
});
it("Publish entity state attribute_json output filtered cache", async () => {
await controller.start();
settings.set(["advanced", "output"], "attribute_and_json");