homebridge-tasmota-control 0.3.39 → 0.3.42
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 +5 -1
- package/config.schema.json +2 -2
- package/index.js +21 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,11 @@ 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.3.
|
|
6
|
+
## [0.3.41] - (25.12.2021)
|
|
7
|
+
## Changs
|
|
8
|
+
- catch error in happened on set state
|
|
9
|
+
|
|
10
|
+
## [0.3.39] - (25.12.2021)
|
|
7
11
|
## Changs
|
|
8
12
|
- update config.schema
|
|
9
13
|
|
package/config.schema.json
CHANGED
|
@@ -120,8 +120,8 @@
|
|
|
120
120
|
"title": "Disable log info",
|
|
121
121
|
"type": "boolean",
|
|
122
122
|
"default": false,
|
|
123
|
-
"
|
|
124
|
-
"
|
|
123
|
+
"description": "This disable log info, all values and state will not be displayed in Homebridge log console.",
|
|
124
|
+
"required": false
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
package/index.js
CHANGED
|
@@ -5,11 +5,16 @@ const axios = require('axios');
|
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const fsPromises = require('fs').promises;
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const API_COMMANDS = {
|
|
9
|
+
Status: 'Status0',
|
|
10
|
+
PowerStatus: 'Power0', //0,1,2 - Power all
|
|
11
|
+
Power: 'Power',
|
|
12
|
+
Off: '%20off', //0
|
|
13
|
+
On: '%20on', //1
|
|
14
|
+
Toggle: '%20toggle', //2
|
|
15
|
+
Blink: '%20blink', //3
|
|
16
|
+
BlinkOff: '%20blinkoff' //4
|
|
17
|
+
}
|
|
13
18
|
|
|
14
19
|
const PLUGIN_NAME = 'homebridge-tasmota-control';
|
|
15
20
|
const PLATFORM_NAME = 'tasmotaControl';
|
|
@@ -115,7 +120,7 @@ class tasmotaDevice {
|
|
|
115
120
|
async getDeviceInfo() {
|
|
116
121
|
this.log.debug('Device: %s %s, requesting Device Info.', this.host, this.name);
|
|
117
122
|
try {
|
|
118
|
-
const response = await this.axiosInstance(
|
|
123
|
+
const response = await this.axiosInstance(API_COMMANDS.Status);
|
|
119
124
|
const debug = this.enableDebugMode ? this.log('Device: %s %s, debug response: %s', this.host, this.name, response.data) : false;
|
|
120
125
|
|
|
121
126
|
const deviceName = response.data.Status.DeviceName;
|
|
@@ -137,14 +142,13 @@ class tasmotaDevice {
|
|
|
137
142
|
this.checkDeviceInfo = false;
|
|
138
143
|
} catch (error) {
|
|
139
144
|
this.log.error('Device: %s %s, Device Info eror: %s, state: Offline, trying to reconnect', this.host, this.name, error);
|
|
140
|
-
this.checkDeviceInfo = true;
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
async updateDeviceState() {
|
|
145
149
|
this.log.debug('Device: %s %s, requesting Device state.', this.host, this.name);
|
|
146
150
|
try {
|
|
147
|
-
const response = await this.axiosInstance(
|
|
151
|
+
const response = await this.axiosInstance(API_COMMANDS.PowerStatus);
|
|
148
152
|
const debug = this.enableDebugMode ? this.log('Device: %s %s, debug response: %s', this.host, this.name, response.data) : false;
|
|
149
153
|
|
|
150
154
|
this.powerState = new Array();
|
|
@@ -160,6 +164,7 @@ class tasmotaDevice {
|
|
|
160
164
|
}
|
|
161
165
|
this.checkDeviceState = true;
|
|
162
166
|
|
|
167
|
+
//start prepare accessory
|
|
163
168
|
if (this.startPrepareAccessory) {
|
|
164
169
|
this.prepareAccessory();
|
|
165
170
|
}
|
|
@@ -207,11 +212,15 @@ class tasmotaDevice {
|
|
|
207
212
|
return state;
|
|
208
213
|
})
|
|
209
214
|
.onSet(async (state) => {
|
|
210
|
-
const powerOn = this.channelsCount == 1 ?
|
|
211
|
-
const powerOff = this.channelsCount == 1 ?
|
|
215
|
+
const powerOn = this.channelsCount == 1 ? API_COMMANDS.Power + API_COMMANDS.On : API_COMMANDS.Power + (i + 1) + API_COMMANDS.On;
|
|
216
|
+
const powerOff = this.channelsCount == 1 ? API_COMMANDS.Power + API_COMMANDS.Off : API_COMMANDS.Power + (i + 1) + API_COMMANDS.Off;
|
|
212
217
|
state = state ? powerOn : powerOff;
|
|
213
|
-
|
|
214
|
-
|
|
218
|
+
try {
|
|
219
|
+
await this.axiosInstance(state);
|
|
220
|
+
const logInfo = this.disableLogInfo ? false : this.log('Device: %s %s, set state: %s', this.host, accessoryName, state ? 'ON' : 'OFF');
|
|
221
|
+
} catch (error) {
|
|
222
|
+
this.log.error('Device: %s %s, set state: %s', this.host, this.name, error);
|
|
223
|
+
}
|
|
215
224
|
});
|
|
216
225
|
tasmotaService.getCharacteristic(Characteristic.OutletInUse)
|
|
217
226
|
.onGet(async () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Tasmota Control",
|
|
3
3
|
"name": "homebridge-tasmota-control",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.42",
|
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Tasmota flashed devices.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|