From 1e850adaf0995bfc4a3fb97ff1ec0e870e3aec7a Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Sun, 16 Oct 2022 19:58:57 +0200 Subject: [PATCH 01/41] BREAK: new Eufy Library BREAK: update to SDK 3 BREAK: Homey v3 NEW: eufy pairing FIX: hub driver FIX: drivers FIX: arm types FIX: panTilt NEW: add Sentry NEW: Keypad Bump version to v3.0.0 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog Bump version to v3.0.0 FIX: remove capability FIX: images Bump version to v3.0.1 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog OPT: remove yarn.lock FIX: Keypadd pairing FIX: auto REGION switcher FIX: guard mode FIX: notifications FIX: remove env json OPT: gitignore OPT: remove env json Bump version to v3.0.2 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog BREAK: new Eufy Library Bump version to v3.0.3 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog Bump version to v3.0.5 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog FIX: events helper Update eufy-notification-check.helper.js Bump version to v3.0.6 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog FIX: deviceUser Bump version to v3.0.7 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog Bump version to v3.0.8 Changelog: Fix: app crash FIX: app Crash Bump version to v3.0.9 Changelog: FIX: app crash FIX: fixes for eufy libr Bump version to v3.0.10 Changelog: BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog --- .gitignore | 10 +- .homeychangelog.json | 6 + README.md | 35 +- README.txt | 21 +- api.js | 45 +- app.js | 584 +++-- app.json | 1327 +++------- constants/device_types.js | 1 + constants/message_types.js | 26 - drivers/driver_DOORSENSOR/driver.js | 4 +- .../driver_DOORSENSOR/pair/login_eufy.html | 6 +- drivers/driver_EUFYCAM/driver.js | 4 +- drivers/driver_EUFYCAM/pair/login_eufy.html | 6 +- drivers/driver_EUFYCAM_2/driver.js | 4 +- drivers/driver_EUFYCAM_2/pair/login_eufy.html | 6 +- drivers/driver_EUFYCAM_2C/driver.js | 4 +- .../driver_EUFYCAM_2C/pair/login_eufy.html | 6 +- drivers/driver_EUFYCAM_2C_PRO/driver.js | 4 +- .../pair/login_eufy.html | 6 +- drivers/driver_EUFYCAM_2_PRO/driver.js | 4 +- .../driver_EUFYCAM_2_PRO/pair/login_eufy.html | 6 +- drivers/driver_EUFYCAM_E/driver.js | 4 +- drivers/driver_EUFYCAM_E/pair/login_eufy.html | 6 +- drivers/driver_FLOODLIGHT_CAMERA/driver.js | 4 +- .../pair/login_eufy.html | 6 +- .../driver_FLOODLIGHT_CAM_PAN_TILT/driver.js | 4 +- .../pair/login_eufy.html | 6 +- drivers/driver_HOMEBASE/driver.js | 4 +- drivers/driver_HOMEBASE/pair/login_eufy.html | 6 +- drivers/driver_HOMEBASE_1/driver.js | 4 +- .../driver_HOMEBASE_1/pair/login_eufy.html | 6 +- drivers/driver_HOMEBASE_CHIME/driver.js | 4 +- .../pair/login_eufy.html | 6 +- drivers/driver_INDOOR_CAM/driver.js | 4 +- .../driver_INDOOR_CAM/pair/login_eufy.html | 6 +- drivers/driver_INDOOR_CAM_PAN_TILT/driver.js | 4 +- .../pair/login_eufy.html | 6 +- drivers/driver_KEYPAD/device.js | 4 +- drivers/driver_KEYPAD/driver.js | 4 +- drivers/driver_KEYPAD/pair/login_eufy.html | 6 +- drivers/driver_MOTIONSENSOR/driver.js | 4 +- .../driver_MOTIONSENSOR/pair/login_eufy.html | 6 +- drivers/driver_OUTDOOR_CAM/driver.js | 4 +- .../driver_OUTDOOR_CAM/pair/login_eufy.html | 6 +- drivers/driver_OUTDOOR_CAM_PRO/driver.js | 4 +- .../pair/login_eufy.html | 6 +- drivers/driver_SOLOCAM_E2040/driver.js | 4 +- .../driver_SOLOCAM_E2040/pair/login_eufy.html | 6 +- drivers/driver_SOLOCAM_L2040/driver.js | 4 +- .../driver_SOLOCAM_L2040/pair/login_eufy.html | 6 +- drivers/driver_SOLOCAM_S2040/driver.js | 4 +- .../driver_SOLOCAM_S2040/pair/login_eufy.html | 6 +- .../driver.js | 2 +- .../pair/login_eufy.html | 6 +- .../pair/login_eufy.html | 6 +- .../driver.js | 4 +- .../pair/login_eufy.html | 6 +- .../driver.js | 4 +- .../pair/login_eufy.html | 6 +- .../driver.js | 4 +- .../pair/login_eufy.html | 6 +- drivers/main-device.js | 766 ++---- drivers/main-driver.js | 192 +- drivers/main-hub-driver.js | 174 +- drivers/main-hub.js | 205 +- drivers/main-sensor.js | 48 +- lib/flow/actions.js | 225 +- lib/flow/conditions.js | 10 +- lib/flow/triggers.js | 26 +- lib/helpers/eufy-events.helper.js | 91 + lib/helpers/eufy-logger.helper.js | 49 + lib/helpers/eufy-notification-check.helper.js | 255 +- lib/helpers/eufy-p2p.helper.js | 123 - lib/helpers/eufy-parameter.helper.js | 64 - lib/utils.js | 49 +- locales/en.json | 3 +- locales/nl.json | 3 +- package-lock.json | 2202 +++++++++++++++++ package.json | 14 +- settings/index.html | 5 +- settings/settings.js | 77 +- yarn.lock | 69 - 82 files changed, 3862 insertions(+), 3101 deletions(-) delete mode 100644 constants/message_types.js create mode 100644 lib/helpers/eufy-events.helper.js create mode 100644 lib/helpers/eufy-logger.helper.js delete mode 100644 lib/helpers/eufy-p2p.helper.js delete mode 100644 lib/helpers/eufy-parameter.helper.js create mode 100644 package-lock.json delete mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index d8efbb7..474fe53 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ # Logs +env.json +node_modules/ +assets/.DS_Store + +.DS_Store + logs *.log npm-debug.log* @@ -87,10 +93,6 @@ typings/ # DynamoDB Local files .dynamodb/ -.DS_Store - -package-lock.json -eufy-homey-client build/ diff --git a/.homeychangelog.json b/.homeychangelog.json index 343074b..ca629ef 100644 --- a/.homeychangelog.json +++ b/.homeychangelog.json @@ -970,5 +970,11 @@ }, "2.36.9": { "en": "FIX: light for outdoorcam pro | NEW: add status led flowcards" + }, + "3.0.9": { + "en": "BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog" + }, + "3.0.10": { + "en": "BREAK: Update Eufy Library | BREAK: Update to Homey SDK 3 | Check on community page for full changelog" } } diff --git a/README.md b/README.md index 30d7829..272cb6f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # Eufy Security Add support for Eufy Cam in Homey. -Based on: https://github.com/martijnpoppen/eufy-node-client - Link: https://homey.app/nl-nl/app/com.eufylife.security/Eufy-Security/ # Account Information @@ -13,34 +11,9 @@ use the mobile app to create a secondary "guest" account with a separate email a and use it with this library. # Usage - - Install this app on your Homey. -- Go to the app settings and provide your Username and Password. Click Save Changes -- Other keys will be fetched and filled in to the settings page. -- Connect a device to Eufy Security -- Create a flow with Eufy Security devices - -## Current features: - -- Turn on/off camera (EufyCam pan&tilt will turn its lens) -- Set Security mode (Home, Away, Disarmed, Schedule) -- Trigger events based on changed Security modes. Possible combination with keypad. -- Get notifications based on detection modes for specific devices. (Motion, Face, Sound and Doorbell Press) -- Get images when motion is detected -- See last motion events -- Generic alarm for each camera -> Heimdall (goes off for all events except doorbell press) -- Start Stream and retrieve RTSP url - ---- - -  - -## Donation - -If this project help you reduce time to develop, you can give me a cup of coffee :) - -[![paypal](https://www.paypalobjects.com/en_US/NL/i/btn/btn_donateCC_LG.gif)](https://paypal.me/martijnpoppen) - -  +- Go to `add devices` +- Provide your Username and Password. Click Next +- Available devices show up ---- +--- \ No newline at end of file diff --git a/README.txt b/README.txt index 5018be7..2b8a1bc 100644 --- a/README.txt +++ b/README.txt @@ -11,23 +11,4 @@ Usage - Install this app on your Homey. - Go to `add devices` - Provide your Username and Password. Click Next -- Available devices show up - -Current features: -- Turn on/off camera (EufyCam pan&tilt will turn its lens) -- Set Security mode (Home, Away, Disarmed, Schedule) -- Trigger events based on changed Security modes. Possible combination with keypad. -- Get notifications based on detection modes for specific devices. (Motion, Face, Sound and Doorbell Press) -- Get images when motion is detected -- See last motion events -- Generic alarm for each camera -> Heimdall (goes off for all events except doorbell press) -- Start Stream and retrieve RTSP url -- Toggle ALARM for Homebase - This also enables the generic alarm for the Homebase (Heimdall) -- Trigger flows when alarms turns on -- Trigger quickResponses for doorbells -- Trigger HDR -- Trigger WDR -- Trigger night vision -- Reboot Hub or stand-alone cameras -- Force Eufy Homebase notifications to prevent wrong data -- Battery status for Battery devices \ No newline at end of file +- Available devices show up \ No newline at end of file diff --git a/api.js b/api.js index 36f36cf..a2ba222 100644 --- a/api.js +++ b/api.js @@ -1,36 +1,13 @@ -'use strict'; - -const Homey = require('homey'); - -module.exports = [ - { - method: 'PUT', - path: '/login', - fn: async function (args, callback) { - const result = await Homey.app.eufyLogin(args.body); - if (result instanceof Error) return callback(result); - return callback(null, result); - } - }, - { - method: 'PUT', - path: '/settings', - fn: async function (args, callback) { - const result = Homey.app.updateSettings(args.body); - if (result instanceof Error) return callback(result); - return callback(null, result); - } +module.exports = { + async login({ homey, body }){ + return homey.app.eufyLogin( body ); }, - { - method: 'GET', - path: '/streamurl', - public: true, - fn: async function (args, callback) { - const device_sn = args.query.device_sn; - - const result = await Homey.app.getStreamUrl(device_sn); - if (result instanceof Error) return callback(result); - return callback(null, result); - } + + async settings({ homey, body }){ + return homey.app.updateSettings( body ); }, -]; + + async streamUrl({homey, query}) { + return await homey.app.getStreamUrl(query.device_sn); + } +}; \ No newline at end of file diff --git a/app.js b/app.js index fcbad41..3720535 100644 --- a/app.js +++ b/app.js @@ -1,327 +1,377 @@ -"use strict"; +'use strict'; -const Homey = require("homey"); -const { PushRegisterService, HttpService, PushClient, sleep } = require("./lib/eufy-homey-client"); +const Homey = require('homey'); +const path = require('path'); -const flowActions = require("./lib/flow/actions.js"); -const flowConditions = require("./lib/flow/conditions.js"); -const flowTriggers = require("./lib/flow/triggers.js"); +const { EventEmitter } = require('events'); -const EufyP2P = require("./lib/helpers/eufy-p2p.helper"); -const eufyNotificationCheckHelper = require("./lib/helpers/eufy-notification-check.helper"); -const eufyParameterHelper = require("./lib/helpers/eufy-parameter.helper"); +const { EufySecurity } = require('eufy-security-client'); + +const { DEVICE_TYPES } = require('./constants/device_types.js'); + +const flowActions = require('./lib/flow/actions.js'); +const flowConditions = require('./lib/flow/conditions.js'); +const flowTriggers = require('./lib/flow/triggers.js'); +const eufyNotificationCheckHelper = require('./lib/helpers/eufy-notification-check.helper'); +const eufyEventsHelper = require('./lib/helpers/eufy-events.helper'); + +const { sleep } = require('./lib/utils'); + +const Logger = require('./lib/helpers/eufy-logger.helper'); +const { Log } = require('homey-log'); +const consola = require('consola').withScope('HomeyClient'); -const ManagerSettings = Homey.ManagerSettings; -const ManagerCloud = Homey.ManagerCloud; -const ManagerNotifications = Homey.ManagerNotifications; const _settingsKey = `${Homey.manifest.id}.settings`; class App extends Homey.App { - log() { - console.log.bind(this, "[log]").apply(this, arguments); - } - - error() { - console.error.bind(this, "[error]").apply(this, arguments); - } + log() { + consola.info.bind(this, '[log]').apply(this, arguments); + } - // -------------------- INIT ---------------------- + error() { + consola.error.bind(this, '[error]').apply(this, arguments); + } - async onInit() { - try { - this.log(`${Homey.manifest.id} - ${Homey.manifest.version} started...`); + // -------------------- INIT ---------------------- - await this.initSettings(); + async onInit() { + try { + this.log(`${this.homey.manifest.id} - ${this.homey.manifest.version} started...`); - this.log("onInit - Loaded settings", {...this.appSettings, 'USERNAME': 'LOG', PASSWORD: 'LOG'}); + await this.initGlobarVars(); - if (this._httpService) { - await flowActions.init(); - await flowConditions.init(); + // No await - finish onInit asap to start the drivers + this.initApp(); + } catch (error) { + this.homey.app.log(error); } + } + + async initApp() { + try { + this.homeyEvents.once('driversInitialized', async () => { + await sleep(2000); + await this.initSettings(); - if (this.appSettings.CREDENTIALS) { - await PushClient.init(); - await eufyNotificationCheckHelper.init(this.appSettings); - await flowTriggers.init(); + this.log('onStartup - Loaded settings', { ...this.appSettings, USERNAME: 'LOG', PASSWORD: 'LOG' }); + + this.initEufyClient(); + this.sendNotifications(); + }); + } catch (error) { + this.homey.app.log(error); } + } + + // -------------------- SETTINGS ---------------------- + + async initGlobarVars() { + this.log('initGlobarVars'); + + this.settingsInitialized = false; + this.driversInitialized = false; + this.flowsInitialized = false; + + this.deviceList = []; + this.deviceTypes = DEVICE_TYPES; - await sleep(2000); - await this.sendNotifications(); - } catch (error) { - Homey.app.log(error); + this.eufyRegionSwitchAllowed = false; + this.eufyClientConnected = false; + this.eufyClient = null; + + this.homeyLog = new Log({ homey: this.homey }); + + this.homey.settings.getKeys().forEach((key) => { + if (key == _settingsKey) { + this.settingsInitialized = true; + } + }); + + this.homeyEvents = new EventEmitter(); } - } - // -------------------- SETTINGS ---------------------- + async initSettings() { + try { + if (this.settingsInitialized) { + this.log('initSettings - Found settings key', _settingsKey); + this.appSettings = this.homey.settings.get(_settingsKey); - async initSettings() { - try { - let settingsInitialized = false; - this.EufyP2P = new EufyP2P; - this.P2P = {}; - this._deviceList = []; - this._deviceStore = []; + if ('REGION' in this.appSettings && this.appSettings['REGION'] === 'EU') { + this.log('initSettings - Set REGION to NL'); - ManagerSettings.getKeys().forEach((key) => { - if (key == _settingsKey) { - settingsInitialized = true; - } - }); + await this.updateSettings({ + ...this.appSettings, + REGION: 'NL' + }); + } - if (settingsInitialized) { - this.log("initSettings - Found settings key", _settingsKey); - this.appSettings = ManagerSettings.get(_settingsKey); + if (!('REGION' in this.appSettings)) { + await this.updateSettings({ + ...this.appSettings, + REGION: 'US' + }); + } - if(!('REGION' in this.appSettings)) { - await this.updateSettings({ - ...this.appSettings, - REGION: 'US' + if ('HUBS' in this.appSettings) { + delete this.appSettings.HUBS; + await this.updateSettings(this.appSettings); + } + + // Temp disable this until the new app version is live. + // if ('CREDENTIALS' in this.appSettings) { + // delete this.appSettings.CREDENTIALS; + // await this.updateSettings(this.appSettings); + // } + + if (!('NOTIFICATIONS' in this.appSettings)) { + await this.updateSettings({ + ...this.appSettings, + NOTIFICATIONS: [] + }); + } + + return true; + } + + this.log(`Initializing ${_settingsKey} with defaults`); + this.updateSettings({ + USERNAME: '', + PASSWORD: '', + REGION: 'US', + NOTIFICATIONS: [] }); - } - if (('USERNAME' in this.appSettings) && !this._httpService) { - this._httpService = await this.setHttpService(this.appSettings); - this._httpService.getToken(); + return true; + } catch (err) { + this.error(err); } + } - await eufyParameterHelper.unregisterAllTasks(); - await sleep(2000); - await this.setDeviceStore(this, true); - - return; - } - - this.log(`Initializing ${_settingsKey} with defaults`); - this.updateSettings({ - USERNAME: "", - PASSWORD: "", - SET_CREDENTIALS: true, - CREDENTIALS: "", - REGION: 'US', - NOTIFICATIONS: [] - }); - } catch (err) { - this.error(err); + updateSettings(settings) { + this.log('updateSettings - New settings:', { ...settings, USERNAME: 'LOG', PASSWORD: 'LOG' }); + + this.appSettings = settings; + this.saveSettings(); } - } - updateSettings(settings, resetHttpService = true) { - this.log("updateSettings - New settings:", {...settings, 'USERNAME': 'LOG', PASSWORD: 'LOG', HUBS: 'LOG'}); + saveSettings() { + if (typeof this.appSettings === 'undefined') { + this.log('Not saving settings; settings empty!'); + return; + } - if(resetHttpService) { - this._httpService = undefined; + this.log('Saved settings.'); + this.homey.settings.set(_settingsKey, this.appSettings); } - this.appSettings = settings; - this.saveSettings(); - } + async sendNotifications() { + // const ntfy07022022 = `Good News! Eufy Security - Home-Management has been integrated in Homey! In case of issues please check: https://tinyurl.com/eufy-homey` + // if(!this.appSettings.NOTIFICATIONS.includes('ntfy07022022')) { + // ManagerNotifications.registerNotification({ + // excerpt: ntfy07022022, + // }); + // await this.updateSettings({ + // ...this.appSettings, + // NOTIFICATIONS: [...this.appSettings.NOTIFICATIONS, 'ntfy07022022'] + // }); + // } + } + + async initEvents() { + if (!this.flowsInitialized) { + this.flowsInitialized = true; + + flowActions.init(this.homey); + flowConditions.init(this.homey); + flowTriggers.init(this.homey); - saveSettings() { - if (typeof this.appSettings === "undefined") { - this.log("Not saving settings; settings empty!"); - return; + new eufyNotificationCheckHelper(this.homey); + new eufyEventsHelper(this.homey); + } } - this.log("Saved settings."); - ManagerSettings.set(_settingsKey, this.appSettings); - } + // -------------------- EUFY LOGIN ---------------------- - async sendNotifications() { - if(!('NOTIFICATIONS' in this.appSettings)) { - await this.updateSettings({ - ...this.appSettings, - NOTIFICATIONS: [] - }); - } - - // const ntfy07022022 = `Good News! Eufy Security - Home-Management has been integrated in Homey! In case of issues please check: https://tinyurl.com/eufy-homey` - - // if(!this.appSettings.NOTIFICATIONS.includes('ntfy07022022')) { - // ManagerNotifications.registerNotification({ - // excerpt: ntfy07022022, - // }); - - // await this.updateSettings({ - // ...this.appSettings, - // NOTIFICATIONS: [...this.appSettings.NOTIFICATIONS, 'ntfy07022022'] - // }); - // } - } - - // -------------------- EUFY LOGIN ---------------------- - - async eufyLogin(data) { - try { - let settings = data; - this.log("eufyLogin - New settings:", {...settings, 'USERNAME': 'LOG', PASSWORD: 'LOG', HUBS: 'LOG'}); - this.log(`eufyLogin - Found username and password. Logging in to Eufy`); - - this._httpService = await this.setHttpService(data); - - await this._httpService.getToken(); - - const hubs = await this._httpService.listHubs(); - - if(hubs.length) { - this.log(`eufyLogin - Logged in.`); - } - - if(hubs.error) { - Homey.app.log(`eufyLogin => error =>`, hubs); - } - - const initNotificationCheckHelper = !settings.CREDENTIALS; - - if (!settings.CREDENTIALS && settings.SET_CREDENTIALS) { - this.log(`eufyLogin - Found SET_CREDENTIALS. Registering pushService`); - const pushService = new PushRegisterService(); - settings.CREDENTIALS = await pushService.createPushCredentials(); - } - - this.appSettings = settings; - this.saveSettings(); - this.log("eufyLogin - Loaded settings", {...this.appSettings, 'USERNAME': 'LOG', PASSWORD: 'LOG', HUBS: 'LOG'}); - - if (this._httpService) { - await this.setDeviceStore(this); - flowActions.init(); - flowConditions.init(); - } - - if (settings.CREDENTIALS) { - PushClient.init(); - eufyNotificationCheckHelper.init(this.appSettings); - - flowTriggers.init(); - } - - return; - } catch (err) { - this.error(err); - return err; + async eufyLogin(data) { + try { + this.log('eufyLogin - New settings:', { ...data, USERNAME: 'LOG', PASSWORD: 'LOG' }); + this.log(`eufyLogin - Found username and password. Logging in to Eufy`); + + const loggedIn = await this.setEufyClient(data); + + if (loggedIn) { + this.log('eufyLogin - Succes'); + } else { + return false; + } + + this.updateSettings(data); + + return true; + } catch (err) { + this.error(err); + return err; + } } - } - // ---------------------------- GETTERS/SETTERS ---------------------------------- + async checkLogin() { + try { + await this.eufyClient.connect(); + this.log('eufyClient connected = ' + this.eufyClient.isConnected()); + + return this.eufyClient.isConnected(); + } catch (err) { + this.log('Error authenticating Eufy : ' + err); - async setHttpService(settings) { - try { - return new HttpService(settings.USERNAME, settings.PASSWORD, settings.REGION); - } catch (err) { - this.error(err); + return false; + } } - } - getHttpService() { - return this._httpService; - } + // ---------------------------- eufyClient ---------------------------------- - async getDevices() { - return this._deviceList; - } + async initEufyClient() { + if ('USERNAME' in this.appSettings && this.appSettings.USERNAME.length) { + this.eufyRegionSwitchAllowed = true; - async setDevice(device) { - this._deviceList = [...this._deviceList, device]; - } + await this.setEufyClient(this.appSettings); + } + } - async removeDevice(device_sn) { - try { - Homey.app.log("removeDevice", device_sn); + async setEufyClient(settings) { + try { + const debug = false; + const config = { + username: settings.USERNAME, + password: settings.PASSWORD, + country: settings.REGION, + language: 'EN', + persistentDir: path.resolve(__dirname, '/userdata/'), + trustedDeviceName: 'Homey', + acceptInvitations: true + }; + + await this.resetEufyClient(); + + this.libraryLog = Logger.createNew('EufyLibrary', debug); + this.eufyClient = await EufySecurity.initialize(config, this.libraryLog); + + this.connectEufyClientHandlers(); + + return await this.checkLogin(); + } catch (err) { + this.error(err); + } + } + + async resetEufyClient() { + if (this.eufyClient) { + this.log('resetEufyClient - Resetting EufyClient'); + await this.eufyClient.close(); + this.eufyClient = undefined; + } + } - const filteredList = this._deviceList.filter(dl => { - const data = dl.getData() - return data.device_sn !== device_sn + connectEufyClientHandlers() { + // this.eufyClient.on('tfa request', () => this.onTFARequest()); + // this.eufyClient.on('captcha request', (id, captcha) => this.onCaptchaRequest(id, captcha)); + this.eufyClient.on('connect', async () => { + this.log('Event: connected'); + + this.switchRegions(); }); - - this._deviceList = filteredList; - } catch (error) { - this.error(error); - } - - } - - async setDeviceStore(ctx, initCron = false) { - try { - if(!ctx._httpService) { - return []; + } + + async switchRegions() { + await sleep(3000); + const eufyDevices = await this.eufyClient.getDevices(); + + this.log('switchRegions', { region: this.appSettings.REGION, eufyRegionSwitchAllowed: this.eufyRegionSwitchAllowed, deviceList: this.deviceList.length, eufyDevices: eufyDevices.length }); + + if (this.eufyRegionSwitchAllowed && this.deviceList.length && !eufyDevices.length) { + const REGION = this.appSettings.REGION === 'US' ? 'NL' : 'US'; + + this.eufyRegionSwitchAllowed = false; + + this.log('switchRegions restart eufyClient with region: ', REGION); + + await this.updateSettings({ + ...this.appSettings, + REGION: REGION + }); + + await sleep(200); + + this.setEufyClient(this.appSettings); + } else { + this.eufyRegionSwitchAllowed = false; + this.eufyClientConnected = true; + + this.homeyEvents.emit('eufyClientConnected'); + + this.initEvents(); } - - let devices = await ctx._httpService.listDevices(); + } + + async setDevice(device) { + this.deviceList = [...this.deviceList, device]; + } - if(devices.error) { - Homey.app.log(`setDeviceStore => error =>`, devices); + async setDevices(devices) { + this.deviceList = [...this.deviceList, ...devices]; + + if (!this.driversInitialized) { + this.driversInitialized = true; + await sleep(2000); + this.homeyEvents.emit('driversInitialized'); } + } - ctx._deviceStore = []; - - if(devices.length) { - devices = devices.map((r, i) => { - const measure_battery = eufyParameterHelper.getParamData(r.params, "CMD_GET_BATTERY"); - const measure_temperature = eufyParameterHelper.getParamData(r.params, "CMD_GET_BATTERY_TEMP"); - - return { - name: r.device_name, - index: r.device_channel, - device_sn: r.device_sn, - station_sn: r.station_sn, - deviceId: `${r.device_sn}-${r.device_id}`, - measure_battery, - measure_temperature - } + async removeDevice(device_sn) { + try { + this.homey.app.log('removeDevice', device_sn); + + const filteredList = this.deviceList.filter((dl) => { + const data = dl.getData(); + return data.device_sn !== device_sn; }); - ctx._deviceStore.push(...devices); + this.deviceList = filteredList; + } catch (error) { + this.error(error); } + } - Homey.app.log("setDeviceStore - Setting up DeviceStore", ctx._deviceStore); + /// ----------------- Streaming -------------------- + async getStreamAddress() { + try { + let internalIp = (await this.homey.cloud.getLocalAddress()).replace(/:.*/, ''); + internalIp = internalIp.replace(/\./g, '-'); + this.log(`getStreamAddress - Set internalIp`, internalIp); - if(initCron) { - await eufyParameterHelper.registerCronTask("setDeviceStore", "EVERY_HALVE_HOURS", ctx.setDeviceStore, ctx) + return `https://${internalIp}.homey.homeylocal.com`; + } catch (error) { + this.error(error); } - - - return ctx._deviceStore; - } catch (err) { - ctx.error(err); } - } - - /// ----------------- Streaming --------------------- - - async getStreamAddress() { - try { - let internalIp = (await ManagerCloud.getLocalAddress()).replace(/:.*/, ''); - internalIp = internalIp.replace(/\./g, '-'); - this.log(`getStreamAddress - Set internalIp`, internalIp); - - return `https://${internalIp}.homey.homeylocal.com`; - } catch (error) { - this.error(error); - } - - } - - async getStreamUrl(device_sn) { - try { - const pairedDevices = await Homey.app.getDevices(); - const device = pairedDevices.find(d => { - const data = d.getData(); - this.log(`getStreamUrl - device_sn`, device_sn); - this.log(`getStreamUrl - data`, data); - - return data.device_sn === device_sn; - }) - - - const settings = device.getSettings(); - this.log(`getStreamUrl - settings`, settings); - return settings.CLOUD_STREAM_URL ? settings.CLOUD_STREAM_URL : null; - } catch (error) { - this.error(error); + + async getStreamUrl(device_sn) { + try { + const pairedDevices = this.homey.app.deviceList; + const device = pairedDevices.find((d) => { + const data = d.getData(); + this.log(`getStreamUrl - device_sn`, device_sn); + this.log(`getStreamUrl - data`, data); + + return data.device_sn === device_sn; + }); + + const settings = device.getSettings(); + this.log(`getStreamUrl - settings`, settings); + return settings.CLOUD_STREAM_URL ? settings.CLOUD_STREAM_URL : null; + } catch (error) { + this.error(error); + } } - -} } module.exports = App; diff --git a/app.json b/app.json index ffe6401..cf770cb 100644 --- a/app.json +++ b/app.json @@ -1,9 +1,12 @@ { "id": "com.eufylife.security", - "version": "2.36.9", + "version": "3.0.10", "compatibility": ">=5.0.0", "sdk": 3, "brandColor": "#2a6185", + "platforms": [ + "local" + ], "name": { "en": "Eufy Security", "nl": "Eufy Security" @@ -25,7 +28,8 @@ "Heimdall", "Doorbell", "outdoor camera", - "indoor camera" + "indoor camera", + "homebase" ], "nl": [ "Video doorbell", @@ -79,6 +83,9 @@ "donate": { "paypal": { "username": "martijnpoppen" + }, + "bunq": { + "username": "martijnpoppen" } } }, @@ -88,14 +95,19 @@ "source": "https://github.com/martijnpoppen/com.eufylife.security", "homeyCommunityTopicId": 44921, "support": "https://community.athom.com/t/app-eufy-security/44921", - "discovery": { - "homebase_discovery": { - "type": "mdns-sd", - "mdns-sd": { - "protocol": "tcp", - "name": "_hap" - }, - "id": "{{txt.id}}" + "api": { + "login": { + "method": "put", + "path": "/login/" + }, + "settings": { + "method": "put", + "path": "/settings/" + }, + "streamUrl": { + "method": "get", + "path": "/streamurl/", + "public": true } }, "flow": { @@ -146,6 +158,21 @@ "en": "Person Detected", "nl": "Persoon Gedetecteerd" }, + "hint": { + "en": "This flowcard will contain a known person token (Dual doorbell only)", + "nl": "Deze flowkaart bevat een bekend persoon token (Alleen voor Dual deurbel)" + }, + "tokens": [ + { + "name": "user", + "type": "string", + "title": { + "en": "Person", + "nl": "Persoon" + }, + "example": "John Doe" + } + ], "args": [ { "name": "device", @@ -1269,9 +1296,11 @@ "drivers": [ { "id": "driver_EUFYCAM", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -1302,6 +1331,13 @@ "small": "drivers/driver_EUFYCAM/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -1312,9 +1348,6 @@ { "id": "add_devices", "template": "add_devices" - }, - { - "id": "login_eufy" } ], "settings": [ @@ -1352,9 +1385,11 @@ }, { "id": "driver_EUFYCAM_2", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -1385,6 +1420,13 @@ "small": "drivers/driver_EUFYCAM_2/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -1392,9 +1434,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -1435,9 +1474,11 @@ }, { "id": "driver_EUFYCAM_2_PRO", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -1468,6 +1509,13 @@ "small": "drivers/driver_EUFYCAM_2_PRO/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -1475,9 +1523,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -1518,9 +1563,11 @@ }, { "id": "driver_EUFYCAM_2C", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -1552,6 +1599,13 @@ "small": "drivers/driver_EUFYCAM_2C/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -1559,9 +1613,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -1602,9 +1653,11 @@ }, { "id": "driver_EUFYCAM_2C_PRO", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -1636,6 +1689,13 @@ "small": "drivers/driver_EUFYCAM_2C_PRO/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -1643,9 +1703,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -1686,9 +1743,11 @@ }, { "id": "driver_EUFYCAM_E", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -1718,6 +1777,13 @@ "small": "drivers/driver_EUFYCAM_E/assets/images/small.png" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -1725,9 +1791,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -1768,9 +1831,11 @@ }, { "id": "driver_FLOODLIGHT_CAMERA", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -1798,6 +1863,13 @@ "small": "drivers/driver_FLOODLIGHT_CAMERA/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -1805,9 +1877,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -1934,42 +2003,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -1978,28 +2011,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -2007,9 +2018,11 @@ }, { "id": "driver_FLOODLIGHT_CAM_PAN_TILT", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -2039,6 +2052,13 @@ "small": "drivers/driver_FLOODLIGHT_CAM_PAN_TILT/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -2046,9 +2066,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -2175,42 +2192,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -2219,28 +2200,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -2248,9 +2207,11 @@ }, { "id": "driver_INDOOR_CAM", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -2282,6 +2243,13 @@ "small": "drivers/driver_INDOOR_CAM/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -2289,9 +2257,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -2418,42 +2383,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -2462,28 +2391,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -2491,9 +2398,11 @@ }, { "id": "driver_INDOOR_CAM_PAN_TILT", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -2525,6 +2434,13 @@ "small": "drivers/driver_INDOOR_CAM_PAN_TILT/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -2532,9 +2448,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -2661,42 +2574,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -2705,28 +2582,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -2734,9 +2589,11 @@ }, { "id": "driver_OUTDOOR_CAM", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -2768,6 +2625,13 @@ "small": "drivers/driver_OUTDOOR_CAM/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -2775,9 +2639,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -2904,42 +2765,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -2948,28 +2773,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -2977,9 +2780,11 @@ }, { "id": "driver_OUTDOOR_CAM_PRO", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -3011,6 +2816,13 @@ "small": "drivers/driver_OUTDOOR_CAM_PRO/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -3018,9 +2830,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -3147,42 +2956,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -3191,28 +2964,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -3220,9 +2971,11 @@ }, { "id": "driver_SOLOCAM_E2040", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -3257,6 +3010,13 @@ "small": "drivers/driver_SOLOCAM_E2040/assets/images/small.png" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -3264,9 +3024,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -3393,42 +3150,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -3437,28 +3158,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -3466,9 +3165,11 @@ }, { "id": "driver_SOLOCAM_L2040", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -3504,6 +3205,13 @@ "small": "drivers/driver_SOLOCAM_L2040/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -3511,9 +3219,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -3640,42 +3345,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -3684,28 +3353,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -3713,9 +3360,11 @@ }, { "id": "driver_SOLOCAM_S2040", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "camera", "capabilities": [ @@ -3751,6 +3400,13 @@ "small": "drivers/driver_SOLOCAM_S2040/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -3758,9 +3414,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -3887,42 +3540,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -3931,28 +3548,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -3960,9 +3555,11 @@ }, { "id": "driver_VIDEO_DOORBELL_2K_POWERED", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "doorbell", "capabilities": [ @@ -3982,8 +3579,7 @@ "CMD_SET_HUB_ALARM_CLOSE", "NTFY_MOTION_DETECTION", "NTFY_FACE_DETECTION", - "NTFY_PRESS_DOORBELL", - "NTFY_BACKGROUND_ACTIVE" + "NTFY_PRESS_DOORBELL" ], "name": { "en": "Wired Doorbell (1080P/2K)", @@ -3994,6 +3590,13 @@ "small": "drivers/driver_VIDEO_DOORBELL_2K_POWERED/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4001,9 +3604,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4130,42 +3730,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -4174,28 +3738,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -4203,9 +3745,11 @@ }, { "id": "driver_VIDEO_DOORBELL_2K_BATTERY", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "doorbell", "capabilities": [ @@ -4222,8 +3766,7 @@ "CMD_BAT_DOORBELL_WDR_SWITCH", "NTFY_MOTION_DETECTION", "NTFY_FACE_DETECTION", - "NTFY_PRESS_DOORBELL", - "NTFY_BACKGROUND_ACTIVE" + "NTFY_PRESS_DOORBELL" ], "energy": { "batteries": [ @@ -4239,6 +3782,13 @@ "small": "drivers/driver_VIDEO_DOORBELL_2K_BATTERY/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4246,9 +3796,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4289,9 +3836,11 @@ }, { "id": "driver_VIDEO_DOORBELL_DUAL_BATTERY", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "doorbell", "capabilities": [ @@ -4310,8 +3859,7 @@ "CMD_BAT_DOORBELL_WDR_SWITCH", "NTFY_MOTION_DETECTION", "NTFY_FACE_DETECTION", - "NTFY_PRESS_DOORBELL", - "NTFY_BACKGROUND_ACTIVE" + "NTFY_PRESS_DOORBELL" ], "energy": { "batteries": [ @@ -4327,6 +3875,13 @@ "small": "drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4334,9 +3889,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4377,10 +3929,12 @@ }, { "id": "driver_VIDEO_DOORBELL_1080P_POWERED", + "platforms": [ + "local" + ], "deprecated": true, "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "doorbell", "capabilities": [ @@ -4400,8 +3954,7 @@ "CMD_SET_HUB_ALARM_CLOSE", "NTFY_MOTION_DETECTION", "NTFY_FACE_DETECTION", - "NTFY_PRESS_DOORBELL", - "NTFY_BACKGROUND_ACTIVE" + "NTFY_PRESS_DOORBELL" ], "name": { "en": "Video Doorbell 1080p (Wired)", @@ -4412,6 +3965,13 @@ "small": "drivers/driver_VIDEO_DOORBELL_1080P_POWERED/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4419,9 +3979,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4548,42 +4105,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -4592,28 +4113,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -4621,10 +4120,12 @@ }, { "id": "driver_VIDEO_DOORBELL_1080P_BATTERY", + "platforms": [ + "local" + ], "deprecated": true, "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "doorbell", "capabilities": [ @@ -4643,8 +4144,7 @@ "CMD_BAT_DOORBELL_WDR_SWITCH", "NTFY_MOTION_DETECTION", "NTFY_FACE_DETECTION", - "NTFY_PRESS_DOORBELL", - "NTFY_BACKGROUND_ACTIVE" + "NTFY_PRESS_DOORBELL" ], "energy": { "batteries": [ @@ -4660,6 +4160,13 @@ "small": "drivers/driver_VIDEO_DOORBELL_1080P_BATTERY/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4667,9 +4174,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4710,9 +4214,11 @@ }, { "id": "driver_DOORSENSOR", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "sensor", "capabilities": [ @@ -4732,6 +4238,13 @@ "small": "drivers/driver_DOORSENSOR/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4739,9 +4252,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4782,9 +4292,11 @@ }, { "id": "driver_MOTIONSENSOR", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "sensor", "capabilities": [ @@ -4804,6 +4316,13 @@ "small": "drivers/driver_MOTIONSENSOR/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4811,9 +4330,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4822,9 +4338,11 @@ }, { "id": "driver_HOMEBASE_1", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "homealarm", "capabilities": [ @@ -4844,6 +4362,13 @@ "small": "drivers/driver_HOMEBASE_1/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -4851,9 +4376,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -4980,42 +4502,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -5024,28 +4510,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -5053,9 +4517,11 @@ }, { "id": "driver_HOMEBASE", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "homealarm", "capabilities": [ @@ -5075,6 +4541,13 @@ "small": "drivers/driver_HOMEBASE/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -5082,9 +4555,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -5211,42 +4681,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -5255,28 +4689,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -5284,9 +4696,11 @@ }, { "id": "driver_HOMEBASE_CHIME", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "homealarm", "capabilities": [ @@ -5306,6 +4720,13 @@ "small": "drivers/driver_HOMEBASE_CHIME/assets/images/small.png" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", @@ -5313,9 +4734,6 @@ "next": "add_devices" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -5442,42 +4860,6 @@ "nl": "Hub instellingen" }, "children": [ - { - "id": "LOCAL_STATION_IP", - "type": "text", - "label": { - "en": "LOCAL_STATION_IP", - "nl": "LOCAL_STATION_IP" - }, - "value": "" - }, - { - "id": "HUB_NAME", - "type": "label", - "label": { - "en": "HUB_NAME", - "nl": "HUB_NAME" - }, - "value": "" - }, - { - "id": "P2P_DID", - "type": "label", - "label": { - "en": "P2P_DID", - "nl": "P2P_DID" - }, - "value": "" - }, - { - "id": "ACTOR_ID", - "type": "label", - "label": { - "en": "ACTOR_ID", - "nl": "ACTOR_ID" - }, - "value": "" - }, { "id": "STATION_SN", "type": "label", @@ -5486,28 +4868,6 @@ "nl": "STATION_SN" }, "value": "" - }, - { - "id": "DSK_KEY", - "type": "label", - "label": { - "en": "DSK_KEY", - "nl": "DSK_KEY" - }, - "value": "" - }, - { - "id": "RESET_DATA", - "type": "checkbox", - "label": { - "en": "Reset settings?", - "nl": "Instellingen resetten?" - }, - "hint": { - "en": "When checking this setting above settings will be renewed from the Eufy Server", - "nl": "Door deze instelling aan te vinken zullen bovenstaande instellingen ververst worden van de Eufy Server" - }, - "value": false } ] } @@ -5515,31 +4875,46 @@ }, { "id": "driver_KEYPAD", + "platforms": [ + "local" + ], "connectivity": [ - "cloud", - "lan" + "cloud" ], "class": "homealarm", - "capabilities": [], + "capabilities": [ + "measure_battery", + "measure_temperature" + ], "name": { "en": "Keypad", "nl": "Keypad" }, + "energy": { + "batteries": [ + "INTERNAL" + ] + }, "images": { "large": "drivers/driver_KEYPAD/assets/images/large.jpg", "small": "drivers/driver_KEYPAD/assets/images/small.jpg" }, "pair": [ + { + "id": "login_eufy" + }, + { + "id": "loading", + "template": "loading" + }, { "id": "list_devices", "template": "list_devices", "navigation": { - "next": "add_devices" + "next": "add_devices", + "prev": "login_eufy" } }, - { - "id": "login_eufy" - }, { "id": "add_devices", "template": "add_devices" @@ -5769,30 +5144,30 @@ } }, "CMD_IRCUT_SWITCH": { - "type": "string", - "uiComponent": null, - "getable": false, - "setable": false, + "type": "boolean", + "getable": true, + "setable": true, + "uiComponent": "button", "title": { "en": "Toggle IR", "nl": "Zet Infrarood aan/uit" } }, "CMD_BAT_DOORBELL_VIDEO_QUALITY": { - "type": "string", - "uiComponent": null, - "getable": false, - "setable": false, + "type": "boolean", + "getable": true, + "setable": true, + "uiComponent": "button", "title": { "en": "Toggle HDR", "nl": "Zet HDR aan/uit" } }, "CMD_BAT_DOORBELL_WDR_SWITCH": { - "type": "string", - "uiComponent": null, - "getable": false, - "setable": false, + "type": "boolean", + "getable": true, + "setable": true, + "uiComponent": "button", "title": { "en": "Toggle WDR switch", "nl": "Zet WDR aan/uit" diff --git a/constants/device_types.js b/constants/device_types.js index b862754..10bd09c 100644 --- a/constants/device_types.js +++ b/constants/device_types.js @@ -8,6 +8,7 @@ exports.DEVICE_TYPES = { EUFYCAM_E: ['T8112'], FLOODLIGHT_CAMERA: ['T8420', 'T8422', 'T8424'], FLOODLIGHT_CAM_PAN_TILT:['T8423'], + KEYPAD: ['T8960'], HOMEBASE_1: ['T8001','T8002'], HOMEBASE_2: ['T8010'], HOMEBASE_CHIME: ['T8020'], diff --git a/constants/message_types.js b/constants/message_types.js deleted file mode 100644 index ca2bf2a..0000000 --- a/constants/message_types.js +++ /dev/null @@ -1,26 +0,0 @@ -exports.MESSAGE_TYPES = { - NTFY_BACKGROUND_ACTIVE: 3100, - NTFY_MOTION_DETECTION: 3101, - NTFY_FACE_DETECTION: 3102, - NTFY_PRESS_DOORBELL: 3103, - NTFY_CRYING_DETECTED: 3104, - NTFY_SOUND_DETECTED: 3105, - NTFY_PET_DETECTED: 3106, - CMD_SET_ARMING: 010101 -} - -// https://github.com/matijse/eufy-ha-mqtt-bridge/issues/27#issue-778345221 -exports.SPECIFIC_MESSAGE_TYPES = { - alarm_motion: "is triggered", - alarm_generic_on: "HomeBase is alarming", - alarm_generic_off: "alarm has been turned off", - NTFY_FACE_DETECTION: "Someone", - NTFY_MOTION_DETECTION: "Motion", - CMD_SET_ARMING: "Arming change" -} - -// DOOR_SENSOR_CHANGED: 100001 -exports.PUSH_MESSAGE_TYPES = { - DOOR_SENSOR_OPEN: '2-1', - DOOR_SENSOR_CLOSED: '2-0' -} \ No newline at end of file diff --git a/drivers/driver_DOORSENSOR/driver.js b/drivers/driver_DOORSENSOR/driver.js index 76b6982..5769066 100644 --- a/drivers/driver_DOORSENSOR/driver.js +++ b/drivers/driver_DOORSENSOR/driver.js @@ -1,8 +1,8 @@ const mainDriver = require('../main-driver'); -const { DEVICE_TYPES } = require('../../../constants/device_types'); + module.exports = class driver_DOORSENSOR extends mainDriver { deviceType() { - return DEVICE_TYPES.DOOR_SENSOR + return this.homey.app.deviceTypes.DOOR_SENSOR } } \ No newline at end of file diff --git a/drivers/driver_DOORSENSOR/pair/login_eufy.html b/drivers/driver_DOORSENSOR/pair/login_eufy.html index c673c87..08a8629 100644 --- a/drivers/driver_DOORSENSOR/pair/login_eufy.html +++ b/drivers/driver_DOORSENSOR/pair/login_eufy.html @@ -67,7 +67,7 @@
- + @@ -93,9 +93,7 @@ Homey.setTitle(Homey.__("$tmpl.login_credentials.title")), lgn.value = Homey.__("pair.login"); - Homey.on('error_msg', function (e) { - Homey.alert(e); - }) + o.addEventListener("submit", function (e) { if (e.preventDefault(), !m) { diff --git a/drivers/driver_EUFYCAM/driver.js b/drivers/driver_EUFYCAM/driver.js index 55bc363..7a2d2ef 100644 --- a/drivers/driver_EUFYCAM/driver.js +++ b/drivers/driver_EUFYCAM/driver.js @@ -1,8 +1,8 @@ const mainDriver = require('../main-driver'); -const { DEVICE_TYPES } = require('../../../constants/device_types'); + module.exports = class driver_EUFYCAM extends mainDriver { deviceType() { - return DEVICE_TYPES.EUFYCAM_1 + return this.homey.app.deviceTypes.EUFYCAM_1 } } \ No newline at end of file diff --git a/drivers/driver_EUFYCAM/pair/login_eufy.html b/drivers/driver_EUFYCAM/pair/login_eufy.html index c673c87..08a8629 100644 --- a/drivers/driver_EUFYCAM/pair/login_eufy.html +++ b/drivers/driver_EUFYCAM/pair/login_eufy.html @@ -67,7 +67,7 @@ + \ No newline at end of file diff --git a/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/eufy.svg b/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/eufy.svg new file mode 100644 index 0000000..7c1f3c9 --- /dev/null +++ b/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/eufy.svg @@ -0,0 +1,83 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/login_captcha.html b/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/login_captcha.html new file mode 100644 index 0000000..3145bcb --- /dev/null +++ b/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/login_captcha.html @@ -0,0 +1,105 @@ +
+ +
+ \ No newline at end of file diff --git a/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/login_eufy.html b/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/login_eufy.html new file mode 100644 index 0000000..54c73a3 --- /dev/null +++ b/drivers/driver_VIDEO_DOORBELL_DUAL_BATTERY/repair/login_eufy.html @@ -0,0 +1,133 @@ +
+ +
+ \ No newline at end of file diff --git a/drivers/main-driver.js b/drivers/main-driver.js index 4883729..f750b4b 100644 --- a/drivers/main-driver.js +++ b/drivers/main-driver.js @@ -3,7 +3,7 @@ const { sleep } = require('../lib/utils.js'); module.exports = class mainDriver extends Homey.Driver { onInit() { - this.homey.app.log('[Driver] - init', this.id); + this.homey.app.log('[Driver] - init', this.id, this.driverType()); this.homey.app.setDevices(this.getDevices()); } @@ -12,14 +12,34 @@ module.exports = class mainDriver extends Homey.Driver { return this.homey.app.deviceTypes.OTHER; } + driverType() { + return 'devices'; + } + async onPair(session) { + this.setPairingSession(session, 'pair') + } + + async onRepair(session) { + this.setPairingSession(session, 'repair') + } + + async setPairingSession(session, type) { this.deviceError = false; this._devices = []; + this.type = type; session.setHandler('showView', async (view) => { - this.homey.app.log(`[Driver] ${this.id} - currentView:`, view); + this.homey.app.log(`[Driver] ${this.id} - currentView:`, view, this.deviceError); if(view === 'login_eufy') { + if (this.id.includes('KEYPAD')) { + this.deviceError = this.homey.__('pair.keypad'); + + session.showView('error'); + return true; + } + this.appSettings = this.homey.app.appSettings; if(this.appSettings && this.appSettings.USERNAME) { @@ -34,28 +54,35 @@ module.exports = class mainDriver extends Homey.Driver { if (view === 'login_eufy' && this.homey.app.eufyClient.isConnected() && !this.deviceError) { session.nextView(); return true; - } else if(view === 'login_eufy' && this.deviceError) { + } + + if(view === 'login_captcha' && this.homey.app.needCaptcha) { + await session.emit('set_captcha', this.homey.app.needCaptcha.captcha); + } + + if(view === 'error' && this.deviceError) { await session.emit('deviceError', this.deviceError); - this.deviceError = false; } - + if (view === 'loading') { this.deviceList = await waitForResults(this); this.homey.app.log(`[Driver] ${this.id} - deviceList:`, this.deviceList.length, !!this.deviceList.length); - if(this.deviceList.length) { + if(!!this.deviceList.length) { session.nextView(); - } else if(this.deviceError) { - session.prevView(); + } else if(this.homey.app.needCaptcha) { + this.homey.app.log(`[Driver] ${this.id} - needCaptcha`); + session.showView('login_captcha') return []; } else { this.deviceError = this.homey.__('pair.no_devices'); - session.prevView(); + session.showView('error') + return []; } - + return true; } }); @@ -73,13 +100,23 @@ module.exports = class mainDriver extends Homey.Driver { return result; }); + session.setHandler('login_captcha', async (data) => { + const result = await this.homey.app.eufyCaptcha(data.captcha); + + this.deviceError = false; + + await sleep(3000); + + session.showView('loading') + + return result; + }); + session.setHandler('list_devices', async () => { try { - if (this.id.includes('KEYPAD')) { - this.deviceError = this.homey.__('pair.keypad'); - - session.showView('login_eufy'); - return []; + if(this.type === 'repair') { + this.homey.app.log(`[Driver] ${this.id} - list_devices: repair mode -> Closing repair`); + return session.showView('done'); } this._devices = await this.onDeviceListRequest(this.id); @@ -91,20 +128,17 @@ module.exports = class mainDriver extends Homey.Driver { } else if (this._devices && !!this._devices.info) { this.deviceError = this._devices.info; - session.showView('login_eufy'); - return []; + session.showView('error'); } else { this.deviceError = this.homey.__('pair.no_devices'); - session.showView('login_eufy'); - return []; + session.showView('error'); } } catch (error) { this.homey.app.log(`[Driver] ${this.id} - Error:`, error); this.deviceError = error; - - session.showView('login_eufy'); - return []; + + session.showView('error'); } }); @@ -112,7 +146,15 @@ module.exports = class mainDriver extends Homey.Driver { for (let i = 1; i <= retry; i++) { ctx.homey.app.log(`[Driver] ${ctx.id} - eufyDeviceData - try: ${i}`); await sleep(500); - const eufyDevices = await ctx.homey.app.eufyClient.getDevices(); + + let eufyDevices = [] + + if(ctx.driverType() === 'stations') { + eufyDevices = await ctx.homey.app.eufyClient.getStations(); + } else { + eufyDevices = await ctx.homey.app.eufyClient.getDevices(); + } + if (eufyDevices.length) { return Promise.resolve(eufyDevices); diff --git a/drivers/main-hub-driver.js b/drivers/main-hub-driver.js index 00e9f9b..6526861 100644 --- a/drivers/main-hub-driver.js +++ b/drivers/main-hub-driver.js @@ -1,118 +1,8 @@ -const Homey = require('homey'); -const { sleep } = require('../lib/utils.js'); +const mainDriver = require('./main-driver'); -module.exports = class mainDriver extends Homey.Driver { - onInit() { - this.homey.app.log('[Driver] - init', this.id); - - this.homey.app.setDevices(this.getDevices()); - } - - deviceType() { - return this.homey.app.deviceTypes.OTHER; - } - - async onPair(session) { - this.deviceError = false; - this._devices = []; - - session.setHandler('showView', async (view) => { - this.homey.app.log(`[Driver] ${this.id} - currentView:`, view); - - if(view === 'login_eufy') { - this.appSettings = this.homey.app.appSettings; - - if(this.appSettings && this.appSettings.USERNAME) { - await session.emit('set_user', this.appSettings.USERNAME); - } - - if(this.appSettings && this.appSettings.PASSWORD) { - await session.emit('set_password', this.appSettings.PASSWORD); - } - } - - if (view === 'login_eufy' && this.homey.app.eufyClient.isConnected() && !this.deviceError) { - session.nextView(); - return true; - } else if(view === 'login_eufy' && this.deviceError) { - await session.emit('deviceError', this.deviceError); - this.deviceError = false; - } - - if (view === 'loading') { - this.deviceList = await waitForResults(this); - - this.homey.app.log(`[Driver] ${this.id} - deviceList:`, this.deviceList.length, !!this.deviceList.length); - - - if(this.deviceList.length) { - session.nextView(); - } else if(this.deviceError) { - session.showView('login_eufy') - - return []; - } else { - this.deviceError = this.homey.__('pair.no_devices'); - session.showView('login_eufy') - - return []; - } - - return true; - } - }); - - session.setHandler('login', async (data) => { - const username = data.username; - const password = data.password; - - const settings = this.homey.app.appSettings; - const result = await this.homey.app.eufyLogin({ ...settings, USERNAME: username, PASSWORD: password, REGION: data.region }); - if (result === false) { - this.deviceError = this.homey.__('pair.no_data'); - } - - return result; - }); - - session.setHandler('list_devices', async () => { - try { - this._devices = await this.onDeviceListRequest(this.id); - - this.homey.app.log(`[Driver] ${this.id} - Found new devices:`, this._devices); - - if (this._devices && this._devices.length) { - return this._devices; - } else { - this.deviceError = this.homey.__('pair.no_devices'); - - session.showView('login_eufy'); - return []; - } - } catch (error) { - this.homey.app.log(`[Driver] ${this.id} - Error:`, error); - this.deviceError = error; - - session.showView('login_eufy'); - return []; - } - }); - - async function waitForResults(ctx, retry = 10) { - for (let i = 1; i <= retry; i++) { - ctx.homey.app.log(`[Driver] ${ctx.id} - eufyDeviceData - try: ${i}`); - await sleep(500); - const eufyDevices = await ctx.homey.app.eufyClient.getStations(); - - if (eufyDevices.length) { - return Promise.resolve(eufyDevices); - } else if (retry === 9) { - return Promise.resolve([]); - } - } - - return Promise.resolve([]); - } +module.exports = class mainHubDriver extends mainDriver { + driverType() { + return 'stations'; } // ---------------------------------------AUTO COMPLETE HELPERS---------------------------------------------------------- diff --git a/locales/en.json b/locales/en.json index 6ef4a9c..55c9c18 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1,7 +1,7 @@ { "settings": { "title": "Eufy Settings Page", - "subtitle": "Please log in", + "subtitle": "Login settings are removed from this page. To fix the Eufy login go to the device settings of a Eufy Device (e.g. Homebase 2) and click maintenance and then repair.", "account": "Account settings" }, "pair": { @@ -9,8 +9,10 @@ "usernamePlaceholder": "john@doe.com", "passwordLabel": "Password", "passwordPlaceholder": "Password", + "captchaLabel": "Captcha", "region": "Region", "login": "Login", + "loading": "Loading", "reset": "Do not reset the notification service if you have working triggers (person detected etc).

Hitting this button wil create a new instance and might cause duplicate", "no_data": "No devices found. Try a diferrent region.", "no_devices": "No devices found. Make sure you shared the Eufy devices with your admin extra account", diff --git a/locales/nl.json b/locales/nl.json index 8efc0cc..a047aeb 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -1,7 +1,7 @@ { "settings": { "title": "Eufy instellingen", - "subtitle": "Login", + "subtitle": "Login instellingen zijn verwijderd van deze pagina. Om de Eufy login aan te passen: Ga naar de apparaat instellingen van een Eufy device (Bijv. Homebase 2). Klik op onderhoud en dan repareren", "account": "Account instellingen" }, "pair": { @@ -9,9 +9,10 @@ "usernamePlaceholder": "john@doe.com", "passwordLabel": "Wachtwoord", "passwordPlaceholder": "Password", + "captchaLabel": "Captcha", "region": "Regio", "login": "Inloggen", - "reset": "Reset de notification service NIET als je al werkende 'ALS' kaarten hebt (persoon gedecteerd etc).

Het aanklikken van deze knop kan gedupliceerde notificaties veroorzaken!", + "loading": "Laden", "no_data": "Geen apparaten gevonden. Probeer een andere regio", "no_devices": "Geen apparaten gevonden. Zorg ervoor dat je de apparaten gedeeld hebt met je extra account.", "keypad": "Het toetsenbord is een fysiek apparaat om de beveiligingsmodus voor de Homebase in te stellen. Daarom heeft dit geen eigen functionaliteit in de Homey app. Om flows te maken op basis van of het wijzigen van beveiligingsmodi voegt u in plaats daarvan de homebase toe (als dat nog niet is gebeurd). Daar vindt u de beveiligingsmodi en stroomkaarten voor beveiligingsmodi." diff --git a/settings/index.html b/settings/index.html index 7e8fa3b..f2c2cff 100644 --- a/settings/index.html +++ b/settings/index.html @@ -45,35 +45,6 @@

-
- -
- - -
-
- - -
-
- -
- - - - -
-
-
-
- - -

-

-

-

-



- \ No newline at end of file diff --git a/settings/settings.js b/settings/settings.js deleted file mode 100644 index 032a1b4..0000000 --- a/settings/settings.js +++ /dev/null @@ -1,80 +0,0 @@ -function onHomeyReady(Homey) { - const _settingsKey = `com.eufylife.security.settings`; - - const initializeSettings = function (err, data) { - if (err || !data) { - document.getElementById('error').innerHTML = err; - return; - } - - document.getElementById('eufy_user').value = data['USERNAME']; - document.getElementById('eufy_pass').value = data['PASSWORD']; - if (document.querySelector(`input[name="region"][value="${data['REGION']}"]`)) { - document.querySelector(`input[name="region"][value="${data['REGION']}"]`).checked = true; - } else { - document.querySelector(`input[name="region"][value="US"]`).checked = true; - } - - initSave(data); - }; - - // -------------------------------------------------------------- - - Homey.get(_settingsKey, initializeSettings); - Homey.on('settings.set', (key, data) => { - if (key == _settingsKey) { - Homey.get(_settingsKey, initializeSettings); - } - }); - - Homey.ready(); -} - -function initSave(_settings) { - document.getElementById('save').addEventListener('click', function (e) { - const error = document.getElementById('error'); - const loading = document.getElementById('loading'); - const success = document.getElementById('success'); - const button = document.getElementById('save'); - - const USERNAME = document.getElementById('eufy_user').value; - const PASSWORD = document.getElementById('eufy_pass').value; - const regionSelect = document.querySelector('input[name="region"]:checked'); - const REGION = regionSelect ? regionSelect.value : 'US'; - - const settings = { - USERNAME, - PASSWORD, - REGION, - NOTIFICATIONS: _settings.NOTIFICATIONS || [] - }; - - // ---------------------------------------------- - - loading.innerHTML = 'Logging in. Please wait...'; - error.innerHTML = ''; - success.innerHTML = ''; - - if (USERNAME && PASSWORD) { - Homey.api('PUT', '/login', settings, function (err, result) { - if (err) { - error.innerHTML = err; - loading.innerHTML = ''; - return Homey.alert(err); - } else { - loading.innerHTML = ''; - error.innerHTML = ''; - success.innerHTML = 'Saved. Logged in to EufyLife. You can close this screen now.'; - } - }); - } else { - const error = 'Fill in USERNAME and PASSWORD.'; - Homey.alert(error); - - error.innerHTML = error; - button.disabled = false; - loading.innerHTML = ''; - success.innerHTML = ''; - } - }); -} From 01b331a217ad70a17f3be318bc41c17ace512fe2 Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Wed, 2 Nov 2022 16:44:44 +0100 Subject: [PATCH 33/41] FIX: pairing --- app.json | 364 ++++++++++++++++++----------------------- drivers/main-driver.js | 33 ++-- drivers/main-hub.js | 1 - lib/flow/actions.js | 1 - locales/en.json | 3 +- locales/nl.json | 3 +- 6 files changed, 177 insertions(+), 228 deletions(-) diff --git a/app.json b/app.json index c610636..cf5a9b1 100644 --- a/app.json +++ b/app.json @@ -1471,8 +1471,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -1480,8 +1479,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -1519,8 +1518,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -1528,8 +1526,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -1666,8 +1664,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -1675,8 +1672,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -1714,8 +1711,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -1723,8 +1719,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -1861,8 +1857,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -1870,8 +1865,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -1909,8 +1904,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -1918,8 +1912,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2057,8 +2051,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2066,8 +2059,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2105,8 +2098,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2114,8 +2106,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2253,8 +2245,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2262,8 +2253,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2301,8 +2292,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2310,8 +2300,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2447,8 +2437,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2456,8 +2445,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2495,8 +2484,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2504,8 +2492,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2641,8 +2629,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2650,8 +2637,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2689,8 +2676,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2698,8 +2684,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2878,8 +2864,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2887,8 +2872,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -2926,8 +2911,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -2935,8 +2919,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3117,8 +3101,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3126,8 +3109,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3165,8 +3148,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3174,8 +3156,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3356,8 +3338,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3365,8 +3346,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3404,8 +3385,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3413,8 +3393,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3595,8 +3575,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3604,8 +3583,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3643,8 +3622,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3652,8 +3630,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3834,8 +3812,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3843,8 +3820,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -3882,8 +3859,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -3891,8 +3867,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4074,8 +4050,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4083,8 +4058,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4122,8 +4097,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4131,8 +4105,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4315,8 +4289,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4324,8 +4297,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4363,8 +4336,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4372,8 +4344,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4556,8 +4528,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4565,8 +4536,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4604,8 +4575,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4613,8 +4583,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4794,8 +4764,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4803,8 +4772,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -4842,8 +4811,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -4851,8 +4819,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5032,8 +5000,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5041,8 +5008,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5080,8 +5047,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5089,8 +5055,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5231,8 +5197,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5240,8 +5205,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5279,8 +5244,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5288,8 +5252,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5429,8 +5393,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5438,8 +5401,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5477,8 +5440,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5486,8 +5448,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5670,8 +5632,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5679,8 +5640,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5718,8 +5679,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5727,8 +5687,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5852,8 +5812,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5861,8 +5820,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -5900,8 +5859,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -5909,8 +5867,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6034,8 +5992,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6043,8 +6000,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6082,8 +6039,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6091,8 +6047,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6191,8 +6147,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6200,8 +6155,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6239,8 +6194,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6248,8 +6202,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6419,8 +6373,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6428,8 +6381,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6467,8 +6420,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6476,8 +6428,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6647,8 +6599,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6656,8 +6607,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6695,8 +6646,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6704,8 +6654,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6879,8 +6829,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6888,8 +6837,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, @@ -6927,8 +6876,7 @@ { "id": "error", "navigation": { - "prev": "login_eufy", - "next": "done" + "prev": "login_eufy" }, "options": { "title": { @@ -6936,8 +6884,8 @@ "nl": "Error" }, "text": { - "en": "


To change the login click back. Or click next


", - "nl": "


Om opnieuw in te loggen, klik terug. Of klik verder


" + "en": "


To change the login click back.


", + "nl": "


Om opnieuw in te loggen, klik terug.


" } } }, diff --git a/drivers/main-driver.js b/drivers/main-driver.js index f750b4b..6be07ce 100644 --- a/drivers/main-driver.js +++ b/drivers/main-driver.js @@ -70,7 +70,22 @@ module.exports = class mainDriver extends Homey.Driver { this.homey.app.log(`[Driver] ${this.id} - deviceList:`, this.deviceList.length, !!this.deviceList.length); if(!!this.deviceList.length) { - session.nextView(); + this._devices = await this.onDeviceListRequest(this.id); + + this.homey.app.log(`[Driver] ${this.id} - Found new devices:`, this._devices); + + if (this._devices && this._devices.length) { + session.nextView(); + } else if (this._devices && !!this._devices.info) { + this.deviceError = this._devices.info; + + session.showView('error'); + } else { + this.deviceError = this.homey.__('pair.no_devices'); + + session.showView('error'); + } + } else if(this.homey.app.needCaptcha) { this.homey.app.log(`[Driver] ${this.id} - needCaptcha`); session.showView('login_captcha') @@ -119,21 +134,7 @@ module.exports = class mainDriver extends Homey.Driver { return session.showView('done'); } - this._devices = await this.onDeviceListRequest(this.id); - - this.homey.app.log(`[Driver] ${this.id} - Found new devices:`, this._devices); - - if (this._devices && this._devices.length) { - return this._devices; - } else if (this._devices && !!this._devices.info) { - this.deviceError = this._devices.info; - - session.showView('error'); - } else { - this.deviceError = this.homey.__('pair.no_devices'); - - session.showView('error'); - } + return this._devices; } catch (error) { this.homey.app.log(`[Driver] ${this.id} - Error:`, error); this.deviceError = error; diff --git a/drivers/main-hub.js b/drivers/main-hub.js index 1af79f9..299d2b9 100644 --- a/drivers/main-hub.js +++ b/drivers/main-hub.js @@ -1,6 +1,5 @@ const mainDevice = require('./main-device'); const { ARM_TYPES } = require('../constants/capability_types'); -const { sleep } = require('../lib/utils.js'); const { PropertyName } = require('eufy-security-client'); module.exports = class mainHub extends mainDevice { diff --git a/lib/flow/actions.js b/lib/flow/actions.js index 062e77c..a717f67 100644 --- a/lib/flow/actions.js +++ b/lib/flow/actions.js @@ -16,7 +16,6 @@ exports.init = async function (homey) { homey.app.action_CMD_TRIGGER_RINGTONE_HUB = homey.flow.getActionCard('action_CMD_TRIGGER_RINGTONE_HUB'); homey.app.action_CMD_TRIGGER_RINGTONE_HUB.registerRunListener(async (args, state) => { - await args.device.onCapability_CMD_TRIGGER_RINGTONE_HUB(args.action_CMD_TRIGGER_RINGTONE_HUB_TYPE); return await args.device.onCapability_CMD_TRIGGER_RINGTONE_HUB(args.action_CMD_TRIGGER_RINGTONE_HUB_TYPE); }); diff --git a/locales/en.json b/locales/en.json index 55c9c18..ff6d480 100644 --- a/locales/en.json +++ b/locales/en.json @@ -19,6 +19,7 @@ "keypad": "The keypad is a physical device to set the security mode for the Homebase. Therefore this has no own functionality in the Homey app. To make flows based on or change security modes please add the homebase instead (if not already done so). There you can find the security modes and flow cards for security modes." }, "device": { - "init": "is connecting to Eufy Server..." + "init": "is connecting to Eufy Server...", + "needCaptcha": "Connection failed (Captcha neeeded). Try to repair the device. Device settings -> maintenance -> repair" } } diff --git a/locales/nl.json b/locales/nl.json index a047aeb..3740631 100644 --- a/locales/nl.json +++ b/locales/nl.json @@ -18,6 +18,7 @@ "keypad": "Het toetsenbord is een fysiek apparaat om de beveiligingsmodus voor de Homebase in te stellen. Daarom heeft dit geen eigen functionaliteit in de Homey app. Om flows te maken op basis van of het wijzigen van beveiligingsmodi voegt u in plaats daarvan de homebase toe (als dat nog niet is gebeurd). Daar vindt u de beveiligingsmodi en stroomkaarten voor beveiligingsmodi." }, "device": { - "init": "maakt verbinding met Eufy Server..." + "init": "maakt verbinding met Eufy Server...", + "needCaptcha": "Verbinding mislukt (Captcha vereist). Probeer het apparaat te repareren. Apparaat instellingen -> onderhoud -> repareren" } } From 571662b864bebc30f9ab52985e1375bfe82c9a34 Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Wed, 2 Nov 2022 16:48:44 +0100 Subject: [PATCH 34/41] NEW: show repair message --- drivers/main-device.js | 6 ++++++ drivers/main-hub.js | 2 ++ drivers/main-sensor.js | 2 ++ 3 files changed, 10 insertions(+) diff --git a/drivers/main-device.js b/drivers/main-device.js index ce8d804..0f66446 100644 --- a/drivers/main-device.js +++ b/drivers/main-device.js @@ -17,6 +17,8 @@ module.exports = class mainDevice extends Homey.Device { try { this.homey.app.log(`[Device] ${this.getName()} - starting`); + this.setUnavailable(`${this.getName()} ${this.homey.__('device.init')}`); + this.EufyDevice = await this.homey.app.eufyClient.getDevice(this.HomeyDevice.device_sn); this.EufyStation = await this.homey.app.eufyClient.getStation(this.HomeyDevice.station_sn); @@ -72,6 +74,10 @@ module.exports = class mainDevice extends Homey.Device { this._image = null; await sleep(6500); + + if(this.homey.app.needCaptcha) { + this.setUnavailable(`${this.getName()} ${this.homey.__('device.needCaptcha')}`); + } } async resetCapabilities() { diff --git a/drivers/main-hub.js b/drivers/main-hub.js index 299d2b9..d66fc7e 100644 --- a/drivers/main-hub.js +++ b/drivers/main-hub.js @@ -7,6 +7,8 @@ module.exports = class mainHub extends mainDevice { try { this.homey.app.log(`[Device] ${this.getName()} - starting`); + this.setUnavailable(`${this.getName()} ${this.homey.__('device.init')}`); + this.EufyStation = await this.homey.app.eufyClient.getStation(this.HomeyDevice.station_sn); // When we need station calls and the device is the same as the station diff --git a/drivers/main-sensor.js b/drivers/main-sensor.js index 8a88735..3ea9fb5 100644 --- a/drivers/main-sensor.js +++ b/drivers/main-sensor.js @@ -5,6 +5,8 @@ module.exports = class mainSensor extends mainDevice { try { this.homey.app.log(`[Device] ${this.getName()} - starting`); + this.setUnavailable(`${this.getName()} ${this.homey.__('device.init')}`); + this.EufyDevice = await this.homey.app.eufyClient.getDevice(this.HomeyDevice.device_sn); this.EufyStation = await this.homey.app.eufyClient.getStation(this.HomeyDevice.station_sn); From 784eeb2c47e59f1a9de2ea5650342b3efed5a6ec Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Wed, 2 Nov 2022 21:31:16 +0100 Subject: [PATCH 35/41] FIX: image update --- app.js | 2 ++ lib/helpers/eufy-events.helper.js | 8 +------- lib/helpers/eufy-notification-check.helper.js | 11 ++--------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/app.js b/app.js index 71091f5..acf1f51 100644 --- a/app.js +++ b/app.js @@ -244,6 +244,8 @@ class App extends Homey.App { if (loggedIn) { this.log('eufyCaptcha - Succes'); this.needCaptcha = null; + + this.eufyClient.writePersistentData(); } else { return false; } diff --git a/lib/helpers/eufy-events.helper.js b/lib/helpers/eufy-events.helper.js index 2869c35..bdd4da5 100644 --- a/lib/helpers/eufy-events.helper.js +++ b/lib/helpers/eufy-events.helper.js @@ -76,13 +76,7 @@ module.exports = class eufyEventsHelper { } if (name === PropertyName.DevicePictureUrl && homeyDevice._image) { - if (!eufyDevice.isMotionDetected || !eufyDevice.isPersonDetected) { - await sleep(2000); - - homeyDevice._image.update(); - - await sleep(2000); - } + homeyDevice._image.update(); } } } diff --git a/lib/helpers/eufy-notification-check.helper.js b/lib/helpers/eufy-notification-check.helper.js index 16216ff..3c89bb8 100644 --- a/lib/helpers/eufy-notification-check.helper.js +++ b/lib/helpers/eufy-notification-check.helper.js @@ -81,14 +81,6 @@ module.exports = class eufyNotificationCheckHelper { } } - async setDeviceImage(device) { - if(device._image) { - this.homey.app.log(`[NTFY] - 2b. Update Image`); - await device._image.update(); - await sleep(2000); - } - } - async triggerFlow(device, device_sn, message, state, user = null) { this.homey.app.log(`[NTFY] - 2. Trigger device_sn: ${message} - ${device_sn}`); if (message.includes('alarm_')) { @@ -100,7 +92,8 @@ module.exports = class eufyNotificationCheckHelper { this.homey.app.log(`[NTFY] - 3. ${device.getName()} doesn't contain ${message} - with state: ${state}`); } } else if(state) { - await this.setDeviceImage(device) + this.homey.app.log(`[NTFY] - 2b. Update Image`); + await sleep(1000); await device.onCapability_NTFY_TRIGGER(message, state); From a714cbedbdb25358235c1420841df127e11baa5f Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Wed, 2 Nov 2022 21:35:44 +0100 Subject: [PATCH 36/41] Bump version to v3.2.0 Changelog: NEW: add captcha to login | NEW: add repair option | FIX: remove settings page --- .homeychangelog.json | 3 + app.json | 270 ++++++++++++++++++++++++++++++++----------- 2 files changed, 204 insertions(+), 69 deletions(-) diff --git a/.homeychangelog.json b/.homeychangelog.json index 39fc542..95ce16f 100644 --- a/.homeychangelog.json +++ b/.homeychangelog.json @@ -1009,5 +1009,8 @@ }, "3.1.5": { "en": "FIX: issue in NotificationType" + }, + "3.2.0": { + "en": "NEW: add captcha to login | NEW: add repair option | FIX: remove settings page" } } diff --git a/app.json b/app.json index cf5a9b1..f572538 100644 --- a/app.json +++ b/app.json @@ -1,11 +1,11 @@ { "id": "com.eufylife.security", - "version": "3.1.5", + "version": "3.2.0", "compatibility": ">=5.0.0", "sdk": 3, "brandColor": "#2a6185", "platforms": [ - "local", "cloud" + "local" ], "name": { "en": "Eufy Security", @@ -1414,8 +1414,12 @@ "drivers": [ { "id": "driver_EUFYCAM", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -1432,7 +1436,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "eufyCam 1", @@ -1607,8 +1613,12 @@ }, { "id": "driver_EUFYCAM_2", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -1625,7 +1635,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "eufyCam 2", @@ -1800,8 +1812,12 @@ }, { "id": "driver_EUFYCAM_2_PRO", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -1818,7 +1834,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "eufyCam 2 Pro", @@ -1993,8 +2011,12 @@ }, { "id": "driver_EUFYCAM_2C", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -2012,7 +2034,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "eufyCam 2C", @@ -2187,8 +2211,12 @@ }, { "id": "driver_EUFYCAM_2C_PRO", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -2206,7 +2234,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "eufyCam 2C Pro", @@ -2381,8 +2411,12 @@ }, { "id": "driver_EUFYCAM_E", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -2398,7 +2432,9 @@ "NTFY_MOTION_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "eufyCam E", @@ -2573,8 +2609,12 @@ }, { "id": "driver_FLOODLIGHT_CAMERA", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -2806,8 +2846,12 @@ }, { "id": "driver_FLOODLIGHT_CAM_PAN_TILT", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -3041,8 +3085,12 @@ }, { "id": "driver_INDOOR_CAM", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -3278,8 +3326,12 @@ }, { "id": "driver_INDOOR_CAM_PAN_TILT", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -3515,8 +3567,12 @@ }, { "id": "driver_OUTDOOR_CAM", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -3752,8 +3808,12 @@ }, { "id": "driver_OUTDOOR_CAM_PRO", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -3989,8 +4049,12 @@ }, { "id": "driver_SOLOCAM_E2040", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -4011,7 +4075,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "SoloCam E20 / E40", @@ -4227,8 +4293,12 @@ }, { "id": "driver_SOLOCAM_L2040", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -4250,7 +4320,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "SoloCam L20 / L40", @@ -4466,8 +4538,12 @@ }, { "id": "driver_SOLOCAM_S2040", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "camera", "capabilities": [ "onoff", @@ -4489,7 +4565,9 @@ "NTFY_FACE_DETECTION" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "SoloCam (Solar) S40", @@ -4705,8 +4783,12 @@ }, { "id": "driver_VIDEO_DOORBELL_2K_POWERED", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "doorbell", "capabilities": [ "onoff", @@ -4941,8 +5023,12 @@ }, { "id": "driver_VIDEO_DOORBELL_2K_BATTERY", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "doorbell", "capabilities": [ "onoff", @@ -4961,7 +5047,9 @@ "NTFY_PRESS_DOORBELL" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "Battery Doorbell (1080P/2K)", @@ -5136,8 +5224,12 @@ }, { "id": "driver_VIDEO_DOORBELL_DUAL_BATTERY", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "doorbell", "capabilities": [ "onoff", @@ -5158,7 +5250,9 @@ "NTFY_PRESS_DOORBELL" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "Battery Dual Doorbell", @@ -5333,9 +5427,13 @@ }, { "id": "driver_VIDEO_DOORBELL_1080P_POWERED", - "platforms": ["local", "cloud"], + "platforms": [ + "local" + ], "deprecated": true, - "connectivity": ["cloud"], + "connectivity": [ + "cloud" + ], "class": "doorbell", "capabilities": [ "onoff", @@ -5570,9 +5668,13 @@ }, { "id": "driver_VIDEO_DOORBELL_1080P_BATTERY", - "platforms": ["local", "cloud"], + "platforms": [ + "local" + ], "deprecated": true, - "connectivity": ["cloud"], + "connectivity": [ + "cloud" + ], "class": "doorbell", "capabilities": [ "onoff", @@ -5593,7 +5695,9 @@ "NTFY_PRESS_DOORBELL" ], "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "name": { "en": "Video Doorbell 1080p (Battery-Powered)", @@ -5768,16 +5872,24 @@ }, { "id": "driver_DOORSENSOR", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "sensor", - "capabilities": ["alarm_contact"], + "capabilities": [ + "alarm_contact" + ], "name": { "en": "Doorsensor", "nl": "Deursensor" }, "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "images": { "large": "drivers/driver_DOORSENSOR/assets/images/large.jpg", @@ -5948,16 +6060,24 @@ }, { "id": "driver_MOTIONSENSOR", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "sensor", - "capabilities": ["alarm_motion"], + "capabilities": [ + "alarm_motion" + ], "name": { "en": "Motionsensor", "nl": "Bewegingssensor" }, "energy": { - "batteries": ["INTERNAL"] + "batteries": [ + "INTERNAL" + ] }, "images": { "large": "drivers/driver_MOTIONSENSOR/assets/images/large.jpg", @@ -6098,8 +6218,12 @@ }, { "id": "driver_HOMEBASE_1", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "homealarm", "capabilities": [ "alarm_arm_mode", @@ -6324,8 +6448,12 @@ }, { "id": "driver_HOMEBASE", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "homealarm", "capabilities": [ "alarm_arm_mode", @@ -6550,8 +6678,12 @@ }, { "id": "driver_HOMEBASE_CHIME", - "platforms": ["local", "cloud"], - "connectivity": ["cloud"], + "platforms": [ + "local" + ], + "connectivity": [ + "cloud" + ], "class": "homealarm", "capabilities": [ "alarm_arm_mode", @@ -6777,7 +6909,7 @@ { "id": "driver_KEYPAD", "platforms": [ - "local", "cloud" + "local" ], "connectivity": [ "cloud" From 4f28f60c2db7653bcd0bd5d02baf45c3b8c0dc31 Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Wed, 2 Nov 2022 22:05:32 +0100 Subject: [PATCH 37/41] Bump version to v3.2.1 Changelog: FIX: pair and repair process --- .homeychangelog.json | 3 +++ app.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.homeychangelog.json b/.homeychangelog.json index 95ce16f..78a30ce 100644 --- a/.homeychangelog.json +++ b/.homeychangelog.json @@ -1012,5 +1012,8 @@ }, "3.2.0": { "en": "NEW: add captcha to login | NEW: add repair option | FIX: remove settings page" + }, + "3.2.1": { + "en": "FIX: pair and repair process" } } diff --git a/app.json b/app.json index f572538..51fc3d1 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,6 @@ { "id": "com.eufylife.security", - "version": "3.2.0", + "version": "3.2.1", "compatibility": ">=5.0.0", "sdk": 3, "brandColor": "#2a6185", From 473f9dcc075d63f30654e1bf044f1301aa36d41c Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Thu, 3 Nov 2022 21:53:08 +0100 Subject: [PATCH 38/41] FIX: repair | FIX: issue with event helper --- app.js | 2 +- drivers/main-driver.js | 82 ++++++++++++++----------------- lib/helpers/eufy-events.helper.js | 2 +- 3 files changed, 40 insertions(+), 46 deletions(-) diff --git a/app.js b/app.js index acf1f51..43fe116 100644 --- a/app.js +++ b/app.js @@ -333,7 +333,7 @@ class App extends Homey.App { } async switchRegions() { - await sleep(3000); + await sleep(4000); const eufyDevices = await this.eufyClient.getDevices(); this.log('switchRegions', { region: this.appSettings.REGION, eufyRegionSwitchAllowed: this.eufyRegionSwitchAllowed, deviceList: this.deviceList.length, eufyDevices: eufyDevices.length }); diff --git a/drivers/main-driver.js b/drivers/main-driver.js index 6be07ce..ccec40b 100644 --- a/drivers/main-driver.js +++ b/drivers/main-driver.js @@ -4,7 +4,7 @@ const { sleep } = require('../lib/utils.js'); module.exports = class mainDriver extends Homey.Driver { onInit() { this.homey.app.log('[Driver] - init', this.id, this.driverType()); - + this.homey.app.setDevices(this.getDevices()); } @@ -17,87 +17,87 @@ module.exports = class mainDriver extends Homey.Driver { } async onPair(session) { - this.setPairingSession(session, 'pair') + this.type = 'pair'; + this.setPairingSession(session); } async onRepair(session) { - this.setPairingSession(session, 'repair') + this.type = 'repair'; + this.setPairingSession(session); } - async setPairingSession(session, type) { + async setPairingSession(session) { this.deviceError = false; this._devices = []; - this.type = type; session.setHandler('showView', async (view) => { - this.homey.app.log(`[Driver] ${this.id} - currentView:`, view, this.deviceError); + this.homey.app.log(`[Driver] ${this.id} - currentView:`, { view, type: this.type, deviceError: this.deviceError }); - if(view === 'login_eufy') { - if (this.id.includes('KEYPAD')) { - this.deviceError = this.homey.__('pair.keypad'); - - session.showView('error'); - return true; - } + if (view === 'login_eufy' && this.id.includes('KEYPAD')) { + this.deviceError = this.homey.__('pair.keypad'); - this.appSettings = this.homey.app.appSettings; + session.showView('error'); + return true; + } - if(this.appSettings && this.appSettings.USERNAME) { - await session.emit('set_user', this.appSettings.USERNAME); - } + if (view === 'login_eufy') { + this.appSettings = this.homey.app.appSettings; - if(this.appSettings && this.appSettings.PASSWORD) { - await session.emit('set_password', this.appSettings.PASSWORD); + if (this.appSettings && this.appSettings.USERNAME && this.appSettings.PASSWORD) { + session.emit('set_user', this.appSettings.USERNAME); + session.emit('set_password', this.appSettings.PASSWORD); } } if (view === 'login_eufy' && this.homey.app.eufyClient.isConnected() && !this.deviceError) { session.nextView(); return true; - } + } - if(view === 'login_captcha' && this.homey.app.needCaptcha) { + if (view === 'login_captcha' && this.homey.app.needCaptcha) { await session.emit('set_captcha', this.homey.app.needCaptcha.captcha); } - - if(view === 'error' && this.deviceError) { + + if (view === 'error' && this.deviceError) { await session.emit('deviceError', this.deviceError); } - + if (view === 'loading') { this.deviceList = await waitForResults(this); this.homey.app.log(`[Driver] ${this.id} - deviceList:`, this.deviceList.length, !!this.deviceList.length); - if(!!this.deviceList.length) { + if (!!this.deviceList.length) { this._devices = await this.onDeviceListRequest(this.id); this.homey.app.log(`[Driver] ${this.id} - Found new devices:`, this._devices); - - if (this._devices && this._devices.length) { + + if (this.type === 'repair') { + this.homey.app.log(`[Driver] ${this.id} - list_devices: repair mode -> Closing repair`); + return session.showView('done'); + } else if (this._devices && this._devices.length) { session.nextView(); } else if (this._devices && !!this._devices.info) { this.deviceError = this._devices.info; - + session.showView('error'); } else { this.deviceError = this.homey.__('pair.no_devices'); - + session.showView('error'); } - - } else if(this.homey.app.needCaptcha) { + } else if (this.homey.app.needCaptcha) { this.homey.app.log(`[Driver] ${this.id} - needCaptcha`); - session.showView('login_captcha') + session.showView('login_captcha'); return []; } else { this.deviceError = this.homey.__('pair.no_devices'); - session.showView('error') + session.showView('error'); return []; } - + return true; } }); @@ -121,19 +121,14 @@ module.exports = class mainDriver extends Homey.Driver { this.deviceError = false; await sleep(3000); - - session.showView('loading') + + session.showView('loading'); return result; }); session.setHandler('list_devices', async () => { try { - if(this.type === 'repair') { - this.homey.app.log(`[Driver] ${this.id} - list_devices: repair mode -> Closing repair`); - return session.showView('done'); - } - return this._devices; } catch (error) { this.homey.app.log(`[Driver] ${this.id} - Error:`, error); @@ -148,14 +143,13 @@ module.exports = class mainDriver extends Homey.Driver { ctx.homey.app.log(`[Driver] ${ctx.id} - eufyDeviceData - try: ${i}`); await sleep(500); - let eufyDevices = [] + let eufyDevices = []; - if(ctx.driverType() === 'stations') { + if (ctx.driverType() === 'stations') { eufyDevices = await ctx.homey.app.eufyClient.getStations(); } else { eufyDevices = await ctx.homey.app.eufyClient.getDevices(); } - if (eufyDevices.length) { return Promise.resolve(eufyDevices); diff --git a/lib/helpers/eufy-events.helper.js b/lib/helpers/eufy-events.helper.js index bdd4da5..e4033c3 100644 --- a/lib/helpers/eufy-events.helper.js +++ b/lib/helpers/eufy-events.helper.js @@ -94,7 +94,7 @@ module.exports = class eufyEventsHelper { await this.homey.app.eufyClient.setStationProperty(settings.STATION_SN, PropertyName.StationNotificationSwitchModeKeypad, true); } - if (settings.force_include_thumbnail && homeyDevice.EufyDevice.hasProperty(PropertyName.DeviceNotificationType) && settings.DEVICE_SN) { + if (settings.force_include_thumbnail && homeyDevice.EufyDevice && homeyDevice.EufyDevice.hasProperty(PropertyName.DeviceNotificationType) && settings.DEVICE_SN) { this.homey.app.log(`[Device] ${homeyDevice.getName()} - enforceSettings - DeviceNotificationType`); await this.homey.app.eufyClient.setDeviceProperty(settings.DEVICE_SN, PropertyName.DeviceNotificationType, 2); } From f65df62a2acbf26b97df0e526a8e78ee098dc9ce Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Thu, 3 Nov 2022 21:58:50 +0100 Subject: [PATCH 39/41] FIX: settings page error --- settings/index.html | 4 ++++ settings/settings.js | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 settings/settings.js diff --git a/settings/index.html b/settings/index.html index f2c2cff..73b5c0c 100644 --- a/settings/index.html +++ b/settings/index.html @@ -46,5 +46,9 @@



+

+

+

+ \ No newline at end of file diff --git a/settings/settings.js b/settings/settings.js new file mode 100644 index 0000000..5b419b2 --- /dev/null +++ b/settings/settings.js @@ -0,0 +1,21 @@ +function onHomeyReady(Homey) { + const _settingsKey = `com.eufylife.security.settings`; + + const initializeSettings = function (err, data) { + if (err || !data) { + document.getElementById('error').innerHTML = err; + return; + } + }; + + // -------------------------------------------------------------- + + Homey.get(_settingsKey, initializeSettings); + Homey.on('settings.set', (key, data) => { + if (key == _settingsKey) { + Homey.get(_settingsKey, initializeSettings); + } + }); + + Homey.ready(); +} From 2775ffb9556ce4783db75de1db6b77c04da46a41 Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Thu, 3 Nov 2022 22:02:55 +0100 Subject: [PATCH 40/41] Bump version to v3.2.2 Changelog: FIX: repair | FIX: issue with event helper --- .homeychangelog.json | 3 +++ app.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.homeychangelog.json b/.homeychangelog.json index 78a30ce..e10c7eb 100644 --- a/.homeychangelog.json +++ b/.homeychangelog.json @@ -1015,5 +1015,8 @@ }, "3.2.1": { "en": "FIX: pair and repair process" + }, + "3.2.2": { + "en": "FIX: repair | FIX: issue with event helper" } } diff --git a/app.json b/app.json index 51fc3d1..a5dc869 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,6 @@ { "id": "com.eufylife.security", - "version": "3.2.1", + "version": "3.2.2", "compatibility": ">=5.0.0", "sdk": 3, "brandColor": "#2a6185", From ce6963cf318c7ef81ba2c2c0d98ea21f23faac38 Mon Sep 17 00:00:00 2001 From: Martijn Poppen Date: Thu, 3 Nov 2022 22:05:16 +0100 Subject: [PATCH 41/41] Bump version to v3.2.3 --- app.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.json b/app.json index a5dc869..560f244 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,6 @@ { "id": "com.eufylife.security", - "version": "3.2.2", + "version": "3.2.3", "compatibility": ">=5.0.0", "sdk": 3, "brandColor": "#2a6185",