mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 05:24:29 +00:00
fix: Preserve duration in state (#32900)
Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
This commit is contained in:
co-authored by
Koen Kanters
parent
dccf0a98c6
commit
7fbbbc3b17
@@ -22,7 +22,6 @@ const CACHE_IGNORE_PROPERTIES = [
|
||||
"no_occupancy_since",
|
||||
"step_mode",
|
||||
"transition_time",
|
||||
"duration",
|
||||
"elapsed",
|
||||
"from_side",
|
||||
"to_side",
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user