diff --git a/config.schema copy.json b/config.schema copy.json deleted file mode 100644 index 9af81d8..0000000 --- a/config.schema copy.json +++ /dev/null @@ -1,364 +0,0 @@ -{ - "pluginAlias": "Alexa", - "pluginType": "platform", - "singular": true, - "headerDisplay": "

Allow your Amazon Alexa to control your homebridge devices


To setup the service:

1 - First create an account on https://www.homebridge.ca/.
2 - Then enter the username and password for your account below.
3 - Save the settings and restart homebridge.
4 - In the Amazon Alexa Application on your smart phone, search for the Homebridge Skill and enable it. When you enable the skill, it will take you to the https://www.homebridge.ca/ website to enable and link the skill to the plugin.
5 - You can now ask Alexa to `discover devices` and it should discover your homebridge devices.

Detailed setup instructions are available here.
", - "footerDisplay": "Homebridge Alexa Skill: https://www.amazon.com/Northern-Man-54-Homebridge/dp/B07B9QMTFQ", - "schema": { - "type": "object", - "properties": { - "name": { - "title": "Name", - "type": "string", - "required": true, - "default": "Alexa", - "description": "Plugin name as displayed in the Homebridge log" - }, - "username": { - "title": "Username", - "type": "string", - "required": true, - "description": "Username for https://www.homebridge.ca/" - }, - "password": { - "title": "Password", - "type": "string", - "required": true, - "description": "Password for https://www.homebridge.ca/" - }, - "pin": { - "title": "Homebridge Pin", - "type": "string", - "placeholder": "031-45-154", - "description": "This needs to match the Homebridge pin set in your config.json file" - }, - "routines": { - "title": "Routines", - "type": "boolean", - "placeholder": false, - "description": "Enables passing of Motion and Contact sensor events to Alexa. For use in the Alexa app to create Routines triggered by these sensors." - }, - "blind": { - "title": "Blind", - "type": "boolean", - "placeholder": false, - "description": "Enables natural wording for opening and closing blinds, and window coverings. Not supported in all countries. Defaults to false" - }, - "door": { - "title": "Door", - "type": "boolean", - "placeholder": false, - "description": "Enables natural wording for opening and closing garage doors. Not supported in all countries. Please note that opening a garage door requires setting a voice pin within the Alexa app. Defaults to false" - }, - "debug": { - "title": "Debug", - "type": "boolean", - "placeholder": false, - "description": "Enable debug level logging to assist in problem investigation." - }, - "beta": { - "title": "beta", - "type": "boolean", - "placeholder": false, - "description": "Enable beta test environment. Only available by invitation." - }, - "refresh": { - "title": "Accessory Cache Refresh Interval", - "type": "integer", - "default": 900, - "description": "Frequency of refreshes of the homebridge accessory cache, in seconds. Defaults to 900 Seconds ( 15 minutes ). This is the interval before new devices/homebridge instances are discovered. This should never require changing, unless you are frequently changing your homebridge configuration without restarting the plugin.", - "minimum": 120, - "maximum": 86400 - }, - "keepalive": { - "title": "Cloud Server Connection Keepalive", - "type": "integer", - "default": "5", - "description": "Frequency of keepalive messages to cloud server, in minutes. Defaults to 5 minutes. Do not change from default unless requested as part of problem investigation.", - "minimum": 1, - "maximum": 59, - "condition": { - "functionBody": "return model.CloudTransport !== 'wss';" - } - }, - "mergeServiceName": { - "title": "Alternate device naming approach", - "type": "boolean", - "description": "This is an alternate device naming approach, which combines the internal HomeKit names for a device. It may resolve duplicate device name issues. Do not enable on an existing implementation, as you will lose control of your existing devices.", - "placeholder": false - }, - "thermostatTurnOn": { - "title": "Thermostat Turn On Behaviour", - "description": "Set Thermostat `Turn On` Behaviour to either Heat, Cool or Auto when Alexa is asked to turn on a Thermostat. Defaults to doing nothing and saying `That command does not work on device ...`.", - "type": "integer", - "oneOf": [ - { - "title": "Heat", - "enum": [ - 1 - ] - }, - { - "title": "Cool", - "enum": [ - 2 - ] - }, - { - "title": "Auto", - "enum": [ - 3 - ] - } - ] - }, - "CloudTransport": { - "title": "Cloud Server Connection Transport", - "description": "Transport options for cloud server connection. MQTTS - this is the recommended setting. MQTT - this is the original/legacy option. WSS - this is the an alternative transport option.", - "type": "string", - "default": "mqtts", - "required": true, - "oneOf": [ - { - "title": "MQTTS", - "enum": [ - "mqtts" - ] - }, - { - "title": "WSS", - "enum": [ - "wss" - ] - }, - { - "title": "MQTT", - "enum": [ - "mqtt" - ] - } - ] - }, - "filter": { - "title": "Homebridge Instance Filter", - "type": "string", - "placeholder": "eg. 192.168.1.122:51826", - "description": "Limits accessories shared with Alexa to particular homebridge instances. Uses ip address and port of homebridge instance, eg. '192.168.1.122:51826' or '192.168.1.11:51551, 192.168.1.11:46047'.", - "pattern": "^(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d{1,5})(,\\s*\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}:\\d{1,5})*$" - }, - "deviceListHandling": { - "title": "Device List", - "type": "string", - "description": "Allows filtering of devices by name. You can either allow or ignore a list of device names.", - "default": "none", - "required": true, - "oneOf": [ - { - "title": "None", - "enum": [ - "none" - ] - }, - { - "title": "Allow devices", - "enum": [ - "allow" - ] - }, - { - "title": "Ignore devices", - "enum": [ - "deny" - ] - } - ] - }, - "deviceList": { - "title": "Devices to be allowed or denied", - "type": "array", - "items": { - "type": "string" - }, - "condition": { - "functionBody": "if (model.deviceListHandling === 'allow' || model.deviceListHandling === 'deny') { return true } else { return false };" - } - }, - "combine": { - "type": "array", - "items": { - "title": "Combine", - "type": "object", - "properties": { - "into": { - "title": "Into", - "type": "string" - }, - "from": { - "title": "From", - "type": "array", - "items": { - "type": "string" - } - } - } - } - }, - "speakers": { - "title": "Speakers", - "type": "array", - "items": { - "title": "Speaker", - "type": "object", - "properties": { - "manufacturer": { - "title": "Manufacturer", - "type": "string" - }, - "name": { - "title": "Name", - "type": "string" - } - } - } - }, - "enhancedSkip": { - "title": "For 'appletv-enhanced', enable skip", - "type": "boolean", - "placeholder": false, - "description": "This option will change the behaviour of the next or skip command of the 'appletv-enhanced' plugin, from skip to select. This will enable the wording 'Alexa tv skip' to press the select button on the Apple TV remote. This is useful for skipping adds on YouTube." - } - } - }, - "layout": [ - { - "type": "fieldset", - "title": "Required Settings", - "items": [ - { - "type": "flex", - "flex-flow": "row wrap", - "items": [ - "username", - { - "key": "password", - "type": "password" - } - ] - } - ] - }, - { - "type": "fieldset", - "title": "Optional Settings", - "expandable": true, - "expanded": false, - "items": [ - "pin", - "routines", - "debug", - "thermostatTurnOn", - "enhancedSkip", - "deviceListHandling", - { - "key": "deviceList", - "type": "array", - "items": { - "title": "DeviceName", - "description": "Name of the device you want to allow or ignore", - "type": "string" - }, - "condition": { - "functionBody": "return model.deviceListHandling !== 'none';" - } - } - ] - }, - { - "type": "fieldset", - "title": "Advanced Settings", - "expandable": true, - "expanded": false, - "items": [ - "CloudTransport", - "keepalive", - "refresh", - "filter", - "mergeServiceName", - "blind", - "door" - ] - }, - { - "type": "fieldset", - "title": "Speakers", - "description": "Devices to configure as speakers as HomeKit currently does not have a Speaker service.", - "expandable": true, - "expanded": false, - "items": [ - { - "notitle": true, - "key": "speakers", - "type": "array", - "items": [ - { - "type": "div", - "displayFlex": true, - "flex-direction": "row", - "items": [ - { - "key": "speakers[].manufacturer", - "flex": "1 1 50px", - "notitle": true, - "placeholder": "Manufacturer" - }, - { - "key": "speakers[].name", - "flex": "4 4 200px", - "notitle": true, - "placeholder": "Name" - } - ] - } - ] - } - ] - }, - { - "type": "fieldset", - "title": "Combine Accessories", - "description": "Combine disparate accessories into one common device.", - "expandable": true, - "expanded": false, - "items": [ - { - "notitle": true, - "key": "combine", - "type": "array", - "items": [ - { - "type": "div", - "items": [ - { - "key": "combine[].into", - "title": "Into", - "placeholder": "Target Accessory Name" - }, - { - "key": "combine[].from", - "notitle": true, - "items": [ - { - "title": "From", - "key": "combine[].from[]", - "placeholder": "Source Accessory Name" - } - ] - } - ] - } - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/config.schema.json b/config.schema.json index 039b9c5..9af81d8 100644 --- a/config.schema.json +++ b/config.schema.json @@ -2,7 +2,6 @@ "pluginAlias": "Alexa", "pluginType": "platform", "singular": true, - "customUi": true, "headerDisplay": "

Allow your Amazon Alexa to control your homebridge devices


To setup the service:

1 - First create an account on https://www.homebridge.ca/.
2 - Then enter the username and password for your account below.
3 - Save the settings and restart homebridge.
4 - In the Amazon Alexa Application on your smart phone, search for the Homebridge Skill and enable it. When you enable the skill, it will take you to the https://www.homebridge.ca/ website to enable and link the skill to the plugin.
5 - You can now ask Alexa to `discover devices` and it should discover your homebridge devices.

Detailed setup instructions are available here.
", "footerDisplay": "Homebridge Alexa Skill: https://www.amazon.com/Northern-Man-54-Homebridge/dp/B07B9QMTFQ", "schema": { diff --git a/homebridge-ui/public/index.html b/homebridge-ui/public/index.html deleted file mode 100644 index d021e1a..0000000 --- a/homebridge-ui/public/index.html +++ /dev/null @@ -1,468 +0,0 @@ - - - -
- - - - - - - - -
- - \ No newline at end of file diff --git a/homebridge-ui/server.js b/homebridge-ui/server.js deleted file mode 100644 index 140ae22..0000000 --- a/homebridge-ui/server.js +++ /dev/null @@ -1,89 +0,0 @@ -const axios = require('axios') -const { HomebridgePluginUiServer, RequestError } = require('@homebridge/plugin-ui-utils'); - -class UiServer extends HomebridgePluginUiServer { - constructor() { - super(); - - this.endpointUrl = 'https://app.ecpiot.co.il/mobile/mobilecommand'; - this.imei; - - // create request handlers - this.onRequest('/request-otp', this.requestOtp.bind(this)); - this.onRequest('/check-otp', this.checkOtp.bind(this)); - - // must be called when the script is ready to accept connections - this.ready(); - } - - - /** - * Handle requests sent to /request-otp - */ - async requestOtp(body) { - this.imei = this.generateIMEI(); - - const data = { - 'pvdid': 1, - 'id': 99, - 'cmd': 'SEND_OTP', - 'data': { - 'imei': this.imei, - 'phone': body.phone, - } - } - - try { - const response = await axios.post(this.endpointUrl, data); - return response.data; - } catch (e) { - throw e.response.data; - } - } - - /** - * Handle requests sent to /check-otp - */ - async checkOtp(body) { - const data = { - 'pvdid': 1, - 'id': 99, - 'cmd': 'CHECK_OTP', - 'data': { - 'imei': this.imei, - 'phone': body.phone, - 'code': body.code, - 'os': 'android', - 'osver': 'M4B30Z' - } - } - - let response; - - try { - response = await axios.post(this.endpointUrl, data); - } catch (e) { - throw new RequestError(e.response ? e.response.data : e.message); - } - - if (response.data.data && response.data.data.token) { - return { - imei: this.imei, - token: response.data.data.token, - } - } else { - throw new RequestError(`Could NOT get the token: ${response.data.data ? response.data.data.res_desc : JSON.stringify(response.data)}`); - } - } - - generateIMEI() { - const min = Math.pow(10, 7) - const max = Math.pow(10, 8) - 1 - return '2b950000' + (Math.floor(Math.random() * (max - min) + min) + 1) - } -} - -// start the instance of the class -(() => { - return new UiServer; -})(); \ No newline at end of file