Skip to content

Commit

Permalink
Screensaver options
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Oct 19, 2019
1 parent 2cd7873 commit 1c0f126
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ You can read more about notifications here: https://lametric-documentation.readt

- Set display brightness (percent, auto-mode/manual-mode)
- Set audio volume (percent)
- Configure screensaver (enable/disable, time based, when dark)
- Activate/Deactivate bluetooth and change bluetooth name
- Switch between apps (next, previous, go to specific app)
- Send blockly notifications (with configurable priority, sound, icons, text, ...)
Expand Down
8 changes: 4 additions & 4 deletions io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
"type": "boolean",
"role": "value",
"read": true,
"write": false
"write": true
},
"native": {}
},
Expand All @@ -391,7 +391,7 @@
"type": "string",
"role": "value",
"read": true,
"write": false
"write": true
},
"native": {}
},
Expand All @@ -403,7 +403,7 @@
"type": "string",
"role": "value",
"read": true,
"write": false
"write": true
},
"native": {}
},
Expand All @@ -424,7 +424,7 @@
"type": "boolean",
"role": "value",
"read": true,
"write": false
"write": true
},
"native": {}
},
Expand Down
42 changes: 42 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,48 @@ class LaMetric extends utils.Adapter {
}
}
);
} else if (id.indexOf(this.namespace + '.meta.display.screensaver.modes.') > -1) {
this.log.debug('changing screensaver settings');

this.getStates(
'meta.display.screensaver.*',
(err, states) => {

var screensaverState = states[this.namespace + '.meta.display.screensaver.enabled'].val;
var currentMode = 'when_dark';
var currentModeParams = {};

if (id.indexOf('timeBased') > -1) {
currentMode = 'time_based';
currentModeParams.enabled = states[this.namespace + '.meta.display.screensaver.modes.timeBased.enabled'].val;
currentModeParams.start_time = states[this.namespace + '.meta.display.screensaver.modes.timeBased.startTime'].val;
currentModeParams.end_time = states[this.namespace + '.meta.display.screensaver.modes.timeBased.endTime'].val;
} else if (id.indexOf('whenDark') > -1) {
currentMode = 'when_dark';
currentModeParams.enabled = states[this.namespace + '.meta.display.screensaver.modes.whenDark.enabled'].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: screensaverState,
mode: currentMode,
mode_params: currentModeParams
}
}
);
}
);
} else if (id.match(/.+\.apps\.[a-z0-9]{32}\.activate$/g)) {
this.log.debug('changing to specific app');

Expand Down

0 comments on commit 1c0f126

Please sign in to comment.