()
| 91 | } |
| 92 | |
| 93 | private save(): void { |
| 94 | if (settings.get().advanced.cache_state_persistent) { |
| 95 | logger.debug(`Saving state to file ${this.file}`); |
| 96 | |
| 97 | const json = JSON.stringify(Object.fromEntries(this.state), null, 4); |
| 98 | |
| 99 | try { |
| 100 | writeFileSync(this.file, json, "utf8"); |
| 101 | } catch (error) { |
| 102 | logger.error(`Failed to write state to '${this.file}' (${error})`); |
| 103 | } |
| 104 | } else { |
| 105 | logger.debug("Not saving state"); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | exists(entity: Device | Group): boolean { |
| 110 | return this.state.has(entity.ID); |
no test coverage detected