homebridge-tasmota-control 0.3.34 → 0.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/config.schema.json +5 -5
- package/index.js +11 -10
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,6 @@ All notable changes to this project will be documented in this file.
|
|
|
3
3
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
-
## [0.0.1] - (
|
|
6
|
+
## [0.0.1] - (24.12.2021)
|
|
7
7
|
## Changs
|
|
8
8
|
- initial release
|
package/config.schema.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"pluginAlias": "
|
|
2
|
+
"pluginAlias": "tasmotaControl",
|
|
3
3
|
"pluginType": "platform",
|
|
4
4
|
"singular": true,
|
|
5
|
-
"headerDisplay": "This plugin works with Tasmota
|
|
6
|
-
"footerDisplay": "This plugin is available [here](https://github.com/grzegorz914/homebridge-tasmota-
|
|
5
|
+
"headerDisplay": "This plugin works with Tasmota flashed devices and are exposed to HomeKit as separate accessories and each needs to be manually paired.\n\n1. Open the Home <img src='https://user-images.githubusercontent.com/3979615/78010622-4ea1d380-738e-11ea-8a17-e6a465eeec35.png' height='16.42px'> app on your device.\n2. Tap the Home tab, then tap <img src='https://user-images.githubusercontent.com/3979615/78010869-9aed1380-738e-11ea-9644-9f46b3633026.png' height='16.42px'>.\n3. Tap *Add Accessory*, and select *I Don't Have a Code or Cannot Scan*.\n4. Enter the Homebridge PIN, this can be found under the QR code in Homebridge UI or your Homebridge logs, alternatively you can select *Use Camera* and scan the QR code again.",
|
|
6
|
+
"footerDisplay": "This plugin is available [here](https://github.com/grzegorz914/homebridge-tasmota-control).",
|
|
7
7
|
"schema": {
|
|
8
8
|
"type": "object",
|
|
9
9
|
"properties": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"maximum": 60,
|
|
47
47
|
"required": true
|
|
48
48
|
},
|
|
49
|
-
"
|
|
49
|
+
"channelsCount": {
|
|
50
50
|
"title": "Channels count",
|
|
51
51
|
"type": "number",
|
|
52
52
|
"default": 1,
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"items": [
|
|
91
91
|
"devices[].user",
|
|
92
92
|
"devices[].passwd",
|
|
93
|
-
"devices[].
|
|
93
|
+
"devices[].channelsCount",
|
|
94
94
|
"devices[].enableDebugMode",
|
|
95
95
|
"devices[].disableLogInfo",
|
|
96
96
|
"devices[].refreshInterval"
|
package/index.js
CHANGED
|
@@ -10,8 +10,8 @@ const POWER = 'Power';
|
|
|
10
10
|
const ON = '%20on'
|
|
11
11
|
const OFF = '%20off';
|
|
12
12
|
|
|
13
|
-
const PLUGIN_NAME = 'homebridge-tasmota-
|
|
14
|
-
const PLATFORM_NAME = '
|
|
13
|
+
const PLUGIN_NAME = 'homebridge-tasmota-control';
|
|
14
|
+
const PLATFORM_NAME = 'tasmotaControl';
|
|
15
15
|
|
|
16
16
|
let Accessory, Characteristic, Service, Categories, UUID;
|
|
17
17
|
|
|
@@ -71,7 +71,7 @@ class tasmotaDevice {
|
|
|
71
71
|
this.user = config.user;
|
|
72
72
|
this.passwd = config.passwd;
|
|
73
73
|
this.refreshInterval = config.refreshInterval || 5;
|
|
74
|
-
this.
|
|
74
|
+
this.channelsCount = config.channelsCount || 1;
|
|
75
75
|
this.enableDebugMode = config.enableDebugMode || false;
|
|
76
76
|
this.disableLogInfo = config.disableLogInfo || true;
|
|
77
77
|
|
|
@@ -120,6 +120,7 @@ class tasmotaDevice {
|
|
|
120
120
|
const modelName = response.data.StatusFWR.Hardware;
|
|
121
121
|
const addressMac = response.data.StatusNET.Mac;
|
|
122
122
|
const firmwareRevision = response.data.StatusFWR.Version;
|
|
123
|
+
|
|
123
124
|
this.log('-------- %s --------', deviceName);
|
|
124
125
|
this.log('Manufacturer: %s', this.manufacturer);
|
|
125
126
|
this.log('Hardware: %s', modelName);
|
|
@@ -142,8 +143,8 @@ class tasmotaDevice {
|
|
|
142
143
|
async updateDeviceState() {
|
|
143
144
|
this.log.debug('Device: %s %s, requesting Device state.', this.host, this.name);
|
|
144
145
|
try {
|
|
145
|
-
for (let i = 0; i < this.
|
|
146
|
-
const channel = this.
|
|
146
|
+
for (let i = 0; i < this.channelsCount; i++) {
|
|
147
|
+
const channel = this.channelsCount == 1 ? 'POWER' : 'POWER' + i;
|
|
147
148
|
const response = await this.axiosInstance(channel);
|
|
148
149
|
const debug = this.enableDebugMode ? this.log('Device: %s %s, debug response: %s', this.host, this.name, response.data) : false;
|
|
149
150
|
const powerState = (response.data[channel] != undefined) ? (response.data[channel] == 'ON') : false;
|
|
@@ -193,26 +194,26 @@ class tasmotaDevice {
|
|
|
193
194
|
//Prepare service
|
|
194
195
|
this.log.debug('prepareTasmotaService');
|
|
195
196
|
this.tasmotaServices = new Array();
|
|
196
|
-
for (let i = 0; i < this.
|
|
197
|
+
for (let i = 0; i < this.channelsCount; i++) {
|
|
197
198
|
const tasmotaService = new Service.Outlet(accessoryName, `tasmotaService${[i]}`);
|
|
198
199
|
tasmotaService.getCharacteristic(Characteristic.On)
|
|
199
200
|
.onGet(async () => {
|
|
200
|
-
const channel = this.
|
|
201
|
+
const channel = this.channelsCount == 1 ? 'POWER' : 'POWER' + i;
|
|
201
202
|
const response = await this.axiosInstance(channel);
|
|
202
203
|
const state = (response.data[channel] != undefined) ? (response.data[channel] == 'ON') : false;
|
|
203
204
|
const logInfo = this.disableLogInfo ? false : this.log('Device: %s, get state: %s', accessoryName, state ? 'ON' : 'OFF');
|
|
204
205
|
return state;
|
|
205
206
|
})
|
|
206
207
|
.onSet(async (state) => {
|
|
207
|
-
const powerOn = this.
|
|
208
|
-
const powerOff = this.
|
|
208
|
+
const powerOn = this.channelsCount == 1 ? POWER + ON : POWER + (i + 1) + ON;
|
|
209
|
+
const powerOff = this.channelsCount == 1 ? POWER + OFF : POWER + (i + 1) + OFF;
|
|
209
210
|
state = state ? powerOn : powerOff;
|
|
210
211
|
this.axiosInstance(state);
|
|
211
212
|
const logInfo = this.disableLogInfo ? false : this.log('Device: %s, set state: %s', accessoryName, state ? 'ON' : 'OFF');
|
|
212
213
|
});
|
|
213
214
|
tasmotaService.getCharacteristic(Characteristic.OutletInUse)
|
|
214
215
|
.onGet(async () => {
|
|
215
|
-
const channel = this.
|
|
216
|
+
const channel = this.channelsCount == 1 ? 'POWER' : 'POWER' + i;
|
|
216
217
|
const response = await this.axiosInstance(channel);
|
|
217
218
|
const state = (response.data[channel] != undefined) ? (response.data[channel] == 'ON') : false;
|
|
218
219
|
const logInfo = this.disableLogInfo ? false : this.log('Device: %s, in use: %s', accessoryName, state ? 'YES' : 'NO');
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Tasmota Control",
|
|
3
3
|
"name": "homebridge-tasmota-control",
|
|
4
|
-
"version": "0.3.
|
|
5
|
-
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Tasmota
|
|
4
|
+
"version": "0.3.35",
|
|
5
|
+
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Tasmota flashed devices.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
8
|
-
"homepage": "https://github.com/grzegorz914/homebridge-tasmota-
|
|
8
|
+
"homepage": "https://github.com/grzegorz914/homebridge-tasmota-control#readme",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/grzegorz914/homebridge-tasmota-
|
|
11
|
+
"url": "git+https://github.com/grzegorz914/homebridge-tasmota-control.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/grzegorz914/homebridge-tasmota-
|
|
14
|
+
"url": "https://github.com/grzegorz914/homebridge-tasmota-control/issues"
|
|
15
15
|
},
|
|
16
16
|
"funding": {
|
|
17
17
|
"type": "paypal",
|