matterbridge
Version:
Matterbridge plugin manager for Matter
161 lines • 7.06 kB
TypeScript
/**
* This file contains the shelly api functions.
*
* @file shelly.ts
* @author Luca Liguori
* @date 2025-02-19
* @version 1.1.0
*
* Copyright 2025, 2026, 2027 Luca Liguori.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. *
*/
import { Matterbridge } from './matterbridge.js';
/**
* Sets the interval for verification in seconds.
*
* @param {number} seconds - The interval in seconds.
* @returns {void}
*/
export declare function setVerifyIntervalSecs(seconds: number): void;
/**
* Sets the timeout for verification in seconds.
*
* @param {number} seconds - The timeout in seconds.
* @returns {void}
*/
export declare function setVerifyTimeoutSecs(seconds: number): void;
/**
* Fetches Shelly system updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
*
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function getShellySysUpdate(matterbridge: Matterbridge): Promise<void>;
/**
* Triggers Shelly system updates.
*
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function triggerShellySysUpdate(matterbridge: Matterbridge): Promise<void>;
/**
* Fetches Shelly main updates. If available: logs the result, sends a snackbar message, and broadcasts the message.
*
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function getShellyMainUpdate(matterbridge: Matterbridge): Promise<void>;
/**
* Triggers Shelly main updates.
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function triggerShellyMainUpdate(matterbridge: Matterbridge): Promise<void>;
/**
* Verifies Shelly update.
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @param {string} api - The api to call: /api/updates/sys/status or /api/updates/main/status
* @param {string} name - The name of the update.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function verifyShellyUpdate(matterbridge: Matterbridge, api: string, name: string): Promise<void>;
/**
* Triggers Shelly change network configuration.
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @param {object} config - The network configuration.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function triggerShellyChangeIp(matterbridge: Matterbridge, config: {
type: 'static' | 'dhcp';
ip: string;
subnet: string;
gateway: string;
dns: string;
}): Promise<void>;
/**
* Triggers Shelly system reboot.
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function triggerShellyReboot(matterbridge: Matterbridge): Promise<void>;
/**
* Triggers Shelly soft reset.
* It will replaces network config with the default one (edn0 on dhcp).
*
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function triggerShellySoftReset(matterbridge: Matterbridge): Promise<void>;
/**
* Triggers Shelly hard reset.
* It will do a hard reset and will remove both directories .matterbridge Matterbridge.
*
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function triggerShellyHardReset(matterbridge: Matterbridge): Promise<void>;
/**
* Fetches Shelly system log and write it to shelly.log.
*
* @param {Matterbridge} matterbridge - The Matterbridge instance.
* @returns {Promise<void>} A promise that resolves when the operation is complete.
*/
export declare function createShellySystemLog(matterbridge: Matterbridge): Promise<void>;
/**
* Perform a GET to Shelly board apis.
* @param {string} api - The api to call:
*
* /api/updates/sys/check => [{name:string; ...}]
* /api/updates/sys/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
* /api/updates/sys/status => {"updatingInProgress":true} or {"updatingInProgress":false}
* /api/updates/main/check => [{name:string; ...}]
* /api/updates/main/perform => {"updatingInProgress":true} or {"updatingInProgress":false}
* /api/updates/main/status => {"updatingInProgress":true} or {"updatingInProgress":false}
*
* /api/logs/system => text
*
* /api/reset/soft => "ok" Replaces network config with default one (edn0 on dhcp)
* /api/reset/hard => reboot on success Hard reset makes soft reset + removing both directories .matterbridge Matterbridge + reboot
*
*
* @param {number} [timeout=60000] - The timeout duration in milliseconds (default is 60000ms).
* @returns {Promise<any>} A promise that resolves to the response.
* @throws {Error} If the request fails.
*/
export declare function getShelly(api: string, timeout?: number): Promise<any>;
/**
* Perform a POST request to Shelly board apis.
* @param {string} api - The api to call:
*
* Set static ip
* /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"}' => {}
*
* Set dhcp
* /api/network/connection/dynamic -d '{"interface": "end0"}' => {}
*
* Reboot
* /api/system/reboot => {"success":true}
*
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/dynamic
* -d '{"interface": "end0"}'
*
* curl -H "Content-Type: application/json" -X POST http://127.0.0.1:8101/api/network/connection/static
* -d '{"interface": "end0", "addr": "192.168.1.64", "mask": "255.255.255.0", "gw": "192.168.1.1", "dns": "192.168.1.1"}'
*
* @param {number} [timeout=60000] - The timeout duration in milliseconds (default is 60000ms).
* @returns {Promise<any>} A promise that resolves to the response.
* @throws {Error} If the request fails.
*/
export declare function postShelly(api: string, data: any, timeout?: number): Promise<any>;
//# sourceMappingURL=shelly.d.ts.map