From 1e6f99d88f2708c816787c1afffbadb2be09a11f Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Sun, 5 Apr 2020 15:41:48 +0200 Subject: [PATCH] Don't cache properties which start with action_ --- lib/state.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/state.js b/lib/state.js index 1853c11e4..0d362ca67 100644 --- a/lib/state.js +++ b/lib/state.js @@ -7,9 +7,8 @@ const events = require('events'); const saveInterval = 1000 * 60 * 5; // 5 minutes const dontCacheProperties = [ - 'action', 'button', 'button_left', 'button_right', 'click', 'forgotten', 'keyerror', - 'step_size', 'transition_time', 'action_color_temperature', 'action_color', - 'action_group', 'group_list', 'group_capacity', 'no_occupancy_since', + 'action', 'action_.*', 'button', 'button_left', 'button_right', 'click', 'forgotten', 'keyerror', + 'step_size', 'transition_time', 'group_list', 'group_capacity', 'no_occupancy_since', 'step_mode', 'transition_time', 'duration', 'elapsed', 'from_side', 'to_side', ]; @@ -70,11 +69,12 @@ class State extends events.EventEmitter { set(ID, state, reason=null) { const toState = objectAssignDeep.noMutate(state); - dontCacheProperties.forEach((property) => { - if (toState.hasOwnProperty(property)) { + + for (const property of Object.keys(toState)) { + if (dontCacheProperties.find((p) => property.match(p))) { delete toState[property]; } - }); + } const fromState = this.state[ID];