From 1a4434268991031cbf694f9bb2e22fee636f6101 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rune=20Moskvil=20Lyng=C3=A5s?= Date: Tue, 16 Jun 2020 22:47:56 +0200 Subject: [PATCH] Added action 'Sync calendar'. Solving issue #3 --- .homeycompose/flow/actions/sync-calendar.json | 11 +++++++++++ README.md | 1 + app.js | 13 ++++++++++++- app.json | 13 +++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .homeycompose/flow/actions/sync-calendar.json diff --git a/.homeycompose/flow/actions/sync-calendar.json b/.homeycompose/flow/actions/sync-calendar.json new file mode 100644 index 00000000..abfbbb60 --- /dev/null +++ b/.homeycompose/flow/actions/sync-calendar.json @@ -0,0 +1,11 @@ +{ + "id": "sync-calendar", + "title": { + "en": "Sync calendar", + "no": "Synkroniser kalenderen" + }, + "hint": { + "en": "Will download a new .ics file to update current events", + "no": "Henter ned en ny .ics-fil for å oppdatere nåværende avtaler" + } +} \ No newline at end of file diff --git a/README.md b/README.md index c00ca892..eac1a10b 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ The IcalCalendar can trigger on your calendar events to let you know when events - 0.0.5 - Added support for norwegian language -> [Issue #6](https://github.com/runely/calendar-homey/issues/6) + - Added action for Sync calendar -> [Issue #3](https://github.com/runely/calendar-homey/issues/3) - 0.0.4 - Changelog moved out of readme... - 0.0.3 diff --git a/app.js b/app.js index 0ef29d5a..f678f3e9 100644 --- a/app.js +++ b/app.js @@ -16,6 +16,9 @@ class IcalCalendar extends Homey.App { // register condition flow cards this.registerConditionFlowCards(); + // register action flow cards + this.registerActionFlowCards(); + // get ical this.getEvents(); @@ -58,6 +61,14 @@ class IcalCalendar extends Homey.App { .registerRunListener((args, state) => this.checkEvent(args, state, 'any_in')); } + registerActionFlowCards() { + new Homey.FlowCardAction('sync-calendar') + .register() + .registerRunListener((args, state) => { + return Promise.resolve(this.getEvents()); + }) + } + onEventAutocomplete(query, args) { if (!variableMgmt.EVENTS) { this.log("onEventAutocomplete: Events not set yet. Nothing to show..."); @@ -125,7 +136,7 @@ class IcalCalendar extends Homey.App { var settingName = args; } else { - this.log("getEvents: Called from onInit/cron"); + this.log("getEvents: Called from onInit/cron/action"); var settingName = variableMgmt.SETTING.ICAL_URI; } diff --git a/app.json b/app.json index 67e8787b..1d2be8f9 100644 --- a/app.json +++ b/app.json @@ -284,6 +284,19 @@ } ] } + ], + "actions": [ + { + "id": "sync-calendar", + "title": { + "en": "Sync calendar", + "no": "Synkroniser kalenderen" + }, + "hint": { + "en": "Will download a new .ics file to update current events", + "no": "Henter ned en ny .ics-fil for å oppdatere nåværende avtaler" + } + } ] } } \ No newline at end of file