matterbridge 3.2.4-dev-20250830-5c48452 → 3.2.4
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/dist/cli.d.ts +26 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +91 -2
- package/dist/cli.js.map +1 -0
- package/dist/cliEmitter.d.ts +34 -0
- package/dist/cliEmitter.d.ts.map +1 -0
- package/dist/cliEmitter.js +30 -0
- package/dist/cliEmitter.js.map +1 -0
- package/dist/clusters/export.d.ts +2 -0
- package/dist/clusters/export.d.ts.map +1 -0
- package/dist/clusters/export.js +2 -0
- package/dist/clusters/export.js.map +1 -0
- package/dist/defaultConfigSchema.d.ts +28 -0
- package/dist/defaultConfigSchema.d.ts.map +1 -0
- package/dist/defaultConfigSchema.js +24 -0
- package/dist/defaultConfigSchema.js.map +1 -0
- package/dist/deviceManager.d.ts +112 -0
- package/dist/deviceManager.d.ts.map +1 -0
- package/dist/deviceManager.js +94 -1
- package/dist/deviceManager.js.map +1 -0
- package/dist/devices/batteryStorage.d.ts +48 -0
- package/dist/devices/batteryStorage.d.ts.map +1 -0
- package/dist/devices/batteryStorage.js +48 -1
- package/dist/devices/batteryStorage.js.map +1 -0
- package/dist/devices/cooktop.d.ts +60 -0
- package/dist/devices/cooktop.d.ts.map +1 -0
- package/dist/devices/cooktop.js +55 -0
- package/dist/devices/cooktop.js.map +1 -0
- package/dist/devices/dishwasher.d.ts +71 -0
- package/dist/devices/dishwasher.d.ts.map +1 -0
- package/dist/devices/dishwasher.js +57 -0
- package/dist/devices/dishwasher.js.map +1 -0
- package/dist/devices/evse.d.ts +75 -0
- package/dist/devices/evse.d.ts.map +1 -0
- package/dist/devices/evse.js +74 -10
- package/dist/devices/evse.js.map +1 -0
- package/dist/devices/export.d.ts +15 -0
- package/dist/devices/export.d.ts.map +1 -0
- package/dist/devices/export.js +4 -0
- package/dist/devices/export.js.map +1 -0
- package/dist/devices/extractorHood.d.ts +46 -0
- package/dist/devices/extractorHood.d.ts.map +1 -0
- package/dist/devices/extractorHood.js +42 -0
- package/dist/devices/extractorHood.js.map +1 -0
- package/dist/devices/heatPump.d.ts +47 -0
- package/dist/devices/heatPump.d.ts.map +1 -0
- package/dist/devices/heatPump.js +50 -2
- package/dist/devices/heatPump.js.map +1 -0
- package/dist/devices/laundryDryer.d.ts +67 -0
- package/dist/devices/laundryDryer.d.ts.map +1 -0
- package/dist/devices/laundryDryer.js +62 -3
- package/dist/devices/laundryDryer.js.map +1 -0
- package/dist/devices/laundryWasher.d.ts +81 -0
- package/dist/devices/laundryWasher.d.ts.map +1 -0
- package/dist/devices/laundryWasher.js +70 -4
- package/dist/devices/laundryWasher.js.map +1 -0
- package/dist/devices/microwaveOven.d.ts +168 -0
- package/dist/devices/microwaveOven.d.ts.map +1 -0
- package/dist/devices/microwaveOven.js +88 -5
- package/dist/devices/microwaveOven.js.map +1 -0
- package/dist/devices/oven.d.ts +105 -0
- package/dist/devices/oven.d.ts.map +1 -0
- package/dist/devices/oven.js +85 -0
- package/dist/devices/oven.js.map +1 -0
- package/dist/devices/refrigerator.d.ts +93 -0
- package/dist/devices/refrigerator.d.ts.map +1 -0
- package/dist/devices/refrigerator.js +80 -0
- package/dist/devices/refrigerator.js.map +1 -0
- package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
- package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
- package/dist/devices/roboticVacuumCleaner.js +93 -7
- package/dist/devices/roboticVacuumCleaner.js.map +1 -0
- package/dist/devices/solarPower.d.ts +40 -0
- package/dist/devices/solarPower.d.ts.map +1 -0
- package/dist/devices/solarPower.js +38 -0
- package/dist/devices/solarPower.js.map +1 -0
- package/dist/devices/temperatureControl.d.ts +166 -0
- package/dist/devices/temperatureControl.d.ts.map +1 -0
- package/dist/devices/temperatureControl.js +25 -3
- package/dist/devices/temperatureControl.js.map +1 -0
- package/dist/devices/waterHeater.d.ts +111 -0
- package/dist/devices/waterHeater.d.ts.map +1 -0
- package/dist/devices/waterHeater.js +82 -2
- package/dist/devices/waterHeater.js.map +1 -0
- package/dist/dgram/coap.d.ts +205 -0
- package/dist/dgram/coap.d.ts.map +1 -0
- package/dist/dgram/coap.js +126 -13
- package/dist/dgram/coap.js.map +1 -0
- package/dist/dgram/dgram.d.ts +140 -0
- package/dist/dgram/dgram.d.ts.map +1 -0
- package/dist/dgram/dgram.js +113 -2
- package/dist/dgram/dgram.js.map +1 -0
- package/dist/dgram/mb_coap.d.ts +24 -0
- package/dist/dgram/mb_coap.d.ts.map +1 -0
- package/dist/dgram/mb_coap.js +41 -3
- package/dist/dgram/mb_coap.js.map +1 -0
- package/dist/dgram/mb_mdns.d.ts +24 -0
- package/dist/dgram/mb_mdns.d.ts.map +1 -0
- package/dist/dgram/mb_mdns.js +51 -13
- package/dist/dgram/mb_mdns.js.map +1 -0
- package/dist/dgram/mdns.d.ts +288 -0
- package/dist/dgram/mdns.d.ts.map +1 -0
- package/dist/dgram/mdns.js +298 -137
- package/dist/dgram/mdns.js.map +1 -0
- package/dist/dgram/multicast.d.ts +65 -0
- package/dist/dgram/multicast.d.ts.map +1 -0
- package/dist/dgram/multicast.js +60 -1
- package/dist/dgram/multicast.js.map +1 -0
- package/dist/dgram/unicast.d.ts +56 -0
- package/dist/dgram/unicast.d.ts.map +1 -0
- package/dist/dgram/unicast.js +54 -0
- package/dist/dgram/unicast.js.map +1 -0
- package/dist/frontend.d.ts +313 -0
- package/dist/frontend.d.ts.map +1 -0
- package/dist/frontend.js +451 -24
- package/dist/frontend.js.map +1 -0
- package/dist/globalMatterbridge.d.ts +59 -0
- package/dist/globalMatterbridge.d.ts.map +1 -0
- package/dist/globalMatterbridge.js +47 -0
- package/dist/globalMatterbridge.js.map +1 -0
- package/dist/helpers.d.ts +48 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +53 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -0
- package/dist/logger/export.d.ts +2 -0
- package/dist/logger/export.d.ts.map +1 -0
- package/dist/logger/export.js +1 -0
- package/dist/logger/export.js.map +1 -0
- package/dist/matter/behaviors.d.ts +2 -0
- package/dist/matter/behaviors.d.ts.map +1 -0
- package/dist/matter/behaviors.js +2 -0
- package/dist/matter/behaviors.js.map +1 -0
- package/dist/matter/clusters.d.ts +2 -0
- package/dist/matter/clusters.d.ts.map +1 -0
- package/dist/matter/clusters.js +2 -0
- package/dist/matter/clusters.js.map +1 -0
- package/dist/matter/devices.d.ts +2 -0
- package/dist/matter/devices.d.ts.map +1 -0
- package/dist/matter/devices.js +2 -0
- package/dist/matter/devices.js.map +1 -0
- package/dist/matter/endpoints.d.ts +2 -0
- package/dist/matter/endpoints.d.ts.map +1 -0
- package/dist/matter/endpoints.js +2 -0
- package/dist/matter/endpoints.js.map +1 -0
- package/dist/matter/export.d.ts +5 -0
- package/dist/matter/export.d.ts.map +1 -0
- package/dist/matter/export.js +3 -0
- package/dist/matter/export.js.map +1 -0
- package/dist/matter/types.d.ts +3 -0
- package/dist/matter/types.d.ts.map +1 -0
- package/dist/matter/types.js +3 -0
- package/dist/matter/types.js.map +1 -0
- package/dist/matterbridge.d.ts +462 -0
- package/dist/matterbridge.d.ts.map +1 -0
- package/dist/matterbridge.js +789 -50
- package/dist/matterbridge.js.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
- package/dist/matterbridgeAccessoryPlatform.js +36 -0
- package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
- package/dist/matterbridgeBehaviors.d.ts +1351 -0
- package/dist/matterbridgeBehaviors.d.ts.map +1 -0
- package/dist/matterbridgeBehaviors.js +65 -5
- package/dist/matterbridgeBehaviors.js.map +1 -0
- package/dist/matterbridgeDeviceTypes.d.ts +709 -0
- package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
- package/dist/matterbridgeDeviceTypes.js +579 -15
- package/dist/matterbridgeDeviceTypes.js.map +1 -0
- package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
- package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
- package/dist/matterbridgeDynamicPlatform.js +36 -0
- package/dist/matterbridgeDynamicPlatform.js.map +1 -0
- package/dist/matterbridgeEndpoint.d.ts +1356 -0
- package/dist/matterbridgeEndpoint.d.ts.map +1 -0
- package/dist/matterbridgeEndpoint.js +1220 -54
- package/dist/matterbridgeEndpoint.js.map +1 -0
- package/dist/matterbridgeEndpointHelpers.d.ts +407 -0
- package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
- package/dist/matterbridgeEndpointHelpers.js +345 -12
- package/dist/matterbridgeEndpointHelpers.js.map +1 -0
- package/dist/matterbridgePlatform.d.ts +331 -0
- package/dist/matterbridgePlatform.d.ts.map +1 -0
- package/dist/matterbridgePlatform.js +256 -0
- package/dist/matterbridgePlatform.js.map +1 -0
- package/dist/matterbridgeTypes.d.ts +198 -0
- package/dist/matterbridgeTypes.d.ts.map +1 -0
- package/dist/matterbridgeTypes.js +25 -0
- package/dist/matterbridgeTypes.js.map +1 -0
- package/dist/pluginManager.d.ts +270 -0
- package/dist/pluginManager.d.ts.map +1 -0
- package/dist/pluginManager.js +249 -3
- package/dist/pluginManager.js.map +1 -0
- package/dist/shelly.d.ts +174 -0
- package/dist/shelly.d.ts.map +1 -0
- package/dist/shelly.js +168 -7
- package/dist/shelly.js.map +1 -0
- package/dist/storage/export.d.ts +2 -0
- package/dist/storage/export.d.ts.map +1 -0
- package/dist/storage/export.js +1 -0
- package/dist/storage/export.js.map +1 -0
- package/dist/update.d.ts +75 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +69 -0
- package/dist/update.js.map +1 -0
- package/dist/utils/colorUtils.d.ts +99 -0
- package/dist/utils/colorUtils.d.ts.map +1 -0
- package/dist/utils/colorUtils.js +97 -2
- package/dist/utils/colorUtils.js.map +1 -0
- package/dist/utils/commandLine.d.ts +59 -0
- package/dist/utils/commandLine.d.ts.map +1 -0
- package/dist/utils/commandLine.js +54 -0
- package/dist/utils/commandLine.js.map +1 -0
- package/dist/utils/copyDirectory.d.ts +33 -0
- package/dist/utils/copyDirectory.d.ts.map +1 -0
- package/dist/utils/copyDirectory.js +38 -1
- package/dist/utils/copyDirectory.js.map +1 -0
- package/dist/utils/createDirectory.d.ts +34 -0
- package/dist/utils/createDirectory.d.ts.map +1 -0
- package/dist/utils/createDirectory.js +33 -0
- package/dist/utils/createDirectory.js.map +1 -0
- package/dist/utils/createZip.d.ts +39 -0
- package/dist/utils/createZip.d.ts.map +1 -0
- package/dist/utils/createZip.js +47 -2
- package/dist/utils/createZip.js.map +1 -0
- package/dist/utils/deepCopy.d.ts +32 -0
- package/dist/utils/deepCopy.d.ts.map +1 -0
- package/dist/utils/deepCopy.js +39 -0
- package/dist/utils/deepCopy.js.map +1 -0
- package/dist/utils/deepEqual.d.ts +54 -0
- package/dist/utils/deepEqual.d.ts.map +1 -0
- package/dist/utils/deepEqual.js +72 -1
- package/dist/utils/deepEqual.js.map +1 -0
- package/dist/utils/error.d.ts +44 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +41 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/export.d.ts +12 -0
- package/dist/utils/export.d.ts.map +1 -0
- package/dist/utils/export.js +1 -0
- package/dist/utils/export.js.map +1 -0
- package/dist/utils/hex.d.ts +89 -0
- package/dist/utils/hex.d.ts.map +1 -0
- package/dist/utils/hex.js +124 -0
- package/dist/utils/hex.js.map +1 -0
- package/dist/utils/isvalid.d.ts +103 -0
- package/dist/utils/isvalid.d.ts.map +1 -0
- package/dist/utils/isvalid.js +101 -0
- package/dist/utils/isvalid.js.map +1 -0
- package/dist/utils/network.d.ts +84 -0
- package/dist/utils/network.d.ts.map +1 -0
- package/dist/utils/network.js +91 -5
- package/dist/utils/network.js.map +1 -0
- package/dist/utils/spawn.d.ts +33 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +40 -0
- package/dist/utils/spawn.js.map +1 -0
- package/dist/utils/wait.d.ts +54 -0
- package/dist/utils/wait.d.ts.map +1 -0
- package/dist/utils/wait.js +60 -8
- package/dist/utils/wait.js.map +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -1
package/dist/shelly.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the shelly api functions.
|
|
3
|
+
*
|
|
4
|
+
* @file shelly.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-02-19
|
|
7
|
+
* @version 1.1.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
import { Matterbridge } from './matterbridge.js';
|
|
25
|
+
/**
|
|
26
|
+
* Sets the interval for verification in seconds.
|
|
27
|
+
*
|
|
28
|
+
* @param {number} seconds - The interval in seconds.
|
|
29
|
+
* @returns {void}
|
|
30
|
+
*/
|
|
31
|
+
export declare function setVerifyIntervalSecs(seconds: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the timeout for verification in seconds.
|
|
34
|
+
*
|
|
35
|
+
* @param {number} seconds - The timeout in seconds.
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
export declare function setVerifyTimeoutSecs(seconds: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Fetches Shelly system updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
|
|
41
|
+
*
|
|
42
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
43
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getShellySysUpdate(matterbridge: Matterbridge): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Triggers Shelly system updates.
|
|
48
|
+
*
|
|
49
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
50
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
51
|
+
*/
|
|
52
|
+
export declare function triggerShellySysUpdate(matterbridge: Matterbridge): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Fetches Shelly main updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
|
|
55
|
+
*
|
|
56
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
57
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getShellyMainUpdate(matterbridge: Matterbridge): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Triggers Shelly main updates.
|
|
62
|
+
*
|
|
63
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
64
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
65
|
+
*/
|
|
66
|
+
export declare function triggerShellyMainUpdate(matterbridge: Matterbridge): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Verifies Shelly update.
|
|
69
|
+
*
|
|
70
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
71
|
+
* @param {string} api - The api to call: /api/updates/sys/status or /api/updates/main/status
|
|
72
|
+
* @param {string} name - The name of the update.
|
|
73
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
74
|
+
*/
|
|
75
|
+
export declare function verifyShellyUpdate(matterbridge: Matterbridge, api: string, name: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Triggers Shelly change network configuration.
|
|
78
|
+
*
|
|
79
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
80
|
+
* @param {object} config - The network configuration.
|
|
81
|
+
* @param {string} config.type - The type of network configuration, either 'static' or 'dhcp'.
|
|
82
|
+
* @param {string} config.ip - The IP address to set (required for static configuration).
|
|
83
|
+
* @param {string} config.subnet - The subnet mask to set (required for static configuration).
|
|
84
|
+
* @param {string} config.gateway - The gateway to set (required for static configuration).
|
|
85
|
+
* @param {string} config.dns - The DNS server to set (required for static configuration).
|
|
86
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
87
|
+
*/
|
|
88
|
+
export declare function triggerShellyChangeIp(matterbridge: Matterbridge, config: {
|
|
89
|
+
type: 'static' | 'dhcp';
|
|
90
|
+
ip: string;
|
|
91
|
+
subnet: string;
|
|
92
|
+
gateway: string;
|
|
93
|
+
dns: string;
|
|
94
|
+
}): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Triggers Shelly system reboot.
|
|
97
|
+
*
|
|
98
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
99
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
100
|
+
*/
|
|
101
|
+
export declare function triggerShellyReboot(matterbridge: Matterbridge): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Triggers Shelly soft reset.
|
|
104
|
+
* It will replaces network config with the default one (edn0 on dhcp).
|
|
105
|
+
*
|
|
106
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
107
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
108
|
+
*/
|
|
109
|
+
export declare function triggerShellySoftReset(matterbridge: Matterbridge): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Triggers Shelly hard reset.
|
|
112
|
+
* It will do a hard reset and will remove both directories .matterbridge Matterbridge.
|
|
113
|
+
*
|
|
114
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
115
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
116
|
+
*/
|
|
117
|
+
export declare function triggerShellyHardReset(matterbridge: Matterbridge): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* Fetches Shelly system log and write it to shelly.log.
|
|
120
|
+
*
|
|
121
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
122
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the log was successfully downloaded, false otherwise.
|
|
123
|
+
*/
|
|
124
|
+
export declare function createShellySystemLog(matterbridge: Matterbridge): Promise<boolean>;
|
|
125
|
+
/**
|
|
126
|
+
* Perform a GET to Shelly board apis.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} api - The api to call:
|
|
129
|
+
*
|
|
130
|
+
* /api/updates/sys/check => [{name:string; ...}]
|
|
131
|
+
* /api/updates/sys/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
132
|
+
* /api/updates/sys/status => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
133
|
+
* /api/updates/main/check => [{name:string; ...}]
|
|
134
|
+
* /api/updates/main/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
135
|
+
* /api/updates/main/status => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
136
|
+
*
|
|
137
|
+
* /api/logs/system => text
|
|
138
|
+
*
|
|
139
|
+
* /api/reset/soft => "ok" Replaces network config with default one (edn0 on dhcp)
|
|
140
|
+
* /api/reset/hard => reboot on success Hard reset makes soft reset + removing both directories .matterbridge Matterbridge + reboot
|
|
141
|
+
*
|
|
142
|
+
*
|
|
143
|
+
* @param {number} [timeout] - The timeout duration in milliseconds (default is 60000ms).
|
|
144
|
+
* @returns {Promise<any>} A promise that resolves to the response.
|
|
145
|
+
* @throws {Error} If the request fails.
|
|
146
|
+
*/
|
|
147
|
+
export declare function getShelly(api: string, timeout?: number): Promise<any>;
|
|
148
|
+
/**
|
|
149
|
+
* Perform a POST request to Shelly board apis.
|
|
150
|
+
*
|
|
151
|
+
* @param {string} api - The api to call:
|
|
152
|
+
*
|
|
153
|
+
* Set static ip
|
|
154
|
+
* /api/network/connection/static -d '{"interface": "end0", "addr": "10.11.12.101", "mask": "255.255.255.0", "gw": "10.11.12.1", "dns": "1.1.1.1"}' => {}
|
|
155
|
+
*
|
|
156
|
+
* Set dhcp
|
|
157
|
+
* /api/network/connection/dynamic -d '{"interface": "end0"}' => {}
|
|
158
|
+
*
|
|
159
|
+
* Reboot
|
|
160
|
+
* /api/system/reboot => {"success":true}
|
|
161
|
+
*
|
|
162
|
+
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/dynamic
|
|
163
|
+
* -d '{"interface": "end0"}'
|
|
164
|
+
*
|
|
165
|
+
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/static
|
|
166
|
+
* -d '{"interface": "end0", "addr": "192.168.1.64", "mask": "255.255.255.0", "gw": "192.168.1.1", "dns": "192.168.1.1"}'
|
|
167
|
+
*
|
|
168
|
+
* @param {any} data - The data to send in the POST request, typically a JSON object.
|
|
169
|
+
* @param {number} [timeout] - The timeout duration in milliseconds (default is 60000ms).
|
|
170
|
+
* @returns {Promise<any>} A promise that resolves to the response.
|
|
171
|
+
* @throws {Error} If the request fails.
|
|
172
|
+
*/
|
|
173
|
+
export declare function postShelly(api: string, data: any, timeout?: number): Promise<any>;
|
|
174
|
+
//# sourceMappingURL=shelly.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shelly.d.ts","sourceRoot":"","sources":["../src/shelly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAQH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMjD;;;;;GA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AAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAetF;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAexF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,SAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CA+C1E;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,SAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAuDtF"}
|
package/dist/shelly.js
CHANGED
|
@@ -1,13 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the shelly api functions.
|
|
3
|
+
*
|
|
4
|
+
* @file shelly.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-02-19
|
|
7
|
+
* @version 1.1.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
1
24
|
import { debugStringify } from 'node-ansi-logger';
|
|
2
25
|
import { WS_ID_SHELLY_MAIN_UPDATE, WS_ID_SHELLY_SYS_UPDATE } from './frontend.js';
|
|
3
26
|
let verifyIntervalSecs = 15;
|
|
4
27
|
let verifyTimeoutSecs = 600;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the interval for verification in seconds.
|
|
30
|
+
*
|
|
31
|
+
* @param {number} seconds - The interval in seconds.
|
|
32
|
+
* @returns {void}
|
|
33
|
+
*/
|
|
5
34
|
export function setVerifyIntervalSecs(seconds) {
|
|
6
35
|
verifyIntervalSecs = seconds;
|
|
7
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Sets the timeout for verification in seconds.
|
|
39
|
+
*
|
|
40
|
+
* @param {number} seconds - The timeout in seconds.
|
|
41
|
+
* @returns {void}
|
|
42
|
+
*/
|
|
8
43
|
export function setVerifyTimeoutSecs(seconds) {
|
|
9
44
|
verifyTimeoutSecs = seconds;
|
|
10
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Fetches Shelly system updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
|
|
48
|
+
*
|
|
49
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
50
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
51
|
+
*/
|
|
11
52
|
export async function getShellySysUpdate(matterbridge) {
|
|
12
53
|
try {
|
|
13
54
|
const updates = (await getShelly('/api/updates/sys/check'));
|
|
@@ -26,19 +67,33 @@ export async function getShellySysUpdate(matterbridge) {
|
|
|
26
67
|
matterbridge.log.error(`Error getting Shelly system updates: ${err instanceof Error ? err.message : String(err)}`);
|
|
27
68
|
}
|
|
28
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Triggers Shelly system updates.
|
|
72
|
+
*
|
|
73
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
74
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
75
|
+
*/
|
|
29
76
|
export async function triggerShellySysUpdate(matterbridge) {
|
|
30
77
|
try {
|
|
78
|
+
// Trigger the update request
|
|
31
79
|
await getShelly('/api/updates/sys/perform');
|
|
32
80
|
matterbridge.log.notice('Installing Shelly system update...');
|
|
33
81
|
matterbridge.matterbridgeInformation.shellySysUpdate = false;
|
|
34
82
|
matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly system update...', 15);
|
|
35
83
|
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_SYS_UPDATE, 'shelly-sys-update', { available: false });
|
|
84
|
+
// Begin polling update status
|
|
36
85
|
await verifyShellyUpdate(matterbridge, '/api/updates/sys/status', 'Shelly system update');
|
|
37
86
|
}
|
|
38
87
|
catch (err) {
|
|
39
88
|
matterbridge.log.error(`Error triggering Shelly system update: ${err instanceof Error ? err.message : String(err)}`);
|
|
40
89
|
}
|
|
41
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Fetches Shelly main updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
|
|
93
|
+
*
|
|
94
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
95
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
96
|
+
*/
|
|
42
97
|
export async function getShellyMainUpdate(matterbridge) {
|
|
43
98
|
try {
|
|
44
99
|
const updates = (await getShelly('/api/updates/main/check'));
|
|
@@ -57,19 +112,35 @@ export async function getShellyMainUpdate(matterbridge) {
|
|
|
57
112
|
matterbridge.log.error(`Error getting Shelly main updates: ${err instanceof Error ? err.message : String(err)}`);
|
|
58
113
|
}
|
|
59
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Triggers Shelly main updates.
|
|
117
|
+
*
|
|
118
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
119
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
120
|
+
*/
|
|
60
121
|
export async function triggerShellyMainUpdate(matterbridge) {
|
|
61
122
|
try {
|
|
123
|
+
// Trigger the perform-update request
|
|
62
124
|
await getShelly('/api/updates/main/perform');
|
|
63
125
|
matterbridge.log.notice('Installing Shelly software update...');
|
|
64
126
|
matterbridge.matterbridgeInformation.shellyMainUpdate = false;
|
|
65
127
|
matterbridge.frontend.wssSendSnackbarMessage('Installing Shelly software update...', 15);
|
|
66
128
|
matterbridge.frontend.wssBroadcastMessage(WS_ID_SHELLY_MAIN_UPDATE, 'shelly-main-update', { available: false });
|
|
129
|
+
// Begin polling the update status
|
|
67
130
|
await verifyShellyUpdate(matterbridge, '/api/updates/main/status', 'Shelly software update');
|
|
68
131
|
}
|
|
69
132
|
catch (err) {
|
|
70
133
|
matterbridge.log.error(`Error triggering Shelly main update: ${err instanceof Error ? err.message : String(err)}`);
|
|
71
134
|
}
|
|
72
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Verifies Shelly update.
|
|
138
|
+
*
|
|
139
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
140
|
+
* @param {string} api - The api to call: /api/updates/sys/status or /api/updates/main/status
|
|
141
|
+
* @param {string} name - The name of the update.
|
|
142
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
143
|
+
*/
|
|
73
144
|
export async function verifyShellyUpdate(matterbridge, api, name) {
|
|
74
145
|
return new Promise((resolve) => {
|
|
75
146
|
const timeout = setTimeout(() => {
|
|
@@ -77,9 +148,9 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
|
|
|
77
148
|
matterbridge.frontend.wssSendCloseSnackbarMessage(`${name} in progress...`);
|
|
78
149
|
clearInterval(interval);
|
|
79
150
|
resolve();
|
|
80
|
-
}, verifyTimeoutSecs * 1000);
|
|
151
|
+
}, verifyTimeoutSecs * 1000); // 10 minutes
|
|
81
152
|
const interval = setInterval(() => {
|
|
82
|
-
getShelly(api, 10 * 1000)
|
|
153
|
+
getShelly(api, 10 * 1000) // 10 seconds
|
|
83
154
|
.then(async (data) => {
|
|
84
155
|
if (data.updatingInProgress) {
|
|
85
156
|
matterbridge.log.debug(`${name} in progress...`);
|
|
@@ -102,9 +173,21 @@ export async function verifyShellyUpdate(matterbridge, api, name) {
|
|
|
102
173
|
clearTimeout(timeout);
|
|
103
174
|
resolve();
|
|
104
175
|
});
|
|
105
|
-
}, verifyIntervalSecs * 1000);
|
|
176
|
+
}, verifyIntervalSecs * 1000); // 15 seconds
|
|
106
177
|
});
|
|
107
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Triggers Shelly change network configuration.
|
|
181
|
+
*
|
|
182
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
183
|
+
* @param {object} config - The network configuration.
|
|
184
|
+
* @param {string} config.type - The type of network configuration, either 'static' or 'dhcp'.
|
|
185
|
+
* @param {string} config.ip - The IP address to set (required for static configuration).
|
|
186
|
+
* @param {string} config.subnet - The subnet mask to set (required for static configuration).
|
|
187
|
+
* @param {string} config.gateway - The gateway to set (required for static configuration).
|
|
188
|
+
* @param {string} config.dns - The DNS server to set (required for static configuration).
|
|
189
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
190
|
+
*/
|
|
108
191
|
export async function triggerShellyChangeIp(matterbridge, config) {
|
|
109
192
|
const api = config.type === 'static' ? '/api/network/connection/static' : '/api/network/connection/dynamic';
|
|
110
193
|
const data = { interface: 'end0' };
|
|
@@ -127,6 +210,12 @@ export async function triggerShellyChangeIp(matterbridge, config) {
|
|
|
127
210
|
matterbridge.frontend.wssSendSnackbarMessage('Error changing Shelly network configuration', 10, 'error');
|
|
128
211
|
}
|
|
129
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Triggers Shelly system reboot.
|
|
215
|
+
*
|
|
216
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
217
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
218
|
+
*/
|
|
130
219
|
export async function triggerShellyReboot(matterbridge) {
|
|
131
220
|
matterbridge.log.debug(`Triggering Shelly system reboot`);
|
|
132
221
|
try {
|
|
@@ -144,6 +233,13 @@ export async function triggerShellyReboot(matterbridge) {
|
|
|
144
233
|
matterbridge.frontend.wssSendSnackbarMessage('Error rebooting Shelly board', 10, 'error');
|
|
145
234
|
}
|
|
146
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Triggers Shelly soft reset.
|
|
238
|
+
* It will replaces network config with the default one (edn0 on dhcp).
|
|
239
|
+
*
|
|
240
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
241
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
242
|
+
*/
|
|
147
243
|
export async function triggerShellySoftReset(matterbridge) {
|
|
148
244
|
matterbridge.log.debug(`Triggering Shelly soft reset`);
|
|
149
245
|
try {
|
|
@@ -161,6 +257,13 @@ export async function triggerShellySoftReset(matterbridge) {
|
|
|
161
257
|
matterbridge.frontend.wssSendSnackbarMessage('Error resetting the network parameters on Shelly board', 10, 'error');
|
|
162
258
|
}
|
|
163
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Triggers Shelly hard reset.
|
|
262
|
+
* It will do a hard reset and will remove both directories .matterbridge Matterbridge.
|
|
263
|
+
*
|
|
264
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
265
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
266
|
+
*/
|
|
164
267
|
export async function triggerShellyHardReset(matterbridge) {
|
|
165
268
|
matterbridge.log.debug(`Triggering Shelly hard reset`);
|
|
166
269
|
try {
|
|
@@ -178,6 +281,12 @@ export async function triggerShellyHardReset(matterbridge) {
|
|
|
178
281
|
matterbridge.frontend.wssSendSnackbarMessage('Error while factory resetting the Shelly board', 10, 'error');
|
|
179
282
|
}
|
|
180
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Fetches Shelly system log and write it to shelly.log.
|
|
286
|
+
*
|
|
287
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
288
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the log was successfully downloaded, false otherwise.
|
|
289
|
+
*/
|
|
181
290
|
export async function createShellySystemLog(matterbridge) {
|
|
182
291
|
const { promises: fs } = await import('node:fs');
|
|
183
292
|
const path = await import('node:path');
|
|
@@ -194,6 +303,28 @@ export async function createShellySystemLog(matterbridge) {
|
|
|
194
303
|
return false;
|
|
195
304
|
}
|
|
196
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Perform a GET to Shelly board apis.
|
|
308
|
+
*
|
|
309
|
+
* @param {string} api - The api to call:
|
|
310
|
+
*
|
|
311
|
+
* /api/updates/sys/check => [{name:string; ...}]
|
|
312
|
+
* /api/updates/sys/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
313
|
+
* /api/updates/sys/status => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
314
|
+
* /api/updates/main/check => [{name:string; ...}]
|
|
315
|
+
* /api/updates/main/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
316
|
+
* /api/updates/main/status => {"updatingInProgress":true} or {"updatingInProgress":false}
|
|
317
|
+
*
|
|
318
|
+
* /api/logs/system => text
|
|
319
|
+
*
|
|
320
|
+
* /api/reset/soft => "ok" Replaces network config with default one (edn0 on dhcp)
|
|
321
|
+
* /api/reset/hard => reboot on success Hard reset makes soft reset + removing both directories .matterbridge Matterbridge + reboot
|
|
322
|
+
*
|
|
323
|
+
*
|
|
324
|
+
* @param {number} [timeout] - The timeout duration in milliseconds (default is 60000ms).
|
|
325
|
+
* @returns {Promise<any>} A promise that resolves to the response.
|
|
326
|
+
* @throws {Error} If the request fails.
|
|
327
|
+
*/
|
|
197
328
|
export async function getShelly(api, timeout = 60000) {
|
|
198
329
|
const http = await import('node:http');
|
|
199
330
|
return new Promise((resolve, reject) => {
|
|
@@ -207,12 +338,13 @@ export async function getShelly(api, timeout = 60000) {
|
|
|
207
338
|
let data = '';
|
|
208
339
|
if (res.statusCode !== 200) {
|
|
209
340
|
clearTimeout(timeoutId);
|
|
210
|
-
res.resume();
|
|
211
|
-
req.destroy();
|
|
341
|
+
res.resume(); // Discard response data to close the socket properly
|
|
342
|
+
req.destroy(); // Forcefully close the request
|
|
212
343
|
reject(new Error(`Failed to fetch data. Status code: ${res.statusCode}`));
|
|
213
344
|
return;
|
|
214
345
|
}
|
|
215
346
|
res.on('data', (chunk) => {
|
|
347
|
+
// console.log(chunk);
|
|
216
348
|
data += chunk;
|
|
217
349
|
});
|
|
218
350
|
res.on('end', () => {
|
|
@@ -227,6 +359,7 @@ export async function getShelly(api, timeout = 60000) {
|
|
|
227
359
|
}
|
|
228
360
|
}
|
|
229
361
|
else {
|
|
362
|
+
// console.log(data);
|
|
230
363
|
resolve(data);
|
|
231
364
|
}
|
|
232
365
|
});
|
|
@@ -237,6 +370,31 @@ export async function getShelly(api, timeout = 60000) {
|
|
|
237
370
|
});
|
|
238
371
|
});
|
|
239
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Perform a POST request to Shelly board apis.
|
|
375
|
+
*
|
|
376
|
+
* @param {string} api - The api to call:
|
|
377
|
+
*
|
|
378
|
+
* Set static ip
|
|
379
|
+
* /api/network/connection/static -d '{"interface": "end0", "addr": "10.11.12.101", "mask": "255.255.255.0", "gw": "10.11.12.1", "dns": "1.1.1.1"}' => {}
|
|
380
|
+
*
|
|
381
|
+
* Set dhcp
|
|
382
|
+
* /api/network/connection/dynamic -d '{"interface": "end0"}' => {}
|
|
383
|
+
*
|
|
384
|
+
* Reboot
|
|
385
|
+
* /api/system/reboot => {"success":true}
|
|
386
|
+
*
|
|
387
|
+
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/dynamic
|
|
388
|
+
* -d '{"interface": "end0"}'
|
|
389
|
+
*
|
|
390
|
+
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/static
|
|
391
|
+
* -d '{"interface": "end0", "addr": "192.168.1.64", "mask": "255.255.255.0", "gw": "192.168.1.1", "dns": "192.168.1.1"}'
|
|
392
|
+
*
|
|
393
|
+
* @param {any} data - The data to send in the POST request, typically a JSON object.
|
|
394
|
+
* @param {number} [timeout] - The timeout duration in milliseconds (default is 60000ms).
|
|
395
|
+
* @returns {Promise<any>} A promise that resolves to the response.
|
|
396
|
+
* @throws {Error} If the request fails.
|
|
397
|
+
*/
|
|
240
398
|
export async function postShelly(api, data, timeout = 60000) {
|
|
241
399
|
const http = await import('node:http');
|
|
242
400
|
return new Promise((resolve, reject) => {
|
|
@@ -257,10 +415,11 @@ export async function postShelly(api, data, timeout = 60000) {
|
|
|
257
415
|
};
|
|
258
416
|
const req = http.request(url, options, (res) => {
|
|
259
417
|
let responseData = '';
|
|
418
|
+
// Check for non-success status codes (e.g., 300+)
|
|
260
419
|
if (res.statusCode && res.statusCode >= 300) {
|
|
261
420
|
clearTimeout(timeoutId);
|
|
262
|
-
res.resume();
|
|
263
|
-
req.destroy();
|
|
421
|
+
res.resume(); // Discard response data to free up memory
|
|
422
|
+
req.destroy(); // Close the request
|
|
264
423
|
return reject(new Error(`Failed to post data. Status code: ${res.statusCode}`));
|
|
265
424
|
}
|
|
266
425
|
res.on('data', (chunk) => {
|
|
@@ -281,7 +440,9 @@ export async function postShelly(api, data, timeout = 60000) {
|
|
|
281
440
|
clearTimeout(timeoutId);
|
|
282
441
|
reject(new Error(`Request failed: ${error instanceof Error ? error.message : error}`));
|
|
283
442
|
});
|
|
443
|
+
// Send the JSON data
|
|
284
444
|
req.write(jsonData);
|
|
285
445
|
req.end();
|
|
286
446
|
});
|
|
287
447
|
}
|
|
448
|
+
//# sourceMappingURL=shelly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shelly.js","sourceRoot":"","sources":["../src/shelly.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAElF,IAAI,kBAAkB,GAAG,EAAE,CAAC;AAC5B,IAAI,iBAAiB,GAAG,GAAG,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe;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C,kCAAkC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBAClG,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACxB,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,MAAM,CAAC,IAAI,KAAK,CAAC,mBAAmB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;QAEH,qBAAqB;QACrB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QACpB,GAAG,CAAC,GAAG,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
package/dist/storage/export.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/storage/export.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
package/dist/update.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the check updates functions.
|
|
3
|
+
*
|
|
4
|
+
* @file update.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-02-24
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
import { Matterbridge } from './matterbridge.js';
|
|
25
|
+
import { RegisteredPlugin } from './matterbridgeTypes.js';
|
|
26
|
+
/**
|
|
27
|
+
* Checks for updates for Matterbridge and its plugins.
|
|
28
|
+
* If the 'shelly' parameter is present, also checks for Shelly updates.
|
|
29
|
+
*
|
|
30
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
31
|
+
* @returns {Promise<void>} A promise that resolves when the update checks are complete.
|
|
32
|
+
*/
|
|
33
|
+
export declare function checkUpdates(matterbridge: Matterbridge): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Checks for updates and logs from GitHub.
|
|
36
|
+
* If the update check fails, logs a warning message.
|
|
37
|
+
*
|
|
38
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
39
|
+
*/
|
|
40
|
+
export declare function checkUpdatesAndLog(matterbridge: Matterbridge): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves the latest version of Matterbridge and updates the matterbridgeLatestVersion property.
|
|
43
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
44
|
+
*
|
|
45
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
46
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest version is retrieved.
|
|
47
|
+
*/
|
|
48
|
+
export declare function getMatterbridgeLatestVersion(matterbridge: Matterbridge): Promise<string | undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Retrieves the latest dev version of Matterbridge and updates the matterbridgeDevVersion property.
|
|
51
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
52
|
+
*
|
|
53
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
54
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest dev version is retrieved.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getMatterbridgeDevVersion(matterbridge: Matterbridge): Promise<string | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves the latest version of a plugin and updates the plugin's latestVersion property.
|
|
59
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
60
|
+
*
|
|
61
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
62
|
+
* @param {RegisteredPlugin} plugin - The plugin for which to retrieve the latest version.
|
|
63
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest version is retrieved.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getPluginLatestVersion(matterbridge: Matterbridge, plugin: RegisteredPlugin): Promise<string | undefined>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the latest dev version of a plugin and updates the plugin's devVersion property.
|
|
68
|
+
* If there is an error retrieving the latest version, logs an error message.
|
|
69
|
+
*
|
|
70
|
+
* @param {Matterbridge} matterbridge - The Matterbridge instance.
|
|
71
|
+
* @param {RegisteredPlugin} plugin - The plugin for which to retrieve the latest version.
|
|
72
|
+
* @returns {Promise<string | undefined>} A promise that resolves when the latest dev version is retrieved.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getPluginDevVersion(matterbridge: Matterbridge, plugin: RegisteredPlugin): Promise<string | undefined>;
|
|
75
|
+
//# sourceMappingURL=update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../src/update.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAO,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB5E;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBlF;AAED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAqB1G;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoBvG;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB9H;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB3H"}
|