From 2cd787323b78a926beed32046cac8cee2038468c Mon Sep 17 00:00:00 2001 From: "matthias@klein0r.de" Date: Sat, 19 Oct 2019 08:47:02 +0200 Subject: [PATCH] enable or disable screensaver --- io-package.json | 2 +- main.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/io-package.json b/io-package.json index 92aa80f..ac5ed5b 100644 --- a/io-package.json +++ b/io-package.json @@ -337,7 +337,7 @@ "type": "boolean", "role": "value", "read": true, - "write": false + "write": true }, "native": {} }, diff --git a/main.js b/main.js index 0299ac0..3c51de8 100644 --- a/main.js +++ b/main.js @@ -133,6 +133,26 @@ class LaMetric extends utils.Adapter { 'PUT', null ); + } else if (id === this.namespace + '.meta.display.screensaver.enabled') { + this.log.debug('changing screensaver state to ' + state.val); + + this.buildRequest( + 'device/display', + content => { + this.setState('meta.display.screensaver.enabled', {val: content.success.data.screensaver.enabled, ack: true}); + this.setState('meta.display.screensaver.widget', {val: content.success.data.screensaver.widget, ack: true}); + this.setState('meta.display.screensaver.modes.timeBased.enabled', {val: content.success.data.screensaver.modes.time_based.enabled, ack: true}); + this.setState('meta.display.screensaver.modes.timeBased.startTime', {val: content.success.data.screensaver.modes.time_based.start_time, ack: true}); + this.setState('meta.display.screensaver.modes.timeBased.endTime', {val: content.success.data.screensaver.modes.time_based.end_time, ack: true}); + this.setState('meta.display.screensaver.modes.whenDark.enabled', {val: content.success.data.screensaver.modes.when_dark.enabled, ack: true}); + }, + 'PUT', + { + screensaver: { + enabled: state.val + } + } + ); } else if (id.match(/.+\.apps\.[a-z0-9]{32}\.activate$/g)) { this.log.debug('changing to specific app');