homebridge-tasmota-control 0.4.6 → 0.4.10

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 CHANGED
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
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
6
 
7
+ ## [0.4.10] - (23.08.2022)
8
+ ## Changes
9
+ - added possibility to display log device info on every restart
10
+ - config schema updated
11
+
12
+ ## [0.4.7] - (23.08.2022)
13
+ ## Changes
14
+ - added display channel name instead device name
15
+
7
16
  ## [0.4.6] - (12.08.2022)
8
17
  ## Changes
9
18
  - finally fixed report wrong device state [#4](https://github.com/grzegorz914/homebridge-tasmota-control/issues/4)
package/README.md CHANGED
@@ -29,7 +29,7 @@ Homebridge plugin for Tasmota flashed devices.
29
29
 
30
30
  ## Troubleshooting
31
31
  * If for some reason the device is not displayed in HomeKit app try this procedure:
32
- * Go to `./homebridge/persist` or `/var/lib/homebridge/persist` for RPI.
32
+ * Go to `./homebridge/persist` macOS or `/var/lib/homebridge/persist` for RPI.
33
33
  * Remove `AccessoryInfo.xxx` file which contain Your device data: `{"displayName":"Tasmota"}`.
34
34
  * Next remove `IdentifierCashe.xxx` file with same name as `AccessoryInfo.xxx`.
35
35
  * Restart Homebridge and try add it to the Home app again.
@@ -52,6 +52,7 @@ Homebridge plugin for Tasmota flashed devices.
52
52
  | `passwd` | Here set the authorization *Password*. |
53
53
  | `enableDebugMode` | This enable deep log in homebridge console. |
54
54
  | `disableLogInfo` | This disable log info, all values and state will not be displayed in Homebridge log console. |
55
+ | `disableLogDeviceInfo` | If enabled, add ability to disable log device info by every connections device to the network. |
55
56
 
56
57
  ```json
57
58
  {
@@ -65,20 +66,21 @@ Homebridge plugin for Tasmota flashed devices.
65
66
  "passwd": "password",
66
67
  "refreshInterval": 5,
67
68
  "disableLogInfo": false,
68
- "enableDebugMode": false,
69
+ "disableLogDeviceInfo": false,
70
+ "enableDebugMode": false
69
71
  }
70
72
  ]
71
73
  }
72
74
  ```
73
75
 
74
76
  ### Adding to HomeKit
75
- Each accessory needs to be manually paired.
76
- 1. Open the Home <img src='https://user-images.githubusercontent.com/3979615/78010622-4ea1d380-738e-11ea-8a17-e6a465eeec35.png' width='16.42px'> app on your device.
77
- 2. Tap the Home tab, then tap <img src='https://user-images.githubusercontent.com/3979615/78010869-9aed1380-738e-11ea-9644-9f46b3633026.png' width='16.42px'>.
78
- 3. Tap *Add Accessory*, and select *I Don't Have a Code, Cannot Scan* or *More options*.
79
- 4. Select Your accessory and press add anyway.
80
- 5. Enter the PIN or scan the QR code, this can be found in Homebridge UI or Homebridge logs.
81
- 6. Complete the accessory setup.
77
+ * Each accessory needs to be manually paired.
78
+ * Open the Home <img src='https://user-images.githubusercontent.com/3979615/78010622-4ea1d380-738e-11ea-8a17-e6a465eeec35.png' width='16.42px'> app on your device.
79
+ * Tap the Home tab, then tap <img src='https://user-images.githubusercontent.com/3979615/78010869-9aed1380-738e-11ea-9644-9f46b3633026.png' width='16.42px'>.
80
+ * Tap *Add Accessory*, and select *I Don't Have a Code, Cannot Scan* or *More options*.
81
+ * Select Your accessory and press add anyway.
82
+ * Enter the PIN or scan the QR code, this can be found in Homebridge UI or Homebridge logs.
83
+ * Complete the accessory setup.
82
84
 
83
85
  ## [What's New](https://github.com/grzegorz914/homebridge-tasmota-control/main/master/CHANGELOG.md).
84
86
 
@@ -3,7 +3,7 @@
3
3
  "pluginType": "platform",
4
4
  "singular": true,
5
5
  "headerDisplay": "This plugin works with deevices flashed with Tasmota firmware. Devices 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 <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* or *More Options*.\n4. Select Your accessory and press add anyway.\n5. Enter the PIN or scan the QR code, this can be found in Homebridge UI or Homebridge logs.\n6. Complete the accessory setup.",
6
- "footerDisplay": "For documentation please see [GitHub repository](https://github.com/grzegorz914/homebridge-tasmota-control).",
6
+ "footerDisplay": "For documentation please see [GitHub repository](https://github.com/grzegorz914/homebridge-tasmota-control).",
7
7
  "schema": {
8
8
  "type": "object",
9
9
  "properties": {
@@ -20,7 +20,7 @@
20
20
  "required": true
21
21
  },
22
22
  "host": {
23
- "title": "IP Address",
23
+ "title": "IP address",
24
24
  "type": "string",
25
25
  "default": "192.168.1.61",
26
26
  "required": true,
@@ -53,7 +53,7 @@
53
53
  "required": true
54
54
  },
55
55
  "enableDebugMode": {
56
- "title": "Enable Debug Mode",
56
+ "title": "Enable debug mode",
57
57
  "type": "boolean",
58
58
  "default": false,
59
59
  "description": "This enable debug mode.",
@@ -65,46 +65,56 @@
65
65
  "default": false,
66
66
  "description": "This disable log info, all values and state will not be displayed in Homebridge log console.",
67
67
  "required": false
68
+ },
69
+ "disableLogDeviceInfo": {
70
+ "title": "Disable log device info",
71
+ "type": "boolean",
72
+ "default": false,
73
+ "description": "This disable log device info by every connections device to the network.",
74
+ "required": false
68
75
  }
69
76
  }
70
77
  }
71
78
  }
72
79
  }
73
80
  },
74
- "layout": [{
75
- "key": "devices",
76
- "type": "tabarray",
77
- "title": "{{ value.name || 'new device' }}",
78
- "items": [
79
- "devices[].name",
80
- "devices[].host",
81
- "devices[].auth",
82
- {
83
- "key": "devices[]",
84
- "type": "section",
85
- "title": "Authorization",
86
- "expandable": true,
87
- "expanded": false,
88
- "items": [
89
- "devices[].user",
90
- "devices[].passwd"
91
- ],
92
- "condition": {
93
- "functionBody": "return model.devices[arrayIndices].auth === true;"
81
+ "layout": [
82
+ {
83
+ "key": "devices",
84
+ "type": "tabarray",
85
+ "title": "{{ value.name || 'new device' }}",
86
+ "items": [
87
+ "devices[].name",
88
+ "devices[].host",
89
+ "devices[].auth",
90
+ {
91
+ "key": "devices[]",
92
+ "type": "section",
93
+ "title": "Authorization",
94
+ "expandable": true,
95
+ "expanded": false,
96
+ "items": [
97
+ "devices[].user",
98
+ "devices[].passwd"
99
+ ],
100
+ "condition": {
101
+ "functionBody": "return model.devices[arrayIndices].auth === true;"
102
+ }
103
+ },
104
+ {
105
+ "key": "devices[]",
106
+ "type": "section",
107
+ "title": "Advanced Settings",
108
+ "expandable": true,
109
+ "expanded": false,
110
+ "items": [
111
+ "devices[].enableDebugMode",
112
+ "devices[].disableLogInfo",
113
+ "devices[].disableLogDeviceInfo",
114
+ "devices[].refreshInterval"
115
+ ]
94
116
  }
95
- },
96
- {
97
- "key": "devices[]",
98
- "type": "section",
99
- "title": "Advanced Settings",
100
- "expandable": true,
101
- "expanded": false,
102
- "items": [
103
- "devices[].enableDebugMode",
104
- "devices[].disableLogInfo",
105
- "devices[].refreshInterval"
106
- ]
107
- }
108
- ]
109
- }]
117
+ ]
118
+ }
119
+ ]
110
120
  }
package/index.js CHANGED
@@ -33,13 +33,13 @@ class tasmotaPlatform {
33
33
  constructor(log, config, api) {
34
34
  // only load if configured
35
35
  if (!config || !Array.isArray(config.devices)) {
36
- log(`No configuration found for ${deviceName}.`, PLUGIN_NAME);
36
+ log(`No configuration found for ${PLUGIN_NAME}.`);
37
37
  return;
38
38
  };
39
39
 
40
40
  this.log = log;
41
41
  this.api = api;
42
- this.devices = config.devices || [];
42
+ this.devices = config.devices;
43
43
  this.accessories = [];
44
44
 
45
45
  this.api.on('didFinishLaunching', () => {
@@ -80,6 +80,7 @@ class tasmotaDevice {
80
80
  this.refreshInterval = config.refreshInterval || 5;
81
81
  this.enableDebugMode = config.enableDebugMode || false;
82
82
  this.disableLogInfo = config.disableLogInfo || false;
83
+ this.disableLogDeviceInfo = config.disableLogDeviceInfo || false;
83
84
 
84
85
  //get Device info
85
86
  this.manufacturer = 'Tasmota';
@@ -127,23 +128,27 @@ class tasmotaDevice {
127
128
  const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, debug device info: ${JSON.stringify(deviceInfo.data, null, 2)}`) : false;
128
129
 
129
130
  const deviceName = deviceInfo.data.Status.DeviceName;
131
+ const friendlyName = Array.isArray(deviceInfo.data.Status.FriendlyName) ? deviceInfo.data.Status.FriendlyName : [];
132
+ const friendlyNameCount = friendlyName.length;
130
133
  const modelName = deviceInfo.data.StatusFWR.Hardware;
131
134
  const addressMac = deviceInfo.data.StatusNET.Mac;
132
135
  const firmwareRevision = deviceInfo.data.StatusFWR.Version;
133
- const channelsCount = deviceInfo.data.Status.FriendlyName.length;
134
136
 
135
- this.log(`----- ${deviceName} -----`);
136
- this.log(`Manufacturer: ${this.manufacturer}`);
137
- this.log(`Hardware: ${modelName}`);
138
- this.log(`Serialnr: ${addressMac}`);
139
- this.log(`Firmware: ${firmwareRevision}`);
140
- this.log(`Channels: ${channelsCount}`);
141
- this.log(`----------------------------------`);
137
+ if (!this.disableLogDeviceInfo) {
138
+ this.log(`----- ${this.name} -----`);
139
+ this.log(`Manufacturer: ${this.manufacturer}`);
140
+ this.log(`Hardware: ${modelName}`);
141
+ this.log(`Serialnr: ${addressMac}`);
142
+ this.log(`Firmware: ${firmwareRevision}`);
143
+ this.log(`Channels: ${friendlyNameCount}`);
144
+ this.log(`----------------------------------`);
145
+ };
142
146
 
143
147
  this.modelName = modelName;
144
148
  this.serialNumber = addressMac;
145
149
  this.firmwareRevision = firmwareRevision;
146
- this.channelsCount = channelsCount;
150
+ this.friendlyName = friendlyName;
151
+ this.channelsCount = friendlyNameCount;
147
152
 
148
153
  this.checkDeviceState();
149
154
  } catch (error) {
@@ -155,22 +160,26 @@ class tasmotaDevice {
155
160
  async checkDeviceState() {
156
161
  this.log.debug(`Device: ${this.host} ${this.name}, requesting state.`, this.host, this.name);
157
162
  try {
163
+ const friendlyName = this.friendlyName;
158
164
  const channelsCount = this.channelsCount;
159
165
  const deviceState = await this.axiosInstance(API_COMMANDS.PowerStatus);
160
166
  const debug = this.enableDebugMode ? this.log(`Device: ${this.host} ${this.name}, debug state: ${JSON.stringify(deviceState.data, null, 2)}`) : false;
161
167
 
162
168
  this.powerState = new Array();
169
+ this.names = new Array();
163
170
  for (let i = 0; i < channelsCount; i++) {
164
171
  const power = channelsCount == 1 ? 'POWER' : 'POWER' + (i + 1);
165
172
  const power1 = channelsCount == 1 ? 'POWER1' : 'POWER' + (i + 1);
166
173
  const powerState = (deviceState.data[power] != undefined) ? (deviceState.data[power] == 'ON') : (deviceState.data[power1] == 'ON');
174
+ const name = friendlyName[i];
175
+
176
+ this.powerState.push(powerState);
177
+ this.names.push(name);
167
178
 
168
179
  if (this.tasmotaServices) {
169
180
  this.tasmotaServices[i]
170
181
  .updateCharacteristic(Characteristic.On, powerState);
171
182
  };
172
-
173
- this.powerState.push(powerState);
174
183
  };
175
184
 
176
185
  this.updateDeviceState();
@@ -209,13 +218,16 @@ class tasmotaDevice {
209
218
  //Prepare service
210
219
  this.log.debug('prepareTasmotaService');
211
220
  this.tasmotaServices = new Array();
212
- const channelsCount = this.channelsCount;
221
+ const channelsName = this.names;
222
+ const channelsCount = this.channelsCount;;
213
223
  for (let i = 0; i < channelsCount; i++) {
214
- const tasmotaService = new Service.Outlet(accessoryName, `tasmotaService${[i]}`);
224
+ const serviceName = (channelsCount > 1) ? `${accessoryName} ${channelsName[i]}` : accessoryName;
225
+ const logName = (channelsCount > 1) ? `${accessoryName}, channel: ${channelsName[i]}` : `${accessoryName}`
226
+ const tasmotaService = new Service.Outlet(serviceName, `tasmotaService${[i]}`);
215
227
  tasmotaService.getCharacteristic(Characteristic.On)
216
228
  .onGet(async () => {
217
229
  const state = this.powerState[i];
218
- const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, state: ${state ? 'ON' : 'OFF'}`);
230
+ const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${logName}, state: ${state ? 'ON' : 'OFF'}`);
219
231
  return state;
220
232
  })
221
233
  .onSet(async (state) => {
@@ -224,9 +236,9 @@ class tasmotaDevice {
224
236
  state = state ? powerOn : powerOff;
225
237
  try {
226
238
  await this.axiosInstance(state);
227
- const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${accessoryName}, set state: ${state ? 'ON' : 'OFF'}`);
239
+ const logInfo = this.disableLogInfo ? false : this.log(`Device: ${this.host} ${logName}, set state: ${state ? 'ON' : 'OFF'}`);
228
240
  } catch (error) {
229
- this.log.error(`Device: ${this.host} ${accessoryName}, set state error: ${error}`);
241
+ this.log.error(`Device: ${this.host} ${logName}, set state error: ${error}`);
230
242
  }
231
243
  });
232
244
  this.tasmotaServices.push(tasmotaService);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Tasmota Control",
3
3
  "name": "homebridge-tasmota-control",
4
- "version": "0.4.6",
4
+ "version": "0.4.10",
5
5
  "description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Tasmota flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",