Don't cache properties which start with action_

This commit is contained in:
Koen Kanters
2020-04-05 15:41:48 +02:00
parent 4fa9aaa0b2
commit 1e6f99d88f
+6 -6
View File
@@ -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];