From dee2b769f662479cdca93c26b301fd626d920b36 Mon Sep 17 00:00:00 2001 From: Matthias Kleine Date: Fri, 1 Jan 2021 17:58:31 +0100 Subject: [PATCH] Added custom clockface configuration and countdown configuration --- README.md | 24 +++++++++++++++++++++--- main.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b24cb8c..f287262 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ You can get your personal key [here](https://developer.lametric.com/). - Activate/Deactivate bluetooth and change bluetooth name - Switch between apps (next, previous, go to specific app) - Send notifications with blockly (with configurable priority, sound, icons, text, ...) -- Control special apps like radio, stopwatch or weather +- Control special apps like clock, radio, stopwatch or weather - Use *My Data (DIY)* LaMetric App to display persistent information Features are limited by the [official API features](https://lametric-documentation.readthedocs.io/en/latest/reference-docs/lametric-time-reference.html). @@ -50,7 +50,7 @@ If you want to use chart frames, you have to specify an array of numbers as a fr ![chart data frames](docs/blockly3.png) -## My Data (DIY) +## My Data (DIY) *(version > 1.1.0)* LaMetric offers an app (on the integrated app market) to poll custom data. This app is called [My Data DIY](https://apps.lametric.com/apps/my_data__diy_/8942). This adapter creates a new state in the required format. You can use the Simple API Adapter to transfer the data to the LaMetric Time. @@ -85,7 +85,7 @@ http://172.16.0.219:8087/getPlainValue/lametric.0.mydatadiy.obj/ **Ensure to update IP and port in the URL if necessary!** -### Frame Configuration +### Frame Configuration *(version > 1.1.0)* - Use the plus icon to add as many frames as you want - Icon: Choose an icon from the [official website](https://developer.lametric.com/icons) and put the ID in the configuration field. **Important: Add an i (for static icons) or an a (for animated icons) as a prefix for that ID. (Example: `i3389`) @@ -95,6 +95,23 @@ Example configuration of 2 frames: ![example frame config](docs/myDataDIYConfig.png) +## Special Apps / Widgets *(version > 1.1.2)* + +You can control some apps with custom information + +### clock.clockface + +Allowed values are: + +- one of `weather`, `page_a_day`, `custom` or `none` +- custom icon data in format `data:image/png;base64,` or `data:image/gif;base64,` + +Example: `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAOklEQVQYlWNUVFBgwAeYcEncv//gP04FMEmsCmCSiooKjHAFMEF0SRQTsEnCFcAE0SUZGBgYGAl5EwA+6RhuHb9bggAAAABJRU5ErkJggg==` + +### countdown.configure + +Allowed value: Time in seconds + ## Scripts To show the message on your la metric just send a message to this instance with script adapter: @@ -180,6 +197,7 @@ show(); ### 1.1.2 * (klein0r) Delete app channels if app was deleted on LaMetric +* (klein0r) Custom app configuration (clockface, countdown duration) ### 1.1.1 diff --git a/main.js b/main.js index 891548c..9874edc 100644 --- a/main.js +++ b/main.js @@ -252,12 +252,39 @@ class LaMetric extends utils.Adapter { const data = { id: action }; // START special Widgets - if (action == 'countdown.configure') { + + if (action == 'clock.clockface') { + + if (['weather', 'page_a_day', 'custom', 'none'].indexOf(state.val) > -1) { + + data.params = { + type: state.val + }; + + } else { + + data.params = { + icon: state.val, + type: 'custom' + }; + + } + + data.activate = true; + + this.setState(id, {val: state.val, ack: true}); // Confirm state change + + } else if (action == 'countdown.configure') { + data.params = { duration: state.val, start_now: false }; + + this.setState(id, {val: state.val, ack: true}); // Confirm state change + } + // END special Widgets this.buildRequest( @@ -576,7 +603,32 @@ class LaMetric extends utils.Adapter { this.setState(path + uuid + '.version', {val: pack.version, ack: true}); // START special Widgets - if (pack.package === 'com.lametric.radio') { + + if (pack.package === 'com.lametric.clock') { + + this.setObjectNotExists(path + uuid + '.clock', { + type: 'channel', + common: { + name: pack.package, + role: '' + }, + native: {} + }); + + this.setObjectNotExists(path + uuid + '.clock.clockface', { + type: 'state', + common: { + name: 'Clockface (Base64)', + type: 'string', + role: 'value', + read: true, + write: true + }, + native: {} + }); + + } else if (pack.package === 'com.lametric.radio') { + this.setObjectNotExists(path + uuid + '.radio', { type: 'channel', common: {